-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdisplay.py
60 lines (54 loc) · 1.81 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
import displayio
import terminalio
from adafruit_display_text import label
from adafruit_display_shapes.rect import Rect
class Display:
def __init__(self, macropad):
self.display = macropad.display
self.display.auto_refresh = False
def initialize(self):
self.group = displayio.Group()
for key_index in range(12):
x = key_index % 3
y = key_index // 3
self.group.append(
label.Label(terminalio.FONT,
text='',
color=0xFFFFFF,
anchored_position=((self.display.width - 1) * x / 2,
self.display.height - 1 - (3 - y) * 12),
anchor_point=(x / 2, 1.0)
)
)
self.group.append(Rect(0, 0, self.display.width, 12, fill=0xFFFFFF))
self.group.append(
label.Label(
terminalio.FONT,
text='',
color=0x000000,
anchored_position=(self.display.width//2, -2),
anchor_point=(0.5, 0.0)
)
)
self.display.show(self.group)
def sleep(self):
self.display.brightness = 0
self.display.show(displayio.Group())
self.display.refresh()
def resume(self):
self.display.brightness = 1
self.display.show(self.group)
self.display.refresh()
def setApp(self, app):
self.group[13].text = app.name
for i in range(12):
if i < len(app.macros):
self.group[i].text = app.macros[i][1]
else:
self.group[i].text = ''
self.display.refresh()
def setTitle(self, text):
self.group[13].text = text
for i in range(12):
self.group[i].text = ''
self.display.refresh()