diff --git a/chutney/garage/garage_display.py b/chutney/garage/garage_display.py index 8cdc329..62624b9 100644 --- a/chutney/garage/garage_display.py +++ b/chutney/garage/garage_display.py @@ -15,13 +15,13 @@ class GarageDisplay: self.openFillColor = colors.WHITE self.garageFile = 'data/garage.json' + self.symbolDisplay.clearRow(self.topRow, rowHeight=4) + def showGarageState(self): state = self.getGarageState() - # TODO - only update the changed door so the other one doesn't flicker if state != self.currentState: self.currentState = state - self.symbolDisplay.clearRow(self.topRow, rowHeight=4) if self.isGarageStateValid(state): self.showState(state) @@ -39,31 +39,27 @@ class GarageDisplay: def showState(self, state): if state["west-door"] == "closed": - self.symbolDisplay.displaySquare( - x=self.westDoorStartColumn, - y=self.topRow, - outlineColor=self.closedOutlineColor, - fillColor=self.closedFillColor - ) + self.showClosedDoor(self.westDoorStartColumn) else: - self.symbolDisplay.displaySquare( - x=self.westDoorStartColumn, - y=self.topRow, - outlineColor=self.openOutlineColor, - fillColor=self.openFillColor - ) + self.showOpenDoor(self.westDoorStartColumn) if state["east-door"] == "closed": - self.symbolDisplay.displaySquare( - x=self.eastDoorStartColumn, - y=self.topRow, - outlineColor=self.closedOutlineColor, - fillColor=self.closedFillColor - ) + self.showClosedDoor(self.eastDoorStartColumn) else: - self.symbolDisplay.displaySquare( - x=self.eastDoorStartColumn, - y=self.topRow, - outlineColor=self.openOutlineColor, - fillColor=self.openFillColor - ) + self.showOpenDoor(self.eastDoorStartColumn) + + def showOpenDoor(self, column): + self.symbolDisplay.displaySquare( + x=column, + y=self.topRow, + outlineColor=self.closedOutlineColor, + fillColor=self.closedFillColor + ) + + def showClosedDoor(self, column): + self.symbolDisplay.displaySquare( + x=column, + y=self.topRow, + outlineColor=self.closedOutlineColor, + fillColor=self.closedFillColor + ) diff --git a/chutney/garage/garage_updater.py b/chutney/garage/garage_updater.py index 20d6cde..84651b4 100644 --- a/chutney/garage/garage_updater.py +++ b/chutney/garage/garage_updater.py @@ -12,6 +12,7 @@ class GarageUpdater: self.uri = config['garage'].get('uri') self.garageTempFile = 'data/garage.tmp' self.garageFile = 'data/garage.json' + self.persistGarageState('{"error": "init"}') def updateGarageState(self):