pre-commit
This commit is contained in:
parent
0be196a266
commit
7c669c774b
1 changed files with 42 additions and 41 deletions
|
|
@ -123,21 +123,24 @@ class Adafruit_SSD1683(Adafruit_EPD):
|
|||
self._display_update_val = 0xF7
|
||||
|
||||
# Default initialization sequence (tri-color mode)
|
||||
self._default_init_code = bytes([
|
||||
_SSD1683_SW_RESET, 0, # Software reset
|
||||
0xFF, 50, # Wait for busy (50ms delay)
|
||||
|
||||
_SSD1683_WRITE_BORDER, 1, # Border waveform control
|
||||
0x05, # Border color/waveform
|
||||
|
||||
_SSD1683_TEMP_CONTROL, 1, # Temperature control
|
||||
0x80, # Read temp
|
||||
|
||||
_SSD1683_DATA_MODE, 1, # Data entry mode
|
||||
0x03, # Y decrement, X increment
|
||||
|
||||
0xFE # End of initialization
|
||||
])
|
||||
self._default_init_code = bytes(
|
||||
[
|
||||
_SSD1683_SW_RESET,
|
||||
0, # Software reset
|
||||
0xFF,
|
||||
50, # Wait for busy (50ms delay)
|
||||
_SSD1683_WRITE_BORDER,
|
||||
1, # Border waveform control
|
||||
0x05, # Border color/waveform
|
||||
_SSD1683_TEMP_CONTROL,
|
||||
1, # Temperature control
|
||||
0x80, # Read temp
|
||||
_SSD1683_DATA_MODE,
|
||||
1, # Data entry mode
|
||||
0x03, # Y decrement, X increment
|
||||
0xFE, # End of initialization
|
||||
]
|
||||
)
|
||||
|
||||
def begin(self, reset: bool = True) -> None:
|
||||
"""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
|
||||
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
|
||||
|
||||
# Send initialization sequence
|
||||
|
|
@ -175,7 +178,7 @@ class Adafruit_SSD1683(Adafruit_EPD):
|
|||
self.set_ram_address(0, 0)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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]))
|
||||
|
||||
# Set ram Y start/end position
|
||||
self.command(_SSD1683_SET_RAMYPOS, bytearray([
|
||||
y1 & 0xFF, (y1 >> 8) & 0xFF,
|
||||
y2 & 0xFF, (y2 >> 8) & 0xFF
|
||||
]))
|
||||
self.command(
|
||||
_SSD1683_SET_RAMYPOS,
|
||||
bytearray([y1 & 0xFF, (y1 >> 8) & 0xFF, y2 & 0xFF, (y2 >> 8) & 0xFF]),
|
||||
)
|
||||
|
||||
def _send_command_list(self, init_sequence: bytes) -> None:
|
||||
"""Send a sequence of commands from an initialization list"""
|
||||
|
|
@ -248,14 +251,12 @@ class Adafruit_SSD1683(Adafruit_EPD):
|
|||
delay_ms = init_sequence[i]
|
||||
i += 1
|
||||
time.sleep(delay_ms / 1000.0)
|
||||
else:
|
||||
# Regular command
|
||||
if i < len(init_sequence):
|
||||
num_args = init_sequence[i]
|
||||
i += 1
|
||||
if num_args > 0 and (i + num_args) <= len(init_sequence):
|
||||
args = init_sequence[i:i + num_args]
|
||||
self.command(cmd, bytearray(args))
|
||||
i += num_args
|
||||
else:
|
||||
self.command(cmd)
|
||||
elif i < len(init_sequence):
|
||||
num_args = init_sequence[i]
|
||||
i += 1
|
||||
if num_args > 0 and (i + num_args) <= len(init_sequence):
|
||||
args = init_sequence[i : i + num_args]
|
||||
self.command(cmd, bytearray(args))
|
||||
i += num_args
|
||||
else:
|
||||
self.command(cmd)
|
||||
|
|
|
|||
Loading…
Reference in a new issue