-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.py
executable file
·80 lines (62 loc) · 2.21 KB
/
display.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
79
80
import datetime
import time
from ht1632cpy import HT1632C
import settings
from lightsensor import getLight
interface = HT1632C(2, 0)
interface.pwm(settings.read('settings', 'matrix', 'default_brightness'))
def dimmer():
dimmer_brightness = settings.read('settings', 'matrix', 'dimmer_brightness')
default_brightness = settings.read('settings', 'matrix', 'default_brightness')
if getLight() == False:
interface.pwm(dimmer_brightness)
else:
interface.pwm(default_brightness)
def displayText(x, text, text_color, bg_color, delay):
interface.clear()
if text_color == 'text_green':
c_text = interface.GREEN
elif text_color == 'text_red':
c_text = interface.RED
elif text_color == 'text_orange':
c_text = interface.ORANGE
elif text_color == 'text_black':
c_text = interface.BLACK
if bg_color == 'bg_green':
c_bg = interface.GREEN
elif bg_color == 'bg_red':
c_bg = interface.RED
elif bg_color == 'bg_orange':
c_bg = interface.ORANGE
elif bg_color == 'bg_black':
c_bg = interface.BLACK
if c_text == c_bg:
c_text = interface.GREEN
c_bg = interface.BLACK
if not text_color:
c_text = interface.GREEN
if not bg_color:
c_bg = interface.BLACK
interface.box(0, 0, interface.width(), interface.height(), c_bg)
for c in text:
interface.putchar(x, 4, c, interface.font6x8, c_text, c_bg)
x += interface.fontwidth(interface.font6x8)
interface.sendframe()
time.sleep(float(delay))
def clock():
now = datetime.datetime.now()
hour = str(now.hour).zfill(2)
minute = str(now.minute).zfill(2)
second = str(now.second).zfill(2)
interface.clear()
x = 5
dividers = 2
for section in (hour, minute, second):
for c in section:
interface.putchar(x, 4, c, interface.font7x8num, interface.GREEN, interface.BLACK)
x += interface.fontwidth(interface.font7x8num)
if dividers > 0:
interface.putchar(x, 4, ':', interface.font6x8, interface.GREEN, interface.BLACK)
x += interface.fontwidth(interface.font6x8) - 1
dividers -= 1
interface.sendframe()