Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion adafruit_ht16k33/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def shift(self, x, y, rotate=False):

:param rotate: (Optional) Rotate the shifted pixels to the left side (default=False)
"""
auto_write = self.auto_write
self._auto_write = False
if x > 0: # Shift Right
for _ in range(x):
for row in range(0, self.rows):
Expand Down Expand Up @@ -87,7 +89,8 @@ def shift(self, x, y, rotate=False):
for row in range(0, self.rows - 1):
self[col, row] = self[col, row + 1]
self[col, self.rows - 1] = last_pixel
if self._auto_write:
self._auto_write = auto_write
if auto_write:
self.show()
#pylint: enable=too-many-branches

Expand Down
10 changes: 10 additions & 0 deletions adafruit_ht16k33/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ def print(self, value):
if self._auto_write:
self.show()

def print_hex(self, value):
"""Print the value as a hexidecimal string to the display."""
if isinstance(value, int):
if 0 <= value <= 0xFFFF:
self.print('{0:X}'.format(value))
else:
raise ValueError('Value out of displayable range: {}'.format(value))
else:
self.print(value)

def __setitem__(self, key, value):
self._put(value, key)
if self._auto_write:
Expand Down
4 changes: 4 additions & 0 deletions examples/ht16k33_segments_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
display.print(42)
time.sleep(2)

# Or, can print a hexadecimal value
display.print_hex(0xFF23)
time.sleep(2)

# Or, can set indivdual digits / characters
# Set the first character to '1':
display[0] = '1'
Expand Down