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.openFillColor = colors.WHITE
self.garageFile = 'data/garage.json' self.garageFile = 'data/garage.json'
self.symbolDisplay.clearRow(self.topRow, rowHeight=4)
def showGarageState(self): def showGarageState(self):
state = self.getGarageState() state = self.getGarageState()
# TODO - only update the changed door so the other one doesn't flicker
if state != self.currentState: if state != self.currentState:
self.currentState = state self.currentState = state
self.symbolDisplay.clearRow(self.topRow, rowHeight=4)
if self.isGarageStateValid(state): if self.isGarageStateValid(state):
self.showState(state) self.showState(state)
@ -39,31 +39,27 @@ class GarageDisplay:
def showState(self, state): def showState(self, state):
if state["west-door"] == "closed": if state["west-door"] == "closed":
self.symbolDisplay.displaySquare( self.showClosedDoor(self.westDoorStartColumn)
x=self.westDoorStartColumn,
y=self.topRow,
outlineColor=self.closedOutlineColor,
fillColor=self.closedFillColor
)
else: else:
self.symbolDisplay.displaySquare( self.showOpenDoor(self.westDoorStartColumn)
x=self.westDoorStartColumn,
y=self.topRow,
outlineColor=self.openOutlineColor,
fillColor=self.openFillColor
)
if state["east-door"] == "closed": if state["east-door"] == "closed":
self.showClosedDoor(self.eastDoorStartColumn)
else:
self.showOpenDoor(self.eastDoorStartColumn)
def showOpenDoor(self, column):
self.symbolDisplay.displaySquare( self.symbolDisplay.displaySquare(
x=self.eastDoorStartColumn, x=column,
y=self.topRow, y=self.topRow,
outlineColor=self.closedOutlineColor, outlineColor=self.closedOutlineColor,
fillColor=self.closedFillColor fillColor=self.closedFillColor
) )
else:
def showClosedDoor(self, column):
self.symbolDisplay.displaySquare( self.symbolDisplay.displaySquare(
x=self.eastDoorStartColumn, x=column,
y=self.topRow, y=self.topRow,
outlineColor=self.openOutlineColor, outlineColor=self.closedOutlineColor,
fillColor=self.openFillColor fillColor=self.closedFillColor
) )

View File

@ -12,6 +12,7 @@ class GarageUpdater:
self.uri = config['garage'].get('uri') self.uri = config['garage'].get('uri')
self.garageTempFile = 'data/garage.tmp' self.garageTempFile = 'data/garage.tmp'
self.garageFile = 'data/garage.json' self.garageFile = 'data/garage.json'
self.persistGarageState('{"error": "init"}') self.persistGarageState('{"error": "init"}')
def updateGarageState(self): def updateGarageState(self):