Skip to content

Commit c9b3047

Browse files
authored
Merge pull request #23 from caternuson/iss20
Fix for issue #20
2 parents b6fcdba + 7dd810a commit c9b3047

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

adafruit_ht16k33/ht16k33.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ def fill(self, color):
121121
self.show()
122122

123123
def _pixel(self, x, y, color=None):
124-
mask = 1 << x
124+
addr = 2*y + x // 8
125+
mask = 1 << x % 8
125126
if color is None:
126-
return bool((self._buffer[y + 1] | self._buffer[y + 2] << 8) & mask)
127+
return bool(self._buffer[addr + 1] & mask)
127128
if color:
128-
self._buffer[(y * 2) + 1] |= mask & 0xff
129-
self._buffer[(y * 2) + 2] |= mask >> 8
129+
# set the bit
130+
self._buffer[addr + 1] |= mask
130131
else:
131-
self._buffer[(y * 2) + 1] &= ~(mask & 0xff)
132-
self._buffer[(y * 2) + 2] &= ~(mask >> 8)
132+
# clear the bit
133+
self._buffer[addr + 1] &= ~mask
133134
if self._auto_write:
134135
self.show()
135136
return None

0 commit comments

Comments
 (0)