-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreezermonitor.py
72 lines (51 loc) · 2.14 KB
/
freezermonitor.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
from IT8951.display import AutoEPDDisplay
from IT8951.constants import DisplayModes
from adafruit_display_text import label
import terminalio
import adafruit_imageload
import displayio
class FreezerMonitor():
def __init__(self, skip_splash=False):
self.display = AutoEPDDisplay(vcom=-1.39)
if not skip_splash:
self.load_splash_screen()
def load_splash_screen(self):
# manage group visibility (hide other elements)
self.display.static_ui_group.hidden = True
self.display.text_labels.hidden = True
# we must load the splash screen into the display buffer
# first we set an all-white background
self.display.epd.load_single_color(0xF) # TODO: uncomment
# then we load the sprites that go on top of that
buffer, palette = adafruit_imageload.load("assets/splash_screen_footer.bmp")
footer = displayio.TileGrid(buffer, pixel_shader=palette,
width = 1,
height = 1,
tile_width = buffer.width,
tile_height = buffer.height,
x=472,
y=1656)
self.display.splash_screen.append(footer)
buffer, palette = adafruit_imageload.load("assets/splash_screen_logo.bmp")
logo = displayio.TileGrid(buffer, pixel_shader=palette,
width = 1,
height = 1,
tile_width = buffer.width,
tile_height = buffer.height,
x=396,
y=412)
self.display.splash_screen.append(logo)
# and finally, actually update the physical display (will be done in draw_full)
self.display.draw_full()
def draw_text(self):
text = "HELLO WORLD"
font = terminalio.FONT
color = 0x0000FF
text_area = label.Label(font, text=text, color=color)
# Set the location
text_area.x = 100
text_area.y = 80
for group in text_area:
for letter in group:
self.display.draw_partial(letter)
self.display.splash_screen.append(text_area)