Skip to content

Commit f0ffe0c

Browse files
committed
Fix #52 Distinguish stride from width for SSD1680
Apply fix from 8022b34 to Adafruit_SSD1680, allowing rotations of 1 and 2 to be used even when width is not a multiple of 8.
1 parent d44ecf5 commit f0ffe0c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

adafruit_epd/ssd1680.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ def __init__(
7878
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
7979
)
8080

81-
if width % 8 != 0:
82-
width += 8 - width % 8
81+
stride = width
82+
if stride % 8 != 0:
83+
stride += 8 - stride % 8
8384

84-
self._buffer1_size = int(width * height / 8)
85+
self._buffer1_size = int(stride * height / 8)
8586
self._buffer2_size = self._buffer1_size
8687

8788
if sramcs_pin:
@@ -92,10 +93,18 @@ def __init__(
9293
self._buffer2 = bytearray(self._buffer2_size)
9394

9495
self._framebuf1 = adafruit_framebuf.FrameBuffer(
95-
self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
96+
self._buffer1,
97+
width,
98+
height,
99+
stride=stride,
100+
buf_format=adafruit_framebuf.MHMSB,
96101
)
97102
self._framebuf2 = adafruit_framebuf.FrameBuffer(
98-
self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB
103+
self._buffer2,
104+
width,
105+
height,
106+
stride=stride,
107+
buf_format=adafruit_framebuf.MHMSB,
99108
)
100109
self.set_black_buffer(0, True)
101110
self.set_color_buffer(1, False)

0 commit comments

Comments
 (0)