diff options
| author | D Delmar Davis <don@suspectdevices.com> | 2025-06-21 19:53:00 -0700 |
|---|---|---|
| committer | D Delmar Davis <don@suspectdevices.com> | 2025-06-21 19:53:00 -0700 |
| commit | 084f7f30c631c5b7ce50db2ba58cd9926d6a84ab (patch) | |
| tree | b7b1773d6017d33b988ad01413adc80f9c0fa7fc | |
| parent | e1c7df44c9c651f19f642e13f210ffec1300af65 (diff) | |
timetemp
| -rw-r--r-- | bin/timetemp.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/timetemp.py b/bin/timetemp.py new file mode 100644 index 0000000..5bb6bf3 --- /dev/null +++ b/bin/timetemp.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +import time +import datetime + +from Adafruit_LED_Backpack import SevenSegment + +# =========================================================================== +# Clock Example +# =========================================================================== +segment = SevenSegment.SevenSegment(address=0x70) + +# Initialize the display. Must be called once before using the display. +segment.begin() + +print "Press CTRL+Z to exit" + +# Continually update the time on a 4 char, 7-segment display +while(True): + now = datetime.datetime.now() + hour = now.hour + minute = now.minute + second = now.second + + segment.clear() + # Set hours + segment.set_digit(0, int(hour / 10)) # Tens + segment.set_digit(1, hour % 10) # Ones + # Set minutes + segment.set_digit(2, int(minute / 10)) # Tens + segment.set_digit(3, minute % 10) # Ones + # Toggle colon + segment.set_colon(second % 2) # Toggle colon at 1Hz + + # Write the display buffer to the hardware. This must be called to + # update the actual display LEDs. + segment.write_display() + + # Wait a quarter second (less than 1 second to prevent colon blinking getting$ + time.sleep(0.25)
\ No newline at end of file |
