Last active
February 25, 2022 01:11
-
-
Save whamtet/0fcaa8d656dbd1ea893fd82ebcf9cd0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import time | |
import tm1637 | |
disp = [63, 6, 91, 79, 102, 109, 125, 7, 127, 111, 119, 108] | |
tm = tm1637.TM1637(clk=5, dio=4) | |
# all LEDS on "88:88" | |
def write(nums): | |
tm.write(map(lambda x: disp[x], nums)) | |
def local_time(): | |
tm = time.localtime() | |
hours = tm[3] | |
mins = tm[4] | |
secs = tm[5] | |
hoursFrac = hours + mins / 60. + secs / 3600. | |
dayFrac = hoursFrac / 24 | |
bigSecs = dayFrac * 12 * 12 * 12 * 12 | |
disp = [0, 0, 0, 0] | |
for i in [3, 2, 1, 0]: | |
disp[i] = int(bigSecs) % 12 | |
bigSecs /= 12 | |
write(disp) | |
while True: | |
local_time() | |
time.sleep(3600. * 24 / 12 / 12 / 12 / 12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment