forked from projectbuendia/server-status
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbutton_test.py
More file actions
35 lines (30 loc) · 712 Bytes
/
button_test.py
File metadata and controls
35 lines (30 loc) · 712 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
#!/usr/bin/env python
import mraa
import time
import subprocess
pressed = False
def press(args):
global pressed
if pressed:
return
time.sleep(.1)
if pin.read() == 1:
return
pressed = True
print('Hold for 10s to power off Edison ')
i = 0
while pin.read() == 0:
i += 1
time.sleep(.25)
if i == 50:
print 'Powering down..'
subprocess.call("python /home/root/gpio/lcd/report_lines.py 'Shutting down' 'Wait 2 minutes,' 'then flick the' 'power switch.' 'Au revoir!'", shell=True)
pressed = False
return
pressed = False
while True:
pin = mraa.Gpio(32)
pin.dir(mraa.DIR_IN)
pin.isr(mraa.EDGE_BOTH, press, press)
time.sleep(10800)
pin.isrExit()