import sys from character_display import CharacterDisplay from signal import signal, SIGTERM from time import sleep from time_display import TimeDisplay 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) character_display = CharacterDisplay(unicorn) timeDisplay = TimeDisplay(character_display, lineTop=15) while True: timeDisplay.showTime() sleep(1) if __name__ == '__main__': main()