chutney/chutney.py

49 lines
983 B
Python

import sys
from character_display import CharacterDisplay
from signal import signal, SIGTERM
from time import sleep
from time_display import TimeDisplay
from weather_display import WeatherDisplay
try:
import unicornhathd as unicorn
unicorn.rotation(90)
except ImportError:
from unicorn_hat_sim import unicornhathd as unicorn
unicorn.rotation(180)
def cleanExit(unicorn):
def _exit_(signum, frame):
unicorn.off()
sys.exit(0)
return _exit_
def main():
signal(SIGTERM, cleanExit(unicorn))
unicorn.brightness(0.3)
characterDisplay = CharacterDisplay(unicorn)
timeDisplay = TimeDisplay(characterDisplay, topRow=15)
weatherDisplay = WeatherDisplay(characterDisplay, topRow=9, configFile='chutney.cfg')
x = 0
while True:
timeDisplay.showTime()
if (x == 0):
weatherDisplay.showWeather()
x = x + 1
x = x % 120
sleep(1)
if __name__ == '__main__':
main()