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
```
TODO
cp chutney.sample.cfg chutney.cfg
```
## Installation

View File

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

View File

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

View File

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