Clean up code
This commit is contained in:
parent
eb535a4b84
commit
e8ad3e3062
|
@ -9,7 +9,7 @@ sudo pip3 install unicornhathd
|
|||
|
||||
## Configuration
|
||||
```
|
||||
TODO
|
||||
cp chutney.sample.cfg chutney.cfg
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
|
10
colors.py
10
colors.py
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue