-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·37 lines (28 loc) · 839 Bytes
/
main.py
File metadata and controls
executable file
·37 lines (28 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import RPi.GPIO as GPIO
from driver import main
from time import sleep
from lcd_controller import write_lcd
TouchPin = 15
GPIO.setmode(GPIO.BCM)
GPIO.setup(TouchPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
touched = False
def loop():
global touched
while True:
if GPIO.input(TouchPin) == GPIO.LOW:
touched = False
else:
print("Touched")
write_lcd("take_pic")
touched = True
result = main()
write_lcd(result["status"])
sleep(2)
def destroy():
GPIO.cleanup() # Release resource
if __name__ == '__main__': # Program start from here
try:
loop()
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
destroy()