pre-commit

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

View file

@ -115,29 +115,32 @@ class Adafruit_SSD1683(Adafruit_EPD):
) )
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(1, False) self.set_color_buffer(1, False)
# Set single byte transactions flag # Set single byte transactions flag
self._single_byte_tx = True self._single_byte_tx = True
# Set the display update value # Set the display update value
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,20 +165,20 @@ 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
self._send_command_list(init_code) self._send_command_list(init_code)
# Set RAM window # Set RAM window
self.set_ram_window(0, 0, (self._width // 8) - 1, self._height - 1) self.set_ram_window(0, 0, (self._width // 8) - 1, self._height - 1)
# Set RAM address to start position # Set RAM address to start position
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
@ -201,7 +204,7 @@ class Adafruit_SSD1683(Adafruit_EPD):
self.command(_SSD1683_DISP_CTRL2, bytearray([self._display_update_val])) self.command(_SSD1683_DISP_CTRL2, bytearray([self._display_update_val]))
self.command(_SSD1683_MASTER_ACTIVATE) self.command(_SSD1683_MASTER_ACTIVATE)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(1) # wait 1 second time.sleep(1) # wait 1 second
@ -219,7 +222,7 @@ class Adafruit_SSD1683(Adafruit_EPD):
"""Set the RAM address location""" """Set the RAM address location"""
# set RAM x address count # set RAM x address count
self.command(_SSD1683_SET_RAMXCOUNT, bytearray([x & 0xFF])) self.command(_SSD1683_SET_RAMXCOUNT, bytearray([x & 0xFF]))
# set RAM y address count # set RAM y address count
self.command(_SSD1683_SET_RAMYCOUNT, bytearray([y & 0xFF, (y >> 8) & 0xFF])) self.command(_SSD1683_SET_RAMYCOUNT, bytearray([y & 0xFF, (y >> 8) & 0xFF]))
@ -227,12 +230,12 @@ class Adafruit_SSD1683(Adafruit_EPD):
"""Set the RAM window for partial updates""" """Set the RAM window for partial updates"""
# Set ram X start/end position # Set ram X start/end position
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"""
@ -240,7 +243,7 @@ class Adafruit_SSD1683(Adafruit_EPD):
while i < len(init_sequence): while i < len(init_sequence):
cmd = init_sequence[i] cmd = init_sequence[i]
i += 1 i += 1
if cmd == 0xFE: # End marker if cmd == 0xFE: # End marker
break break
elif cmd == 0xFF: # Delay marker elif cmd == 0xFF: # Delay marker
@ -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)