Skip to content

Commit 55668d0

Browse files
committed
added ssd1680z 2.13 eink bonnet
1 parent c4d3141 commit 55668d0

File tree

1 file changed

+208
-0
lines changed

1 file changed

+208
-0
lines changed

adafruit_epd/ssd1680z.py

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# SPDX-License-Identifier: MIT
2+
3+
"""
4+
`adafruit_epd.ssd1680z` - Adafruit SSD1680Z - ePaper display driver
5+
====================================================================================
6+
CircuitPython driver for Adafruit SSD1680Z display breakouts
7+
* Author(s): Mikey Sklar Melissa LeBlanc-Williams
8+
"""
9+
10+
import time
11+
from micropython import const
12+
import adafruit_framebuf
13+
from adafruit_epd.epd import Adafruit_EPD
14+
15+
try:
16+
"""Needed for type annotations"""
17+
import typing # pylint: disable=unused-import
18+
from typing_extensions import Literal
19+
from busio import SPI
20+
from digitalio import DigitalInOut
21+
22+
except ImportError:
23+
pass
24+
25+
__version__ = "2.12.3"
26+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
27+
28+
_SSD1680Z_DRIVER_CONTROL = const(0x01)
29+
_SSD1680Z_GATE_VOLTAGE = const(0x03)
30+
_SSD1680Z_SOURCE_VOLTAGE = const(0x04)
31+
_SSD1680Z_INIT_SETTING = const(0x08)
32+
_SSD1680Z_INIT_WRITE_REG = const(0x09)
33+
_SSD1680Z_INIT_READ_REG = const(0x0A)
34+
_SSD1680Z_BOOSTER_SOFT_START = const(0x0C)
35+
_SSD1680Z_DEEP_SLEEP = const(0x10)
36+
_SSD1680Z_DATA_MODE = const(0x11)
37+
_SSD1680Z_SW_RESET = const(0x12)
38+
_SSD1680Z_HV_DETECT = const(0x14)
39+
_SSD1680Z_VCI_DETECT = const(0x15)
40+
_SSD1680Z_TEMP_CONTROL = const(0x18)
41+
_SSD1680Z_TEMP_WRITE = const(0x1A)
42+
_SSD1680Z_TEMP_READ = const(0x1B)
43+
_SSD1680Z_EXTTEMP_WRITE = const(0x1C)
44+
_SSD1680Z_MASTER_ACTIVATE = const(0x20)
45+
_SSD1680Z_DISP_CTRL1 = const(0x21)
46+
_SSD1680Z_DISP_CTRL2 = const(0x22)
47+
_SSD1680Z_WRITE_BWRAM = const(0x24)
48+
_SSD1680Z_WRITE_REDRAM = const(0x26)
49+
_SSD1680Z_READ_RAM = const(0x27)
50+
_SSD1680Z_VCOM_SENSE = const(0x28)
51+
_SSD1680Z_VCOM_DURATION = const(0x29)
52+
_SSD1680Z_WRITE_VCOM_OTP = const(0x2A)
53+
_SSD1680Z_WRITE_VCOM_CTRL = const(0x2B)
54+
_SSD1680Z_WRITE_VCOM_REG = const(0x2C)
55+
_SSD1680Z_READ_OTP = const(0x2D)
56+
_SSD1680Z_READ_USERID = const(0x2E)
57+
_SSD1680Z_READ_STATUS = const(0x2F)
58+
_SSD1680Z_WRITE_WS_OTP = const(0x30)
59+
_SSD1680Z_LOAD_WS_OTP = const(0x31)
60+
_SSD1680Z_WRITE_LUT = const(0x32)
61+
_SSD1680Z_CRC_CALC = const(0x34)
62+
_SSD1680Z_CRC_READ = const(0x35)
63+
_SSD1680Z_PROG_OTP = const(0x36)
64+
_SSD1680Z_WRITE_DISPLAY_OPT = const(0x37)
65+
_SSD1680Z_WRITE_USERID = const(0x38)
66+
_SSD1680Z_OTP_PROGMODE = const(0x39)
67+
_SSD1680Z_WRITE_BORDER = const(0x3C)
68+
_SSD1680Z_END_OPTION = const(0x3F)
69+
_SSD1680Z_SET_RAMXPOS = const(0x44)
70+
_SSD1680Z_SET_RAMYPOS = const(0x45)
71+
_SSD1680Z_AUTOWRITE_RED = const(0x46)
72+
_SSD1680Z_AUTOWRITE_BW = const(0x47)
73+
_SSD1680Z_SET_RAMXCOUNT = const(0x4E)
74+
_SSD1680Z_SET_RAMYCOUNT = const(0x4F)
75+
_SSD1680Z_NOP = const(0xFF)
76+
77+
78+
class Adafruit_SSD1680Z(Adafruit_EPD):
79+
"""driver class for Adafruit SSD1680Z ePaper display breakouts"""
80+
81+
# pylint: disable=too-many-arguments
82+
def __init__(
83+
self,
84+
width: int,
85+
height: int,
86+
spi: SPI,
87+
*,
88+
cs_pin: DigitalInOut,
89+
dc_pin: DigitalInOut,
90+
sramcs_pin: DigitalInOut,
91+
rst_pin: DigitalInOut,
92+
busy_pin: DigitalInOut
93+
) -> None:
94+
super().__init__(
95+
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
96+
)
97+
98+
stride = width
99+
if stride % 8 != 0:
100+
stride += 8 - stride % 8
101+
102+
self._buffer1_size = int(stride * height / 8)
103+
self._buffer2_size = self._buffer1_size
104+
105+
if sramcs_pin:
106+
self._buffer1 = self.sram.get_view(0)
107+
self._buffer2 = self.sram.get_view(self._buffer1_size)
108+
else:
109+
self._buffer1 = bytearray(self._buffer1_size)
110+
self._buffer2 = bytearray(self._buffer2_size)
111+
112+
self._framebuf1 = adafruit_framebuf.FrameBuffer(
113+
self._buffer1,
114+
width,
115+
height,
116+
stride=stride,
117+
buf_format=adafruit_framebuf.MHMSB,
118+
)
119+
self._framebuf2 = adafruit_framebuf.FrameBuffer(
120+
self._buffer2,
121+
width,
122+
height,
123+
stride=stride,
124+
buf_format=adafruit_framebuf.MHMSB,
125+
)
126+
self.set_black_buffer(0, True)
127+
self.set_color_buffer(1, False)
128+
# pylint: enable=too-many-arguments
129+
130+
def begin(self, reset: bool = True) -> None:
131+
"""Begin communication with the display and set basic settings"""
132+
if reset:
133+
self.hardware_reset()
134+
self.power_down()
135+
136+
def busy_wait(self) -> None:
137+
"""Wait for display to be done with current task, either by polling the
138+
busy pin, or pausing"""
139+
if self._busy:
140+
while self._busy.value:
141+
time.sleep(0.01)
142+
else:
143+
time.sleep(0.5)
144+
145+
def power_up(self) -> None:
146+
"""Power up the display and set basic settings for SSD1680Z"""
147+
self.hardware_reset()
148+
self.busy_wait()
149+
150+
# Send a software reset command
151+
self.command(_SSD1680Z_SW_RESET)
152+
self.busy_wait()
153+
154+
# Driver output control for SSD1680Z
155+
self.command(
156+
_SSD1680Z_DRIVER_CONTROL,
157+
bytearray([self._height - 1, (self._height - 1) >> 8, 0x00]),
158+
)
159+
160+
# Set data entry mode
161+
self.command(_SSD1680Z_DATA_MODE, bytearray([0x03])) # Increment X and Y
162+
163+
# Set RAM X and Y start/end positions
164+
self.command(_SSD1680Z_SET_RAMXPOS, bytearray([0x00, (self._width // 8) - 1]))
165+
self.command(
166+
_SSD1680Z_SET_RAMYPOS,
167+
bytearray([0x00, 0x00, self._height - 1, (self._height - 1) >> 8]),
168+
)
169+
170+
# Set RAM X and Y count start
171+
self.command(_SSD1680Z_SET_RAMXCOUNT, bytearray([0x00]))
172+
self.command(_SSD1680Z_SET_RAMYCOUNT, bytearray([0x00, 0x00]))
173+
174+
# Set border waveform control
175+
self.command(_SSD1680Z_WRITE_BORDER, bytearray([0x80]))
176+
177+
self.busy_wait()
178+
179+
def power_down(self) -> None:
180+
"""Power down the display - required when not actively displaying!"""
181+
self.command(_SSD1680Z_DEEP_SLEEP, bytearray([0x01]))
182+
time.sleep(0.1)
183+
184+
def update(self) -> None:
185+
"""Activate display update for SSD1680Z"""
186+
self.command(_SSD1680Z_DISP_CTRL2, bytearray([0xF7])) # Full update
187+
self.command(_SSD1680Z_MASTER_ACTIVATE)
188+
self.busy_wait()
189+
if not self._busy:
190+
time.sleep(3) # Wait for update to complete
191+
192+
def write_ram(self, index: int) -> int:
193+
"""Write to RAM for SSD1680Z."""
194+
if index == 0:
195+
return self.command(_SSD1680Z_WRITE_BWRAM, end=False)
196+
if index == 1:
197+
return self.command(_SSD1680Z_WRITE_REDRAM, end=False)
198+
raise RuntimeError("RAM index must be 0 or 1")
199+
200+
def set_ram_address(
201+
self, x: int, y: int
202+
) -> None: # pylint: disable=unused-argument, no-self-use
203+
"""Set the RAM address location, not used on this chipset but required by
204+
the superclass"""
205+
# Set RAM X address counter
206+
self.command(_SSD1680Z_SET_RAMXCOUNT, bytearray([x + 1]))
207+
# Set RAM Y address counter
208+
self.command(_SSD1680Z_SET_RAMYCOUNT, bytearray([y, y >> 8]))

0 commit comments

Comments
 (0)