Added exit function
This commit is contained in:
parent
ccf7f710ec
commit
b5a3c17b57
1 changed files with 11 additions and 4 deletions
15
raspicar.py
15
raspicar.py
|
@ -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!")
|
||||
|
|
Loading…
Reference in a new issue