Skip to content

Added colon property to 7-segment x 4 display #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2020
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
14 changes: 14 additions & 0 deletions adafruit_ht16k33/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ class Seg7x4(Seg14x4):
supports displaying a limited set of characters."""
POSITIONS = (0, 2, 6, 8) # The positions of characters.

def __init__(self, i2c, address=0x70, auto_write=True):
super().__init__(i2c, address, auto_write)
# Use colon for controling two-dots indicator at the center (index 0)
self._colon = Colon(self)

def scroll(self, count=1):
"""Scroll the display by specified number of places."""
if count >= 0:
Expand Down Expand Up @@ -372,6 +377,15 @@ def set_digit_raw(self, index, bitmask):
if self._auto_write:
self.show()

@property
def colon(self):
"""Simplified colon accessor"""
return self._colon[0]

@colon.setter
def colon(self, turn_on):
self._colon[0] = turn_on

class BigSeg7x4(Seg7x4):
"""Numeric 7-segment display. It has the same methods as the alphanumeric display, but only
supports displaying a limited set of characters."""
Expand Down
6 changes: 6 additions & 0 deletions examples/ht16k33_segments_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
display.print_hex(0xFF23)
time.sleep(2)

# Or, print the time
display.print("12:30")
time.sleep(2)

display.colon = False

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