Skip to content

Commit 52106c2

Browse files
committed
Added EK79686 Support
1 parent 20f292d commit 52106c2

File tree

6 files changed

+176
-0
lines changed

6 files changed

+176
-0
lines changed

adafruit_epd/ek79686.py

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# SPDX-FileCopyrightText: 2018 Dean Miller for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
`adafruit_epd.EK79686` - Adafruit EK79686 - ePaper display driver
7+
====================================================================================
8+
CircuitPython driver for Adafruit EK79686 display breakouts
9+
* Author(s): Melissa LeBlanc-Williams
10+
"""
11+
12+
import time
13+
from micropython import const
14+
import adafruit_framebuf
15+
from adafruit_epd.epd import Adafruit_EPD
16+
17+
try:
18+
"Needed for type annotations"
19+
import typing # pylint: disable=unused-import
20+
from typing_extensions import Literal
21+
from busio import SPI
22+
from digitalio import DigitalInOut
23+
24+
except ImportError:
25+
pass
26+
27+
__version__ = "0.0.0+auto.0"
28+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
29+
30+
_EK79686_PANEL_SETTING = const(0x00)
31+
_EK79686_POWER_SETTING = const(0x01)
32+
_EK79686_POWER_OFF = const(0x02)
33+
_EK79686_POWER_OFF_SEQUENCE = const(0x03)
34+
_EK79686_POWER_ON = const(0x04)
35+
_EK79686_POWER_ON_MEASURE = const(0x05)
36+
_EK79686_BOOSTER_SOFT_START = const(0x06)
37+
_EK79686_DEEP_SLEEP = const(0x07)
38+
_EK79686_DTM1 = const(0x10)
39+
_EK79686_DATA_STOP = const(0x11)
40+
_EK79686_DISPLAY_REFRESH = const(0x12)
41+
_EK79686_DTM2 = const(0x13)
42+
_EK79686_PDTM1 = const(0x14)
43+
_EK79686_PDTM2 = const(0x15)
44+
_EK79686_PDRF = const(0x16)
45+
_EK79686_LUT1 = const(0x20)
46+
_EK79686_LUTWW = const(0x21)
47+
_EK79686_LUTBW = const(0x22)
48+
_EK79686_LUTWB = const(0x23)
49+
_EK79686_LUTBB = const(0x24)
50+
_EK79686_PLL = const(0x30)
51+
_EK79686_CDI = const(0x50)
52+
_EK79686_RESOLUTION = const(0x61)
53+
_EK79686_VCM_DC_SETTING = const(0x82)
54+
55+
56+
class Adafruit_EK79686(Adafruit_EPD):
57+
"""driver class for Adafruit EK79686 ePaper display breakouts"""
58+
59+
# pylint: disable=too-many-arguments
60+
def __init__(
61+
self,
62+
width: int,
63+
height: int,
64+
spi: SPI,
65+
*,
66+
cs_pin: DigitalInOut,
67+
dc_pin: DigitalInOut,
68+
sramcs_pin: DigitalInOut,
69+
rst_pin: DigitalInOut,
70+
busy_pin: DigitalInOut
71+
) -> None:
72+
super().__init__(
73+
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
74+
)
75+
76+
self._buffer1_size = int(width * height / 8)
77+
self._buffer2_size = int(width * height / 8)
78+
79+
if sramcs_pin:
80+
self._buffer1 = self.sram.get_view(0)
81+
self._buffer2 = self.sram.get_view(self._buffer1_size)
82+
else:
83+
self._buffer1 = bytearray((width * height) // 8)
84+
self._buffer2 = bytearray((width * height) // 8)
85+
# since we have *two* framebuffers - one for red and one for black
86+
# we dont subclass but manage manually
87+
self._framebuf1 = adafruit_framebuf.FrameBuffer(
88+
self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
89+
)
90+
self._framebuf2 = adafruit_framebuf.FrameBuffer(
91+
self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB
92+
)
93+
self.set_black_buffer(0, True)
94+
self.set_color_buffer(1, False)
95+
self._single_byte_tx = False
96+
97+
def begin(self, reset: bool = True) -> None:
98+
"""Begin communication with the display and set basic settings"""
99+
if reset:
100+
self.hardware_reset()
101+
102+
self.power_down()
103+
104+
def busy_wait(self) -> None:
105+
"""Wait for display to be done with current task, either by polling the
106+
busy pin, or pausing"""
107+
if self._busy:
108+
while not self._busy.value:
109+
time.sleep(0.01)
110+
else:
111+
time.sleep(0.5)
112+
113+
def power_up(self) -> None:
114+
"""Power up the display in preparation for writing RAM and updating"""
115+
self.hardware_reset()
116+
time.sleep(0.2)
117+
118+
self.command(_EK79686_PANEL_SETTING, bytearray([0x0F])) # LUT from OTP 176x264
119+
self.command(0x4D, bytearray([0xAA])) # FITI cmd (???)
120+
self.command(0x87, bytearray([0x28]))
121+
self.command(0x84, bytearray([0x00]))
122+
self.command(0x83, bytearray([0x05]))
123+
self.command(0xA8, bytearray([0xDF]))
124+
self.command(0xA9, bytearray([0x05]))
125+
self.command(0xB1, bytearray([0xE8]))
126+
self.command(0xAB, bytearray([0xA1]))
127+
self.command(0xB9, bytearray([0x10]))
128+
self.command(0x88, bytearray([0x80]))
129+
self.command(0x90, bytearray([0x02]))
130+
self.command(0x86, bytearray([0x15]))
131+
self.command(0x91, bytearray([0x8D]))
132+
self.command(0xAA, bytearray([0x0F]))
133+
self.command(_EK79686_POWER_ON)
134+
self.busy_wait()
135+
136+
def power_down(self) -> None:
137+
"""Power down the display - required when not actively displaying!"""
138+
self.command(_EK79686_POWER_OFF, bytearray([0x17]))
139+
self.busy_wait()
140+
141+
if self._rst: # Only deep sleep if we can get out of it
142+
self.command(_EK79686_DEEP_SLEEP, bytearray([0xA5]))
143+
144+
def update(self) -> None:
145+
"""Update the display from internal memory"""
146+
self.command(_EK79686_DISPLAY_REFRESH)
147+
self.busy_wait()
148+
if not self._busy:
149+
time.sleep(16) # wait 16 seconds
150+
151+
def write_ram(self, index: Literal[0, 1]) -> int:
152+
"""Send the one byte command for starting the RAM write process. Returns
153+
the byte read at the same time over SPI. index is the RAM buffer, can be
154+
0 or 1 for tri-color displays."""
155+
if index == 0:
156+
return self.command(_EK79686_DTM1, end=False)
157+
if index == 1:
158+
return self.command(_EK79686_DTM2, end=False)
159+
raise RuntimeError("RAM index must be 0 or 1")
160+
161+
def set_ram_address(
162+
self, x: int, y: int
163+
) -> None: # pylint: disable=unused-argument, no-self-use
164+
"""Set the RAM address location, not used on this chipset but required by
165+
the superclass"""
166+
return # on this chip it does nothing

examples/epd_bitmap.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
1414
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
1515
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
16+
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
1617

1718

1819
# create the spi device and pins we will need
@@ -30,6 +31,7 @@
3031
# display = Adafruit_SSD1680(122, 250, # 2.13" HD Tri-color display
3132
# display = Adafruit_SSD1681(200, 200, # 1.54" HD Tri-color display
3233
# display = Adafruit_IL91874(176, 264, # 2.7" Tri-color display
34+
# display = Adafruit_EK79686(176, 264, # 2.7" Tri-color display
3335
# display = Adafruit_IL0373(152, 152, # 1.54" Tri-color display
3436
# display = Adafruit_UC8151D(128, 296, # 2.9" mono flexible display
3537
# display = Adafruit_IL0373(128, 296, # 2.9" Tri-color display

examples/epd_blinka.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
1919
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
2020
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
21+
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
2122

2223
# create the spi device and pins we will need
2324
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
@@ -38,6 +39,7 @@
3839
# display = Adafruit_SSD1681(200, 200, # 1.54" HD Tri-color display
3940
# display = Adafruit_SSD1675(122, 250, # 2.13" HD mono display
4041
# display = Adafruit_IL91874(176, 264, # 2.7" Tri-color display
42+
# display = Adafruit_EK79686(176, 264, # 2.7" Tri-color display
4143
# display = Adafruit_IL0373(152, 152, # 1.54" Tri-color display
4244
# display = Adafruit_UC8151D(128, 296, # 2.9" mono flexible display
4345
# display = Adafruit_IL0373(128, 296, # 2.9" Tri-color display

examples/epd_pillow_demo.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
1919
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
2020
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
21+
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
2122

2223
# First define some color constants
2324
WHITE = (0xFF, 0xFF, 0xFF)
@@ -45,6 +46,7 @@
4546
# display = Adafruit_SSD1680(122, 250, # 2.13" HD Tri-color or mono display
4647
# display = Adafruit_SSD1681(200, 200, # 1.54" HD Tri-color display
4748
# display = Adafruit_IL91874(176, 264, # 2.7" Tri-color display
49+
# display = Adafruit_EK79686(176, 264, # 2.7" Tri-color display
4850
# display = Adafruit_IL0373(152, 152, # 1.54" Tri-color display
4951
# display = Adafruit_UC8151D(128, 296, # 2.9" mono flexible display
5052
# display = Adafruit_IL0373(128, 296, # 2.9" Tri-color display

examples/epd_pillow_image.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
2121
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
2222
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
23+
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
2324

2425

2526
# create the spi device and pins we will need
@@ -36,6 +37,7 @@
3637
# display = Adafruit_SSD1680(122, 250, # 2.13" HD Tri-color or mono display
3738
# display = Adafruit_SSD1681(200, 200, # 1.54" HD Tri-color display
3839
# display = Adafruit_IL91874(176, 264, # 2.7" Tri-color display
40+
# display = Adafruit_EK79686(176, 264, # 2.7" Tri-color display
3941
# display = Adafruit_IL0373(152, 152, # 1.54" Tri-color display
4042
# display = Adafruit_UC8151D(128, 296, # 2.9" mono flexible display
4143
# display = Adafruit_IL0373(128, 296, # 2.9" Tri-color display

examples/epd_simpletest.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
1414
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
1515
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
16+
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
1617

1718
# create the spi device and pins we will need
1819
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
@@ -29,6 +30,7 @@
2930
# display = Adafruit_SSD1680(122, 250, # 2.13" HD Tri-color display
3031
# display = Adafruit_SSD1681(200, 200, # 1.54" HD Tri-color display
3132
# display = Adafruit_IL91874(176, 264, # 2.7" Tri-color display
33+
# display = Adafruit_EK79686(176, 264, # 2.7" Tri-color display
3234
# display = Adafruit_IL0373(152, 152, # 1.54" Tri-color display
3335
# display = Adafruit_UC8151D(128, 296, # 2.9" mono flexible display
3436
# display = Adafruit_IL0373(128, 296, # 2.9" Tri-color display

0 commit comments

Comments
 (0)