Skip to content

Commit 29c028a

Browse files
authored
Merge pull request #56 from makermelissa/set_digit_raw
Added colon property to 7-segment x 4 display
2 parents 297b874 + c3392d8 commit 29c028a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

adafruit_ht16k33/segments.py

+14
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ class Seg7x4(Seg14x4):
311311
supports displaying a limited set of characters."""
312312
POSITIONS = (0, 2, 6, 8) # The positions of characters.
313313

314+
def __init__(self, i2c, address=0x70, auto_write=True):
315+
super().__init__(i2c, address, auto_write)
316+
# Use colon for controling two-dots indicator at the center (index 0)
317+
self._colon = Colon(self)
318+
314319
def scroll(self, count=1):
315320
"""Scroll the display by specified number of places."""
316321
if count >= 0:
@@ -372,6 +377,15 @@ def set_digit_raw(self, index, bitmask):
372377
if self._auto_write:
373378
self.show()
374379

380+
@property
381+
def colon(self):
382+
"""Simplified colon accessor"""
383+
return self._colon[0]
384+
385+
@colon.setter
386+
def colon(self, turn_on):
387+
self._colon[0] = turn_on
388+
375389
class BigSeg7x4(Seg7x4):
376390
"""Numeric 7-segment display. It has the same methods as the alphanumeric display, but only
377391
supports displaying a limited set of characters."""

examples/ht16k33_segments_simpletest.py

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
display.print_hex(0xFF23)
3535
time.sleep(2)
3636

37+
# Or, print the time
38+
display.print("12:30")
39+
time.sleep(2)
40+
41+
display.colon = False
42+
3743
# Or, can set indivdual digits / characters
3844
# Set the first character to '1':
3945
display[0] = '1'

0 commit comments

Comments
 (0)