Skip to content

Commit abb15ea

Browse files
committed
Add 7 segment invert to its example, adjust to default to non-inverted mode.
1 parent ac0c639 commit abb15ea

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Adafruit_LED_Backpack/SevenSegment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@
6969
class SevenSegment(HT16K33.HT16K33):
7070
"""Seven segment LED backpack display."""
7171

72-
def __init__(self, **kwargs):
72+
def __init__(self, invert=False, **kwargs):
7373
"""Initialize display. All arguments will be passed to the HT16K33 class
7474
initializer, including optional I2C address and bus number parameters.
7575
"""
7676
super(SevenSegment, self).__init__(**kwargs)
77-
self.invert = True
77+
self.invert = invert
7878

7979
def set_invert(self, _invert):
8080
"""Set whether the display is upside-down or not.

examples/sevensegment_test.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@
7272
display.print_hex(i)
7373
display.set_colon(colon)
7474
display.write_display()
75-
time.sleep(0.5)
75+
time.sleep(0.25)
76+
# Run through hex digits with an inverted (flipped upside down)
77+
# display.
78+
display.set_invert(True)
79+
for i in range(0xFF):
80+
display.clear()
81+
display.print_hex(i)
82+
display.set_colon(colon)
83+
display.write_display()
84+
time.sleep(0.25)
85+
display.set_invert(False)
7686
# Flip colon on or off.
7787
colon = not colon
7888

0 commit comments

Comments
 (0)