Skip to content

Commit 7c669c7

Browse files
committed
pre-commit
1 parent 0be196a commit 7c669c7

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

adafruit_epd/ssd1683.py

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,32 @@ def __init__(
115115
)
116116
self.set_black_buffer(0, True)
117117
self.set_color_buffer(1, False)
118-
118+
119119
# Set single byte transactions flag
120120
self._single_byte_tx = True
121-
121+
122122
# Set the display update value
123123
self._display_update_val = 0xF7
124-
124+
125125
# Default initialization sequence (tri-color mode)
126-
self._default_init_code = bytes([
127-
_SSD1683_SW_RESET, 0, # Software reset
128-
0xFF, 50, # Wait for busy (50ms delay)
129-
130-
_SSD1683_WRITE_BORDER, 1, # Border waveform control
131-
0x05, # Border color/waveform
132-
133-
_SSD1683_TEMP_CONTROL, 1, # Temperature control
134-
0x80, # Read temp
135-
136-
_SSD1683_DATA_MODE, 1, # Data entry mode
137-
0x03, # Y decrement, X increment
138-
139-
0xFE # End of initialization
140-
])
126+
self._default_init_code = bytes(
127+
[
128+
_SSD1683_SW_RESET,
129+
0, # Software reset
130+
0xFF,
131+
50, # Wait for busy (50ms delay)
132+
_SSD1683_WRITE_BORDER,
133+
1, # Border waveform control
134+
0x05, # Border color/waveform
135+
_SSD1683_TEMP_CONTROL,
136+
1, # Temperature control
137+
0x80, # Read temp
138+
_SSD1683_DATA_MODE,
139+
1, # Data entry mode
140+
0x03, # Y decrement, X increment
141+
0xFE, # End of initialization
142+
]
143+
)
141144

142145
def begin(self, reset: bool = True) -> None:
143146
"""Begin communication with the display and set basic settings"""
@@ -162,20 +165,20 @@ def power_up(self) -> None:
162165

163166
# Use custom init code if provided, otherwise use default
164167
init_code = self._default_init_code
165-
if hasattr(self, '_epd_init_code') and self._epd_init_code is not None:
168+
if hasattr(self, "_epd_init_code") and self._epd_init_code is not None:
166169
init_code = self._epd_init_code
167-
170+
168171
# Send initialization sequence
169172
self._send_command_list(init_code)
170173

171174
# Set RAM window
172175
self.set_ram_window(0, 0, (self._width // 8) - 1, self._height - 1)
173-
176+
174177
# Set RAM address to start position
175178
self.set_ram_address(0, 0)
176179

177180
# Set LUT if we have one
178-
if hasattr(self, '_epd_lut_code') and self._epd_lut_code:
181+
if hasattr(self, "_epd_lut_code") and self._epd_lut_code:
179182
self._send_command_list(self._epd_lut_code)
180183

181184
# Set display size and driver output control
@@ -201,7 +204,7 @@ def update(self) -> None:
201204
self.command(_SSD1683_DISP_CTRL2, bytearray([self._display_update_val]))
202205
self.command(_SSD1683_MASTER_ACTIVATE)
203206
self.busy_wait()
204-
207+
205208
if not self._busy:
206209
time.sleep(1) # wait 1 second
207210

@@ -219,43 +222,41 @@ def set_ram_address(self, x: int, y: int) -> None:
219222
"""Set the RAM address location"""
220223
# set RAM x address count
221224
self.command(_SSD1683_SET_RAMXCOUNT, bytearray([x & 0xFF]))
222-
225+
223226
# set RAM y address count
224227
self.command(_SSD1683_SET_RAMYCOUNT, bytearray([y & 0xFF, (y >> 8) & 0xFF]))
225228

226229
def set_ram_window(self, x1: int, y1: int, x2: int, y2: int) -> None:
227230
"""Set the RAM window for partial updates"""
228231
# Set ram X start/end position
229232
self.command(_SSD1683_SET_RAMXPOS, bytearray([x1 & 0xFF, x2 & 0xFF]))
230-
233+
231234
# Set ram Y start/end position
232-
self.command(_SSD1683_SET_RAMYPOS, bytearray([
233-
y1 & 0xFF, (y1 >> 8) & 0xFF,
234-
y2 & 0xFF, (y2 >> 8) & 0xFF
235-
]))
235+
self.command(
236+
_SSD1683_SET_RAMYPOS,
237+
bytearray([y1 & 0xFF, (y1 >> 8) & 0xFF, y2 & 0xFF, (y2 >> 8) & 0xFF]),
238+
)
236239

237240
def _send_command_list(self, init_sequence: bytes) -> None:
238241
"""Send a sequence of commands from an initialization list"""
239242
i = 0
240243
while i < len(init_sequence):
241244
cmd = init_sequence[i]
242245
i += 1
243-
246+
244247
if cmd == 0xFE: # End marker
245248
break
246249
elif cmd == 0xFF: # Delay marker
247250
if i < len(init_sequence):
248251
delay_ms = init_sequence[i]
249252
i += 1
250253
time.sleep(delay_ms / 1000.0)
251-
else:
252-
# Regular command
253-
if i < len(init_sequence):
254-
num_args = init_sequence[i]
255-
i += 1
256-
if num_args > 0 and (i + num_args) <= len(init_sequence):
257-
args = init_sequence[i:i + num_args]
258-
self.command(cmd, bytearray(args))
259-
i += num_args
260-
else:
261-
self.command(cmd)
254+
elif i < len(init_sequence):
255+
num_args = init_sequence[i]
256+
i += 1
257+
if num_args > 0 and (i + num_args) <= len(init_sequence):
258+
args = init_sequence[i : i + num_args]
259+
self.command(cmd, bytearray(args))
260+
i += num_args
261+
else:
262+
self.command(cmd)

0 commit comments

Comments
 (0)