Rename class for clarity
This commit is contained in:
parent
3c5404a3da
commit
1047effcb8
|
@ -3,8 +3,8 @@ import json
|
||||||
|
|
||||||
|
|
||||||
class GarageDisplay:
|
class GarageDisplay:
|
||||||
def __init__(self, characterDisplay, topRow):
|
def __init__(self, symbolDisplay, topRow):
|
||||||
self.characterDisplay = characterDisplay
|
self.symbolDisplay = symbolDisplay
|
||||||
self.topRow = topRow
|
self.topRow = topRow
|
||||||
self.westDoorStartColumn = 1
|
self.westDoorStartColumn = 1
|
||||||
self.eastDoorStartColumn = 12
|
self.eastDoorStartColumn = 12
|
||||||
|
@ -21,7 +21,7 @@ class GarageDisplay:
|
||||||
# TODO - only update the changed door so the other one doesn't flicker
|
# 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.characterDisplay.clearRow(self.topRow, rowHeight=4)
|
self.symbolDisplay.clearRow(self.topRow, rowHeight=4)
|
||||||
|
|
||||||
if self.isGarageStateValid(state):
|
if self.isGarageStateValid(state):
|
||||||
self.showState(state)
|
self.showState(state)
|
||||||
|
@ -39,14 +39,14 @@ class GarageDisplay:
|
||||||
|
|
||||||
def showState(self, state):
|
def showState(self, state):
|
||||||
if state["west-door"] == "closed":
|
if state["west-door"] == "closed":
|
||||||
self.characterDisplay.displaySquare(
|
self.symbolDisplay.displaySquare(
|
||||||
x=self.westDoorStartColumn,
|
x=self.westDoorStartColumn,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
outlineColor=self.closedOutlineColor,
|
outlineColor=self.closedOutlineColor,
|
||||||
fillColor=self.closedFillColor
|
fillColor=self.closedFillColor
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.characterDisplay.displaySquare(
|
self.symbolDisplay.displaySquare(
|
||||||
x=self.westDoorStartColumn,
|
x=self.westDoorStartColumn,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
outlineColor=self.openOutlineColor,
|
outlineColor=self.openOutlineColor,
|
||||||
|
@ -54,14 +54,14 @@ class GarageDisplay:
|
||||||
)
|
)
|
||||||
|
|
||||||
if state["east-door"] == "closed":
|
if state["east-door"] == "closed":
|
||||||
self.characterDisplay.displaySquare(
|
self.symbolDisplay.displaySquare(
|
||||||
x=self.eastDoorStartColumn,
|
x=self.eastDoorStartColumn,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
outlineColor=self.closedOutlineColor,
|
outlineColor=self.closedOutlineColor,
|
||||||
fillColor=self.closedFillColor
|
fillColor=self.closedFillColor
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.characterDisplay.displaySquare(
|
self.symbolDisplay.displaySquare(
|
||||||
x=self.eastDoorStartColumn,
|
x=self.eastDoorStartColumn,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
outlineColor=self.openOutlineColor,
|
outlineColor=self.openOutlineColor,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import json
|
||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from chutney.character_display import CharacterDisplay
|
from chutney.symbol_display import SymbolDisplay
|
||||||
from chutney.garage import GarageDisplay
|
from chutney.garage import GarageDisplay
|
||||||
from chutney.garage import GarageUpdater
|
from chutney.garage import GarageUpdater
|
||||||
from chutney.time import TimeDisplay
|
from chutney.time import TimeDisplay
|
||||||
|
@ -44,10 +44,10 @@ def main():
|
||||||
|
|
||||||
unicorn.brightness(0.3)
|
unicorn.brightness(0.3)
|
||||||
|
|
||||||
characterDisplay = CharacterDisplay(unicorn)
|
symbolDisplay = SymbolDisplay(unicorn)
|
||||||
timeDisplay = TimeDisplay(characterDisplay, topRow=15)
|
timeDisplay = TimeDisplay(symbolDisplay, topRow=15)
|
||||||
weatherDisplay = WeatherDisplay(characterDisplay, topRow=9)
|
weatherDisplay = WeatherDisplay(symbolDisplay, topRow=9)
|
||||||
garageDisplay = GarageDisplay(characterDisplay, topRow=3)
|
garageDisplay = GarageDisplay(symbolDisplay, topRow=3)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
timeDisplay.showTime()
|
timeDisplay.showTime()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import chutney.colors as colors
|
import chutney.colors as colors
|
||||||
|
|
||||||
|
|
||||||
class CharacterDisplay:
|
class SymbolDisplay:
|
||||||
|
|
||||||
def __init__(self, unicorn, minX=0, maxX=15, minY=0, maxY=15):
|
def __init__(self, unicorn, minX=0, maxX=15, minY=0, maxY=15):
|
||||||
self.unicorn = unicorn
|
self.unicorn = unicorn
|
|
@ -5,8 +5,8 @@ from datetime import datetime
|
||||||
|
|
||||||
class TimeDisplay:
|
class TimeDisplay:
|
||||||
|
|
||||||
def __init__(self, characterDisplay, topRow):
|
def __init__(self, symbolDisplay, topRow):
|
||||||
self.characterDisplay = characterDisplay
|
self.symbolDisplay = symbolDisplay
|
||||||
self.topRow = topRow
|
self.topRow = topRow
|
||||||
self.currentHour = [-1, -1]
|
self.currentHour = [-1, -1]
|
||||||
self.currentMinute = [-1, -1]
|
self.currentMinute = [-1, -1]
|
||||||
|
@ -37,7 +37,7 @@ class TimeDisplay:
|
||||||
|
|
||||||
def showTimeDots(self):
|
def showTimeDots(self):
|
||||||
if self.color != self.currentColor:
|
if self.color != self.currentColor:
|
||||||
self.characterDisplay.displayTimeDots(
|
self.symbolDisplay.displayTimeDots(
|
||||||
x=self.timeDotsColumn,
|
x=self.timeDotsColumn,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
color=self.color
|
color=self.color
|
||||||
|
@ -53,7 +53,7 @@ class TimeDisplay:
|
||||||
self.showDigit(self.minuteStartColumn + 4, minute[1])
|
self.showDigit(self.minuteStartColumn + 4, minute[1])
|
||||||
|
|
||||||
def showDigit(self, x, digit):
|
def showDigit(self, x, digit):
|
||||||
self.characterDisplay.displayDigit(
|
self.symbolDisplay.displayDigit(
|
||||||
x=x,
|
x=x,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
digit=digit,
|
digit=digit,
|
||||||
|
@ -61,7 +61,7 @@ class TimeDisplay:
|
||||||
)
|
)
|
||||||
|
|
||||||
def hideDigit(self, x):
|
def hideDigit(self, x):
|
||||||
self.characterDisplay.clearDigit(
|
self.symbolDisplay.clearDigit(
|
||||||
x=x,
|
x=x,
|
||||||
y=self.topRow
|
y=self.topRow
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,8 +2,8 @@ import chutney.colors as colors
|
||||||
|
|
||||||
|
|
||||||
class WeatherDisplay:
|
class WeatherDisplay:
|
||||||
def __init__(self, characterDisplay, topRow):
|
def __init__(self, symbolDisplay, topRow):
|
||||||
self.characterDisplay = characterDisplay
|
self.symbolDisplay = symbolDisplay
|
||||||
self.topRow = topRow
|
self.topRow = topRow
|
||||||
self.twoDigitStartColumn = 5
|
self.twoDigitStartColumn = 5
|
||||||
self.oneDigitStartColumn = 7
|
self.oneDigitStartColumn = 7
|
||||||
|
@ -17,7 +17,7 @@ class WeatherDisplay:
|
||||||
|
|
||||||
if temperature != self.currentTemperature:
|
if temperature != self.currentTemperature:
|
||||||
self.currentTemperature = temperature
|
self.currentTemperature = temperature
|
||||||
self.characterDisplay.clearRow(self.topRow)
|
self.symbolDisplay.clearRow(self.topRow)
|
||||||
|
|
||||||
if self.isTemperatureValid(temperature):
|
if self.isTemperatureValid(temperature):
|
||||||
self.showTemperature(list(temperature))
|
self.showTemperature(list(temperature))
|
||||||
|
@ -38,13 +38,13 @@ class WeatherDisplay:
|
||||||
|
|
||||||
for c in temperature:
|
for c in temperature:
|
||||||
if c == '-':
|
if c == '-':
|
||||||
self.characterDisplay.displayNegative(
|
self.symbolDisplay.displayNegative(
|
||||||
x=start-3,
|
x=start-3,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
color=self.color
|
color=self.color
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.characterDisplay.displayDigit(
|
self.symbolDisplay.displayDigit(
|
||||||
x=start,
|
x=start,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
digit=c,
|
digit=c,
|
||||||
|
@ -52,7 +52,7 @@ class WeatherDisplay:
|
||||||
)
|
)
|
||||||
start = start + self.digitWidth
|
start = start + self.digitWidth
|
||||||
|
|
||||||
self.characterDisplay.displayDegree(
|
self.symbolDisplay.displayDegree(
|
||||||
x=start,
|
x=start,
|
||||||
y=self.topRow,
|
y=self.topRow,
|
||||||
color=self.color
|
color=self.color
|
||||||
|
|
Loading…
Reference in New Issue