Clean up code

This commit is contained in:
Mike Cifelli 2022-12-25 14:23:31 -05:00
parent eb535a4b84
commit e8ad3e3062
4 changed files with 17 additions and 10 deletions

View File

@ -9,7 +9,7 @@ sudo pip3 install unicornhathd
## Configuration ## Configuration
``` ```
TODO cp chutney.sample.cfg chutney.cfg
``` ```
## Installation ## Installation

View File

@ -1,4 +1,6 @@
BLACK = [0, 0, 0 ] BLACK = [0, 0, 0 ]
RED = [255, 0, 0 ] RED = [255, 0, 0 ]
PINK = [255, 0, 64 ] PINK = [255, 0, 64 ]
GREEN = [0, 255, 0 ]
BLUE = [0, 64, 128] BLUE = [0, 64, 128]

View File

@ -11,7 +11,7 @@ class TimeDisplay:
self.currentHour = [-1, -1] self.currentHour = [-1, -1]
self.currentMinute = [-1, -1] self.currentMinute = [-1, -1]
self.currentColor = colors.BLACK self.currentColor = colors.BLACK
self.color = colors.PINK self.color = colors.RED
self.hourStartColumn = -1 self.hourStartColumn = -1
self.timeDotsColumn = 7 self.timeDotsColumn = 7
self.minuteStartColumn = 9 self.minuteStartColumn = 9

View File

@ -1,13 +1,14 @@
import colors import colors
import requests
class WeatherDisplay: class WeatherDisplay:
def __init__(self, characterDisplay, topRow): def __init__(self, characterDisplay, topRow):
self.characterDisplay = characterDisplay self.characterDisplay = characterDisplay
self.topRow = topRow self.topRow = topRow
self.twoDigitStartColumn = 9
self.oneDigitStartColumn = 13
self.currentTemperature = [9, 9] self.currentTemperature = [9, 9]
self.color = colors.BLUE self.color = colors.GREEN
self.weatherFile = 'weather.txt' self.weatherFile = 'weather.txt'
def showWeather(self): def showWeather(self):
@ -33,8 +34,9 @@ class WeatherDisplay:
if temperature != self.currentTemperature: if temperature != self.currentTemperature:
self.characterDisplay.clearRow(self.topRow) self.characterDisplay.clearRow(self.topRow)
start = 13 if ( start = self.oneDigitStartColumn if (
len(temperature) == 2 and temperature[0] == '-') or len(temperature) == 1 else 9 self.isOneDigit(temperature)
) else self.twoDigitStartColumn
for c in temperature: for c in temperature:
if c == '-': if c == '-':
@ -46,3 +48,6 @@ class WeatherDisplay:
start = start + 4 start = start + 4
self.currentTemperature = temperature self.currentTemperature = temperature
def isOneDigit(self, temperature):
return (len(temperature) == 2 and temperature[0] == '-') or len(temperature) == 1