Skip to content

Commit 83abd0a

Browse files
committed
lint & add new chip
1 parent c410494 commit 83abd0a

File tree

2 files changed

+180
-2
lines changed

2 files changed

+180
-2
lines changed

adafruit_epd/ssd1608.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def power_up(self):
110110
self.command(_SSD1608_SW_RESET)
111111
self.busy_wait()
112112
# driver output control
113-
self.command(_SSD1608_DRIVER_CONTROL, bytearray([self._width-1, (self._width-1) >> 8, 0x00]))
113+
self.command(_SSD1608_DRIVER_CONTROL,
114+
bytearray([self._width-1, (self._width-1) >> 8, 0x00]))
114115
# Set dummy line period
115116
self.command(_SSD1608_WRITE_DUMMY, bytearray([0x1B]))
116117
# Set gate line width
@@ -120,7 +121,8 @@ def power_up(self):
120121
# Set ram X start/end postion
121122
self.command(_SSD1608_SET_RAMXPOS, bytearray([0x00, self._height//8 - 1]))
122123
# Set ram Y start/end postion
123-
self.command(_SSD1608_SET_RAMYPOS, bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]))
124+
self.command(_SSD1608_SET_RAMYPOS,
125+
bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]))
124126
# Vcom Voltage
125127
self.command(_SSD1608_WRITE_VCOM, bytearray([0x70]))
126128
# LUT

adafruit_epd/ssd1675.py

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2018 Dean Miller for Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_epd.ssd1675` - Adafruit SSD1675 - ePaper display driver
24+
====================================================================================
25+
CircuitPython driver for Adafruit SSD1675 display breakouts
26+
* Author(s): Dean Miller, Ladyada
27+
"""
28+
29+
import time
30+
from micropython import const
31+
import adafruit_framebuf
32+
from adafruit_epd.epd import Adafruit_EPD
33+
34+
_SSD1675_DRIVER_CONTROL = const(0x01)
35+
_SSD1675_GATE_VOLTAGE = const(0x03)
36+
_SSD1675_SOURCE_VOLTAGE = const(0x04)
37+
_SSD1675_DEEP_SLEEP = const(0x10)
38+
_SSD1675_DATA_MODE = const(0x11)
39+
_SSD1675_SW_RESET = const(0x12)
40+
_SSD1675_HV_READY = const(0x14)
41+
_SSD1675_VCI_READY = const(0x15)
42+
_SSD1675_TEMP_WRITE = const(0x1A)
43+
_SSD1675_MASTER_ACTIVATE = const(0x20)
44+
_SSD1675_DISP_CTRL1 = const(0x21)
45+
_SSD1675_DISP_CTRL2 = const(0x22)
46+
_SSD1675_WRITE_RAM1 = const(0x24)
47+
_SSD1675_WRITE_RAM2 = const(0x26)
48+
_SSD1675_WRITE_VCOM = const(0x2C)
49+
_SSD1675_READ_OTP = const(0x2D)
50+
_SSD1675_WRITE_LUT = const(0x32)
51+
_SSD1675_WRITE_DUMMY = const(0x3A)
52+
_SSD1675_WRITE_GATELINE = const(0x3B)
53+
_SSD1675_WRITE_BORDER = const(0x3C)
54+
_SSD1675_SET_RAMXPOS = const(0x44)
55+
_SSD1675_SET_RAMYPOS = const(0x45)
56+
_SSD1675_SET_RAMXCOUNT = const(0x4E)
57+
_SSD1675_SET_RAMYCOUNT = const(0x4F)
58+
_SSD1675_SET_ANALOGBLOCK = const(0x74)
59+
_SSD1675_SET_DIGITALBLOCK = const(0x7E)
60+
_LUT_DATA = b'\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x02\t\t\x00\x00\x02\x03\x03\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa820\n' # pylint: disable=line-too-long
61+
62+
class Adafruit_SSD1675(Adafruit_EPD):
63+
"""driver class for Adafruit SSD1675 ePaper display breakouts"""
64+
# pylint: disable=too-many-arguments
65+
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin):
66+
super(Adafruit_SSD1675, self).__init__(width, height, spi, cs_pin, dc_pin,
67+
sramcs_pin, rst_pin, busy_pin)
68+
if width % 8 != 0:
69+
width += (8 - width % 8)
70+
71+
self._buffer1_size = int(width * height / 8)
72+
self._buffer2_size = self._buffer1_size
73+
74+
if sramcs_pin:
75+
self._buffer1 = self.sram.get_view(0)
76+
self._buffer2 = self.sram.get_view(self._buffer1_size)
77+
else:
78+
self._buffer1 = bytearray(self._buffer1_size)
79+
self._buffer2 = bytearray(self._buffer2_size)
80+
# since we have *two* framebuffers - one for red and one for black
81+
# we dont subclass but manage manually
82+
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height,
83+
buf_format=adafruit_framebuf.MHMSB)
84+
self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height,
85+
buf_format=adafruit_framebuf.MHMSB)
86+
self.set_black_buffer(0, True)
87+
self.set_color_buffer(0, True)
88+
# pylint: enable=too-many-arguments
89+
90+
def begin(self, reset=True):
91+
"""Begin communication with the display and set basic settings"""
92+
if reset:
93+
self.hardware_reset()
94+
self.power_down()
95+
96+
def busy_wait(self):
97+
"""Wait for display to be done with current task, either by polling the
98+
busy pin, or pausing"""
99+
if self._busy:
100+
while self._busy.value:
101+
time.sleep(0.01)
102+
else:
103+
time.sleep(0.5)
104+
105+
def power_up(self):
106+
"""Power up the display in preparation for writing RAM and updating"""
107+
self.hardware_reset()
108+
time.sleep(0.1)
109+
self.busy_wait()
110+
111+
self.command(_SSD1675_SW_RESET)
112+
self.busy_wait()
113+
114+
# set analog block control
115+
self.command(_SSD1675_SET_ANALOGBLOCK, bytearray([0x54]))
116+
# set digital block control
117+
self.command(_SSD1675_SET_DIGITALBLOCK, bytearray([0x3B]))
118+
119+
# driver output control
120+
self.command(_SSD1675_DRIVER_CONTROL,
121+
bytearray([0xFA, 0x01, 0x00]))
122+
# Data entry sequence
123+
self.command(_SSD1675_DATA_MODE, bytearray([0x03]))
124+
# Set ram X start/end postion
125+
self.command(_SSD1675_SET_RAMXPOS, bytearray([0x00, 0x0F]))
126+
# Set ram Y start/end postion
127+
self.command(_SSD1675_SET_RAMYPOS, bytearray([0, 0, 0xF9, 0]))
128+
# Border color
129+
self.command(_SSD1675_WRITE_BORDER, bytearray([0x03]))
130+
# Vcom Voltage
131+
self.command(_SSD1675_WRITE_VCOM, bytearray([0x70]))
132+
# Set gate voltage
133+
self.command(_SSD1675_GATE_VOLTAGE, _LUT_DATA[70:71])
134+
# Set gate voltage
135+
self.command(_SSD1675_SOURCE_VOLTAGE, _LUT_DATA[71:74])
136+
# Set dummy line period
137+
self.command(_SSD1675_WRITE_DUMMY, _LUT_DATA[74:75])
138+
# Set gate line width
139+
self.command(_SSD1675_WRITE_GATELINE, _LUT_DATA[75:76])
140+
# LUT
141+
self.command(_SSD1675_WRITE_LUT, _LUT_DATA[0:70])
142+
143+
self.command(_SSD1675_SET_RAMXCOUNT, bytearray([0]))
144+
# Set RAM Y address counter
145+
self.command(_SSD1675_SET_RAMYCOUNT, bytearray([0xF9, 0]))
146+
147+
self.busy_wait()
148+
149+
def power_down(self):
150+
"""Power down the display - required when not actively displaying!"""
151+
self.command(_SSD1675_DEEP_SLEEP, bytearray([0x01]))
152+
time.sleep(0.1)
153+
154+
def update(self):
155+
"""Update the display from internal memory"""
156+
self.command(_SSD1675_DISP_CTRL2, bytearray([0xC7]))
157+
self.command(_SSD1675_MASTER_ACTIVATE)
158+
self.busy_wait()
159+
if not self._busy:
160+
time.sleep(3) # wait 3 seconds
161+
162+
def write_ram(self, index):
163+
"""Send the one byte command for starting the RAM write process. Returns
164+
the byte read at the same time over SPI. index is the RAM buffer, can be
165+
0 or 1 for tri-color displays."""
166+
if index == 0:
167+
return self.command(_SSD1675_WRITE_RAM1, end=False)
168+
if index == 1:
169+
return self.command(_SSD1675_WRITE_RAM2, end=False)
170+
raise RuntimeError("RAM index must be 0 or 1")
171+
172+
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
173+
"""Set the RAM address location, not used on this chipset but required by
174+
the superclass"""
175+
self.command(_SSD1675_SET_RAMXCOUNT, bytearray([x]))
176+
self.command(_SSD1675_SET_RAMYCOUNT, bytearray([y, y>>8]))

0 commit comments

Comments
 (0)