-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcd-nc
39 lines (32 loc) · 1.01 KB
/
lcd-nc
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
#!/usr/bin/python
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
from NotificationCenter import NotificationCenter
from time import sleep
import socket
lcd = Adafruit_CharLCDPlate(1)
NC_METHODS = {
'status_date': [lcd.WHITE, 30],
'status_weather': [lcd.TEAL, 30],
'fun1': [lcd.RED, 5],
'status_torrents': [lcd.GREEN, 10],
'status_disk': [lcd.YELLOW, 10],
'random_quotes': [lcd.VIOLET, 10],
}
lcd.clear()
lcd.backlight(lcd.RED)
nc = NotificationCenter()
lcd.message("\n".join(nc.startup()))
sleep(5)
""" Try to keep the weather request from tying things up """
socket.setdefaulttimeout(2)
while True:
for NC_METHOD, (LCD_BK, NC_SLEEP, PWM_COLOR) in NC_METHODS.iteritems():
res = getattr(nc, nc.STATIC_MODE or NC_METHOD)()
if len(res):
lcd.clear()
lcd.message("\n".join(res))
if not nc.STATIC_MODE:
lcd.backlight(LCD_BK)
sleep(NC_SLEEP)
else:
sleep(3)