forked from rt-net/RaspberryPiMouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep3.py
More file actions
42 lines (39 loc) · 1.57 KB
/
Copy pathstep3.py
File metadata and controls
42 lines (39 loc) · 1.57 KB
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
38
39
40
41
#!/usr/bin/python
import time
state0=state1=state2=0
while 1 :
with open("/dev/rtswitch0","r") as f:
if f.readline() == "0\n" :
time.sleep(0.1)
while 1 :
with open("/dev/rtswitch0","r") as f:
if f.readline() != "0\n" :
break
time.sleep(0.1)
state0 = (state0 + 1 ) & 1
with open("/dev/rtled3","w") as f:
f.write(str(state0))
with open("/dev/rtswitch1","r") as f:
if f.readline() == "0\n" :
time.sleep(0.1)
while 1 :
with open("/dev/rtswitch1","r") as f:
if f.readline() != "0\n" :
break
time.sleep(0.1)
state1 = (state1 + 1 ) & 1
with open("/dev/rtled2","w") as f:
f.write(str(state1))
with open("/dev/rtled1","w") as f:
f.write(str(state1))
with open("/dev/rtswitch2","r") as f:
if f.readline() == "0\n" :
time.sleep(0.1)
while 1 :
with open("/dev/rtswitch2","r") as f:
if f.readline() != "0\n" :
break
time.sleep(0.1)
state2 = (state2 + 1 ) & 1
with open("/dev/rtled0","w") as f:
f.write(str(state2))