Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.
Closed
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
15 changes: 14 additions & 1 deletion Adafruit_LEDBackpack/Adafruit_7Segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@

class SevenSegment:
disp = None

# Some 7Segment-Display have several different colons, e.g. the
# 1,2" display. To seperately control such different colons
# use the following values where applicable:
#
# 0x00 - nothing
# 0x02 - center colon
# 0x04 - left colon - upper dot
# 0x08 - left colon - lower dot
# 0x10 - decimal point
# 0xFFFF - everything (default)
mask_colons = 0xFFFF

# Hexadecimal character lookup table (row 1 = 0..9, row 2 = A..F)
digits = [ 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, \
Expand Down Expand Up @@ -45,8 +57,9 @@ def setColon(self, state=True):
# Warning: This function assumes that the colon is character '2',
# which is the case on 4 char displays, but may need to be modified
# if another display type is used

if (state):
self.disp.setBufferRow(2, 0xFFFF)
self.disp.setBufferRow(2, self.mask_colons)
else:
self.disp.setBufferRow(2, 0)

13 changes: 9 additions & 4 deletions Adafruit_LEDBackpack/ex_7segment_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
# Set minutes
segment.writeDigit(3, int(minute / 10)) # Tens
segment.writeDigit(4, minute % 10) # Ones
# Toggle colon
segment.setColon(second % 2) # Toggle colon at 1Hz
# Wait one second
time.sleep(1)

# Toggle colon(s) as configured in Adafruit_7Segment.py
# every second (by using even seconds vs. odd seconds)
if (second % 2 == 0): # reminder = 0 -> even second
segment.setColon(0) # turn colons off
else: # reminder != 0 -> odd second
segment.setColon(1) # turn colons on

time.sleep(1) # Wait one second