-
Notifications
You must be signed in to change notification settings - Fork 0
/
feathereminDisplay.py
executable file
·86 lines (64 loc) · 2.7 KB
/
feathereminDisplay.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
81
82
83
84
85
86
# SPDX-FileCopyrightText: 2023 dr cran's 3-D house of tofu
#
# SPDX-License-Identifier: Unlicense
"""
Display object for
Adafruit FeatherWing OLED - 128x64 OLED Add-on For Feather - STEMMA QT / Qwiic
AdafruitProduct ID: 4650
and using the Adafruit CircuitPython DisplayIO SH1107 module.
Adapted from code by: Mark Roberts (mdroberts1243) from Adafruit code
"""
import board
import displayio
import terminalio
# original comment (what does it mean?):
# can try import bitmap_label below for alternative
from adafruit_display_text import label
from adafruit_display_text.scrolling_label import ScrollingLabel
import adafruit_displayio_sh1107
class FeathereminDisplay:
# SH1107 is vertically oriented 64x128
WIDTH = 128
HEIGHT = 64
BORDER = 2
LINE_HEIGHT = 12
splash_ = None
text_area_1_ = None
text_area_2_ = None
text_area_3_ = None
def __init__(self) -> None:
displayio.release_displays()
# oled_reset = board.D9
i2c = board.I2C() # on the Feather 2040, this is both SCA/SCL and STEMMA
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
display = adafruit_displayio_sh1107.SH1107(
display_bus, width=self.WIDTH, height=self.HEIGHT, rotation=0
)
# Make the display context
self.splash_ = displayio.Group()
display.show(self.splash_)
self.text_area_1_ = label.Label(terminalio.FONT, text="",
scale=1, color=0xFFFFFF, x=self.BORDER, y=self.LINE_HEIGHT)
self.splash_.append(self.text_area_1_)
self.text_area_2_ = label.Label(terminalio.FONT, text="",
scale=1, color=0xFFFFFF, x=self.BORDER, y=2*self.LINE_HEIGHT)
self.splash_.append(self.text_area_2_)
self.text_area_3_ = label.Label(terminalio.FONT, text="",
scale=1, color=0xFFFFFF, x=self.BORDER, y=3*self.LINE_HEIGHT)
self.splash_.append(self.text_area_3_)
## for this sort of thing to work we would need to expose an update() method?
#
# text = "Hello world CircuitPython scrolling label"
# my_scrolling_label = ScrollingLabel(
# terminalio.FONT, text=text, max_characters=20, animate_time=0.3
# )
# my_scrolling_label.x = 10
# my_scrolling_label.y = 10
# self.splash_.append(my_scrolling_label)
# end __init__
def setTextArea1(self, pText):
self.text_area_1_.text = pText
def setTextArea2(self, pText):
self.text_area_2_.text = pText
def setTextArea3(self, pText):
self.text_area_3_.text = pText