Skip to content

Commit afd64a9

Browse files
committed
subclass il0373 flex
1 parent 1e07941 commit afd64a9

File tree

2 files changed

+60
-26
lines changed

2 files changed

+60
-26
lines changed

adafruit_epd/il0373.py

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ def __init__(
7070
sramcs_pin: DigitalInOut,
7171
rst_pin: DigitalInOut,
7272
busy_pin: DigitalInOut,
73-
pid: int = 0, # Product ID, defaults to 0
7473
) -> None:
7574
super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
76-
self.pid = pid
7775

7876
self._buffer1_size = int(width * height / 8)
7977
self._buffer2_size = int(width * height / 8)
@@ -116,29 +114,20 @@ def power_up(self) -> None:
116114
self.hardware_reset()
117115
self.busy_wait()
118116

119-
if self.pid == 4243: # Adafruit 2.13" HD Monochrome eInk Display - 212x104
120-
self.command(_IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17]))
121-
self.command(_IL0373_POWER_ON)
122-
self.busy_wait()
123-
time.sleep(0.2)
124-
self.command(_IL0373_PANEL_SETTING, bytearray([0x1F, 0x0D]))
125-
self.command(_IL0373_CDI, bytearray([0x97]))
126-
else:
127-
# Default IL0373 init sequence
128-
self.command(_IL0373_POWER_SETTING, bytearray([0x03, 0x00, 0x2B, 0x2B, 0x09]))
129-
self.command(_IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17]))
130-
self.command(_IL0373_POWER_ON)
131-
self.busy_wait()
132-
time.sleep(0.2)
133-
self.command(_IL0373_PANEL_SETTING, bytearray([0xCF]))
134-
self.command(_IL0373_CDI, bytearray([0x37]))
135-
self.command(_IL0373_PLL, bytearray([0x29]))
136-
_b1 = self._width & 0xFF
137-
_b2 = (self._height >> 8) & 0xFF
138-
_b3 = self._height & 0xFF
139-
self.command(_IL0373_RESOLUTION, bytearray([_b1, _b2, _b3]))
140-
self.command(_IL0373_VCM_DC_SETTING, bytearray([0x0A]))
141-
time.sleep(0.05)
117+
self.command(_IL0373_POWER_SETTING, bytearray([0x03, 0x00, 0x2B, 0x2B, 0x09]))
118+
self.command(_IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17]))
119+
self.command(_IL0373_POWER_ON)
120+
self.busy_wait()
121+
time.sleep(0.2)
122+
self.command(_IL0373_PANEL_SETTING, bytearray([0xCF]))
123+
self.command(_IL0373_CDI, bytearray([0x37]))
124+
self.command(_IL0373_PLL, bytearray([0x29]))
125+
_b1 = self._width & 0xFF
126+
_b2 = (self._height >> 8) & 0xFF
127+
_b3 = self._height & 0xFF
128+
self.command(_IL0373_RESOLUTION, bytearray([_b1, _b2, _b3]))
129+
self.command(_IL0373_VCM_DC_SETTING, bytearray([0x0A]))
130+
time.sleep(0.05)
142131

143132
def power_down(self) -> None:
144133
"""Power down the display - required when not actively displaying!"""
@@ -168,3 +157,47 @@ def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
168157
"""Set the RAM address location, not used on this chipset but required by
169158
the superclass"""
170159
return # on this chip it does nothing
160+
161+
162+
class Adafruit_IL0373_213_Flex_Mono(Adafruit_IL0373):
163+
"""Driver for Adafruit 2.13" Flexible Monochrome 212x104"""
164+
165+
def __init__(
166+
self,
167+
width: int,
168+
height: int,
169+
spi: SPI,
170+
*,
171+
cs_pin: DigitalInOut,
172+
dc_pin: DigitalInOut,
173+
sramcs_pin: DigitalInOut,
174+
rst_pin: DigitalInOut,
175+
busy_pin: DigitalInOut,
176+
) -> None:
177+
super().__init__(
178+
width,
179+
height,
180+
spi,
181+
cs_pin=cs_pin,
182+
dc_pin=dc_pin,
183+
sramcs_pin=sramcs_pin,
184+
rst_pin=rst_pin,
185+
busy_pin=busy_pin,
186+
)
187+
188+
self.set_black_buffer(1, True)
189+
self.set_color_buffer(0, True)
190+
191+
def power_up(self) -> None:
192+
"""Power up the display in preparation for writing RAM and updating"""
193+
self.hardware_reset()
194+
self.busy_wait()
195+
196+
self.command(_IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17]))
197+
self.command(_IL0373_POWER_ON)
198+
199+
self.busy_wait()
200+
time.sleep(0.2)
201+
202+
self.command(_IL0373_PANEL_SETTING, bytearray([0x1F, 0x0D]))
203+
self.command(_IL0373_CDI, bytearray([0x97]))

examples/epd_simpletest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from adafruit_epd.ek79686 import Adafruit_EK79686
99
from adafruit_epd.epd import Adafruit_EPD
10-
from adafruit_epd.il0373 import Adafruit_IL0373
10+
from adafruit_epd.il0373 import Adafruit_IL0373, Adafruit_IL0373_213_Flex_Mono
1111
from adafruit_epd.il0398 import Adafruit_IL0398
1212
from adafruit_epd.il91874 import Adafruit_IL91874
1313
from adafruit_epd.jd79661 import Adafruit_JD79661
@@ -42,6 +42,7 @@
4242
# display = Adafruit_UC8179(648, 480, # 5.83" mono 648x480 display
4343
# display = Adafruit_UC8179(800, 480, # 7.5" mono 800x480 display
4444
# display = Adafruit_IL0373(128, 296, # 2.9" Tri-color display IL0373
45+
# display = Adafruit_IL0373_213_Flex_Mono(104, 212,# 2.13" mono flex display
4546
# display = Adafruit_SSD1680(128, 296, # 2.9" Tri-color display SSD1680
4647
# display = Adafruit_SSD1683(400, 300, # 4.2" 300x400 Tri-Color display
4748
# display = Adafruit_IL0398(400, 300, # 4.2" Tri-color display

0 commit comments

Comments
 (0)