Skip to content

Commit b56f8b6

Browse files
author
caternuson
committed
fix for issue #20
1 parent b6fcdba commit b56f8b6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

adafruit_ht16k33/ht16k33.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ 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()
135-
return None
136136

137137
def _set_buffer(self, i, value):
138138
self._buffer[i+1] = value # Offset by 1 to move past register address.

0 commit comments

Comments
 (0)