Skip to content

Commit 3428c47

Browse files
committed
Fixing matrix.fill color flipping
Swapping the _set_buffer() parameters so that when the matrix is filled it shows the proper color. This fixes part of issue #102. Tested with a QT Py RP2040 running CP8 and an 8x8 BiColor matrix I tried working on shifting to get the color to remain as expected but that's a little over my head at the moment. Also changing two ValueError() strings to f strings per pylint
1 parent 9b321db commit 3428c47

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

adafruit_ht16k33/matrix.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ def image(self, img: Image) -> None:
139139
imwidth, imheight = img.size
140140
if imwidth != self.columns or imheight != self.rows:
141141
raise ValueError(
142-
"Image must be same dimensions as display ({0}x{1}).".format(
143-
self.columns, self.rows
144-
)
142+
f"Image must be same dimensions as display ({self.columns}x{self.rows})."
145143
)
146144
# Grab all the pixels from the image, faster than getpixel.
147145
pixels = img.convert("1").load()
@@ -259,8 +257,8 @@ def fill(self, color: int) -> None:
259257
fill1 = 0xFF if color & 0x01 else 0x00
260258
fill2 = 0xFF if color & 0x02 else 0x00
261259
for i in range(8):
262-
self._set_buffer(i * 2, fill1)
263-
self._set_buffer(i * 2 + 1, fill2)
260+
self._set_buffer(i * 2 + 1, fill1)
261+
self._set_buffer(i * 2, fill2)
264262
if self._auto_write:
265263
self.show()
266264

@@ -274,9 +272,7 @@ def image(self, img: Image) -> None:
274272
imwidth, imheight = img.size
275273
if imwidth != self.columns or imheight != self.rows:
276274
raise ValueError(
277-
"Image must be same dimensions as display ({0}x{1}).".format(
278-
self.columns, self.rows
279-
)
275+
f"Image must be same dimensions as display ({self.columns}x{self.rows})."
280276
)
281277
# Grab all the pixels from the image, faster than getpixel.
282278
pixels = img.convert("RGB").load()

0 commit comments

Comments
 (0)