-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCDModule.py
More file actions
64 lines (49 loc) · 1.46 KB
/
Copy pathLCDModule.py
File metadata and controls
64 lines (49 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from Components import *
from signal import pause, signal, SIGTERM, SIGHUP
from rpi_lcd import LCD as LCD_C
import time
import threading
class LCD(Component):
def __init__(self):
super().__init__('LCD')
self.lcd = LCD_C()
self.cond_var.set()
self.cond_var_support_lock.release()
self.last_message = ['', '']
self.line = 1
signal(SIGTERM, self.safe_exit)
signal(SIGHUP, self.safe_exit)
self.write_event = threading.Event()
def safe_exit(self, signum, frame):
self.lcd.clear()
exit(1)
def active_mode(self):
print('In Active Mode Buzzer')
while True:
self.write_event.wait()
try:
self.lcd.text(self.last_message[self.line - 1], self.line)
except KeyboardInterrupt as err:
print('Interrupt at ' + self.component_name + ' :\n' + err.args[0])
finally:
self.write_event.clear()
def signal(self, message):
self.line = message.meta_data['line']
self.last_message[self.line-1] = message.content
while self.write_event.is_set():
continue
self.write_event.set()
def listen(self):
return None
#lcd = LCD()
#m = Message('test', {'line': 1})
#lcd.signal(m)
#time.sleep(3)
#m.content = 'test2'
#m.meta_data['line'] = 2
#lcd.signal(m)
#time.sleep(3)
#m.content = 'test3'
#m.meta_data['line'] = 1
#lcd.signal(m)
#time.sleep(5)