pre-commit

This commit is contained in:
Liz 2025-08-15 12:58:13 -04:00
parent 0be196a266
commit 7c669c774b

View file

@ -123,21 +123,24 @@ class Adafruit_SSD1683(Adafruit_EPD):
self._display_update_val = 0xF7 self._display_update_val = 0xF7
# Default initialization sequence (tri-color mode) # Default initialization sequence (tri-color mode)
self._default_init_code = bytes([ self._default_init_code = bytes(
_SSD1683_SW_RESET, 0, # Software reset [
0xFF, 50, # Wait for busy (50ms delay) _SSD1683_SW_RESET,
0, # Software reset
_SSD1683_WRITE_BORDER, 1, # Border waveform control 0xFF,
0x05, # Border color/waveform 50, # Wait for busy (50ms delay)
_SSD1683_WRITE_BORDER,
_SSD1683_TEMP_CONTROL, 1, # Temperature control 1, # Border waveform control
0x80, # Read temp 0x05, # Border color/waveform
_SSD1683_TEMP_CONTROL,
_SSD1683_DATA_MODE, 1, # Data entry mode 1, # Temperature control
0x03, # Y decrement, X increment 0x80, # Read temp
_SSD1683_DATA_MODE,
0xFE # End of initialization 1, # Data entry mode
]) 0x03, # Y decrement, X increment
0xFE, # End of initialization
]
)
def begin(self, reset: bool = True) -> None: def begin(self, reset: bool = True) -> None:
"""Begin communication with the display and set basic settings""" """Begin communication with the display and set basic settings"""
@ -162,7 +165,7 @@ class Adafruit_SSD1683(Adafruit_EPD):
# Use custom init code if provided, otherwise use default # Use custom init code if provided, otherwise use default
init_code = self._default_init_code init_code = self._default_init_code
if hasattr(self, '_epd_init_code') and self._epd_init_code is not None: if hasattr(self, "_epd_init_code") and self._epd_init_code is not None:
init_code = self._epd_init_code init_code = self._epd_init_code
# Send initialization sequence # Send initialization sequence
@ -175,7 +178,7 @@ class Adafruit_SSD1683(Adafruit_EPD):
self.set_ram_address(0, 0) self.set_ram_address(0, 0)
# Set LUT if we have one # Set LUT if we have one
if hasattr(self, '_epd_lut_code') and self._epd_lut_code: if hasattr(self, "_epd_lut_code") and self._epd_lut_code:
self._send_command_list(self._epd_lut_code) self._send_command_list(self._epd_lut_code)
# Set display size and driver output control # Set display size and driver output control
@ -229,10 +232,10 @@ class Adafruit_SSD1683(Adafruit_EPD):
self.command(_SSD1683_SET_RAMXPOS, bytearray([x1 & 0xFF, x2 & 0xFF])) self.command(_SSD1683_SET_RAMXPOS, bytearray([x1 & 0xFF, x2 & 0xFF]))
# Set ram Y start/end position # Set ram Y start/end position
self.command(_SSD1683_SET_RAMYPOS, bytearray([ self.command(
y1 & 0xFF, (y1 >> 8) & 0xFF, _SSD1683_SET_RAMYPOS,
y2 & 0xFF, (y2 >> 8) & 0xFF bytearray([y1 & 0xFF, (y1 >> 8) & 0xFF, y2 & 0xFF, (y2 >> 8) & 0xFF]),
])) )
def _send_command_list(self, init_sequence: bytes) -> None: def _send_command_list(self, init_sequence: bytes) -> None:
"""Send a sequence of commands from an initialization list""" """Send a sequence of commands from an initialization list"""
@ -248,14 +251,12 @@ class Adafruit_SSD1683(Adafruit_EPD):
delay_ms = init_sequence[i] delay_ms = init_sequence[i]
i += 1 i += 1
time.sleep(delay_ms / 1000.0) time.sleep(delay_ms / 1000.0)
else: elif i < len(init_sequence):
# Regular command num_args = init_sequence[i]
if i < len(init_sequence): i += 1
num_args = init_sequence[i] if num_args > 0 and (i + num_args) <= len(init_sequence):
i += 1 args = init_sequence[i : i + num_args]
if num_args > 0 and (i + num_args) <= len(init_sequence): self.command(cmd, bytearray(args))
args = init_sequence[i:i + num_args] i += num_args
self.command(cmd, bytearray(args)) else:
i += num_args self.command(cmd)
else:
self.command(cmd)