Added exit function

This commit is contained in:
dbroqua 2021-01-22 18:39:15 +01:00
parent ccf7f710ec
commit b5a3c17b57

View file

@ -1,4 +1,5 @@
import time
import atexit
import board
import RPi.GPIO as GPIO
@ -29,6 +30,14 @@ def handlePushButton(button):
display.print(" :"+str(CHANNEL)+"-")
# On exit
def handleExit():
print("GoodBye!")
display.print("--:--")
sleep(2)
display.fill(0)
# Init program
def init():
# Set display
@ -114,12 +123,10 @@ def main():
time.sleep(10)
atexit.register(handleExit)
if __name__ =='__main__':
try:
main()
except KeyboardInterrupt:
pass
display.print("--:--")
print("GoodBye!")