Skip to content

Instantly share code, notes, and snippets.

@whamtet
Last active February 25, 2022 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whamtet/0fcaa8d656dbd1ea893fd82ebcf9cd0f to your computer and use it in GitHub Desktop.
Save whamtet/0fcaa8d656dbd1ea893fd82ebcf9cd0f to your computer and use it in GitHub Desktop.
#!/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