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