Skip to content

Commit 3ebcc90

Browse files
authored
Merge pull request #90 from AJMansfield/patch-1
ssd1681: Fix OverflowError for displays larger than 255x255.
2 parents be77207 + 298eeb6 commit 3ebcc90

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

adafruit_epd/ssd1681.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def power_up(self) -> None:
143143
# driver output control
144144
self.command(
145145
_SSD1681_DRIVER_CONTROL,
146-
bytearray([self._width - 1, (self._width - 1) >> 8, 0x00]),
146+
bytearray([(self._width - 1) & 0xFF, (self._width - 1) >> 8, 0x00]),
147147
)
148148
# data entry mode
149149
self.command(_SSD1681_DATA_MODE, bytearray([0x03]))
@@ -152,7 +152,7 @@ def power_up(self) -> None:
152152
# Set ram Y start/end postion
153153
self.command(
154154
_SSD1681_SET_RAMYPOS,
155-
bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]),
155+
bytearray([0, 0, (self._height - 1) & 0xFF, (self._height - 1) >> 8]),
156156
)
157157
# Set border waveform
158158
self.command(_SSD1681_WRITE_BORDER, bytearray([0x05]))
@@ -190,4 +190,4 @@ def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
190190
# Set RAM X address counter
191191
self.command(_SSD1681_SET_RAMXCOUNT, bytearray([x]))
192192
# Set RAM Y address counter
193-
self.command(_SSD1681_SET_RAMYCOUNT, bytearray([y, y >> 8]))
193+
self.command(_SSD1681_SET_RAMYCOUNT, bytearray([y & 0xFF, y >> 8]))

0 commit comments

Comments
 (0)