Rename class for clarity

This commit is contained in:
Mike Cifelli 2023-01-05 19:28:04 -05:00
parent 3c5404a3da
commit 1047effcb8
5 changed files with 24 additions and 24 deletions

View File

@ -3,8 +3,8 @@ import json
class GarageDisplay:
def __init__(self, characterDisplay, topRow):
self.characterDisplay = characterDisplay
def __init__(self, symbolDisplay, topRow):
self.symbolDisplay = symbolDisplay
self.topRow = topRow
self.westDoorStartColumn = 1
self.eastDoorStartColumn = 12
@ -21,7 +21,7 @@ class GarageDisplay:
# TODO - only update the changed door so the other one doesn't flicker
if state != self.currentState:
self.currentState = state
self.characterDisplay.clearRow(self.topRow, rowHeight=4)
self.symbolDisplay.clearRow(self.topRow, rowHeight=4)
if self.isGarageStateValid(state):
self.showState(state)
@ -39,14 +39,14 @@ class GarageDisplay:
def showState(self, state):
if state["west-door"] == "closed":
self.characterDisplay.displaySquare(
self.symbolDisplay.displaySquare(
x=self.westDoorStartColumn,
y=self.topRow,
outlineColor=self.closedOutlineColor,
fillColor=self.closedFillColor
)
else:
self.characterDisplay.displaySquare(
self.symbolDisplay.displaySquare(
x=self.westDoorStartColumn,
y=self.topRow,
outlineColor=self.openOutlineColor,
@ -54,14 +54,14 @@ class GarageDisplay:
)
if state["east-door"] == "closed":
self.characterDisplay.displaySquare(
self.symbolDisplay.displaySquare(
x=self.eastDoorStartColumn,
y=self.topRow,
outlineColor=self.closedOutlineColor,
fillColor=self.closedFillColor
)
else:
self.characterDisplay.displaySquare(
self.symbolDisplay.displaySquare(
x=self.eastDoorStartColumn,
y=self.topRow,
outlineColor=self.openOutlineColor,

View File

@ -2,7 +2,7 @@ import json
import requests
import sys
from chutney.character_display import CharacterDisplay
from chutney.symbol_display import SymbolDisplay
from chutney.garage import GarageDisplay
from chutney.garage import GarageUpdater
from chutney.time import TimeDisplay
@ -44,10 +44,10 @@ def main():
unicorn.brightness(0.3)
characterDisplay = CharacterDisplay(unicorn)
timeDisplay = TimeDisplay(characterDisplay, topRow=15)
weatherDisplay = WeatherDisplay(characterDisplay, topRow=9)
garageDisplay = GarageDisplay(characterDisplay, topRow=3)
symbolDisplay = SymbolDisplay(unicorn)
timeDisplay = TimeDisplay(symbolDisplay, topRow=15)
weatherDisplay = WeatherDisplay(symbolDisplay, topRow=9)
garageDisplay = GarageDisplay(symbolDisplay, topRow=3)
while True:
timeDisplay.showTime()

View File

@ -1,7 +1,7 @@
import chutney.colors as colors
class CharacterDisplay:
class SymbolDisplay:
def __init__(self, unicorn, minX=0, maxX=15, minY=0, maxY=15):
self.unicorn = unicorn

View File

@ -5,8 +5,8 @@ from datetime import datetime
class TimeDisplay:
def __init__(self, characterDisplay, topRow):
self.characterDisplay = characterDisplay
def __init__(self, symbolDisplay, topRow):
self.symbolDisplay = symbolDisplay
self.topRow = topRow
self.currentHour = [-1, -1]
self.currentMinute = [-1, -1]
@ -37,7 +37,7 @@ class TimeDisplay:
def showTimeDots(self):
if self.color != self.currentColor:
self.characterDisplay.displayTimeDots(
self.symbolDisplay.displayTimeDots(
x=self.timeDotsColumn,
y=self.topRow,
color=self.color
@ -53,7 +53,7 @@ class TimeDisplay:
self.showDigit(self.minuteStartColumn + 4, minute[1])
def showDigit(self, x, digit):
self.characterDisplay.displayDigit(
self.symbolDisplay.displayDigit(
x=x,
y=self.topRow,
digit=digit,
@ -61,7 +61,7 @@ class TimeDisplay:
)
def hideDigit(self, x):
self.characterDisplay.clearDigit(
self.symbolDisplay.clearDigit(
x=x,
y=self.topRow
)

View File

@ -2,8 +2,8 @@ import chutney.colors as colors
class WeatherDisplay:
def __init__(self, characterDisplay, topRow):
self.characterDisplay = characterDisplay
def __init__(self, symbolDisplay, topRow):
self.symbolDisplay = symbolDisplay
self.topRow = topRow
self.twoDigitStartColumn = 5
self.oneDigitStartColumn = 7
@ -17,7 +17,7 @@ class WeatherDisplay:
if temperature != self.currentTemperature:
self.currentTemperature = temperature
self.characterDisplay.clearRow(self.topRow)
self.symbolDisplay.clearRow(self.topRow)
if self.isTemperatureValid(temperature):
self.showTemperature(list(temperature))
@ -38,13 +38,13 @@ class WeatherDisplay:
for c in temperature:
if c == '-':
self.characterDisplay.displayNegative(
self.symbolDisplay.displayNegative(
x=start-3,
y=self.topRow,
color=self.color
)
else:
self.characterDisplay.displayDigit(
self.symbolDisplay.displayDigit(
x=start,
y=self.topRow,
digit=c,
@ -52,7 +52,7 @@ class WeatherDisplay:
)
start = start + self.digitWidth
self.characterDisplay.displayDegree(
self.symbolDisplay.displayDegree(
x=start,
y=self.topRow,
color=self.color