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