Clean up garage

This commit is contained in:
Mike Cifelli 2023-01-06 09:55:07 -05:00
parent 1047effcb8
commit 39eba9b6f5
2 changed files with 23 additions and 26 deletions

View File

@ -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.showClosedDoor(self.eastDoorStartColumn)
else:
self.showOpenDoor(self.eastDoorStartColumn)
def showOpenDoor(self, column):
self.symbolDisplay.displaySquare(
x=self.eastDoorStartColumn,
x=column,
y=self.topRow,
outlineColor=self.closedOutlineColor,
fillColor=self.closedFillColor
)
else:
def showClosedDoor(self, column):
self.symbolDisplay.displaySquare(
x=self.eastDoorStartColumn,
x=column,
y=self.topRow,
outlineColor=self.openOutlineColor,
fillColor=self.openFillColor
outlineColor=self.closedOutlineColor,
fillColor=self.closedFillColor
)

View File

@ -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):