-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·84 lines (49 loc) · 1.42 KB
/
main.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/local/lib/python3.5
# Display a runtext with double-buffering.
from LEDController import LEDController
from LEDContext import LEDContext
import lirc
from multiprocessing import Process, Pipe, Event
import time
# IR input process
def get_input(sim=False):
if sim:
return [input()]
else:
return lirc.nextcode()
# print(c, 'here')
# continue
def main():
lirc.init("ledsign")
parent_pipe, child_pipe = Pipe()
remote_event = Event()
param_event = Event()
LED = LEDController()
context = LEDContext(param_event, remote_event, child_pipe)
p = Process(target=LED.process, args=(context,))
p.daemon = False
p.start()
# time.sleep(2)
print('starting IR')
while 1:
c = get_input(False)
if len(c) > 0:
cmd = c[0]
print(c[0], 'IR process')
#
if cmd == 'up' or cmd == 'down' or cmd == 'left' or cmd == 'right' or cmd == 'vol_up'or cmd == 'vol_down' or cmd == 'back':
print('setting p')
context.param_event.set()
else:
context.remote_event.set()
parent_pipe.send(cmd)
# if cmd == 'restart':
# break
# time.sleep(0.02)
p.join()
if __name__ == "__main__":
while 1:
try:
main()
except (KeyboardInterrupt, SystemExit):
lirc.deinit()