You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i just got this led matrix working as clock using the following code:
#!/usr/bin/env pythonimportRPi.GPIOasGPIOimporttimefromtimeimportsleepfromdatetimeimportdatetimefromluma.led_matrix.deviceimportmax7219fromluma.core.interface.serialimportspi, noopfromluma.core.virtualimportviewportfromluma.core.interface.serialimportspi, noopfromluma.core.renderimportcanvasfromluma.core.legacyimporttext, show_messagefromluma.core.legacy.fontimportproportional, CP437_FONT, TINY_FONTserial=spi(port=0, device=0, gpio=noop())
device=max7219(serial, width=32, height=8, block_orientation=90, blocks_arranged_in_reverse_order=True)
virtual=viewport(device, width=32, height=16)
defclock():
print ("clock is started")
# The time ascends from the abyss...animation(device, 8, 1)
button_state2=Truetoggle=True# Toggle the second indicator every secondwhileTrue:
toggle=nottogglesec=datetime.now().secondifsec==59:
# When we change minutes, animate the minute changeminute_change(device)
else:
hours=datetime.now().strftime('%H')
minutes=datetime.now().strftime('%M')
withcanvas(device) asdraw:
text(draw, (0, 1), hours, fill="white", font=proportional(CP437_FONT))
text(draw, (15, 1), ":"iftoggleelse" ", fill="white", font=proportional(TINY_FONT))
text(draw, (17, 1), minutes, fill="white", font=proportional(CP437_FONT))
time.sleep(0.5)
defminute_change(device):
'''When we reach a minute change, animate it.'''hours=datetime.now().strftime('%H')
minutes=datetime.now().strftime('%M')
defhelper(current_y):
withcanvas(device) asdraw:
text(draw, (0, 1), hours, fill="white", font=proportional(CP437_FONT))
text(draw, (15, 1), ":", fill="white", font=proportional(TINY_FONT))
text(draw, (17, current_y), minutes, fill="white", font=proportional(CP437_FONT))
time.sleep(0.1)
forcurrent_yinrange(1, 9):
helper(current_y)
minutes=datetime.now().strftime('%M')
forcurrent_yinrange(9, 1, -1):
helper(current_y)
defhour_change(device):
'''When we reach a hour change, animate it.'''hours=datetime.now().strftime('%H')
minutes=datetime.now().strftime('%M')
defhelper(current_y):
withcanvas(device) asdraw:
text(draw, (0, current_y), hours, fill="white", font=proportional(CP437_FONT))
text(draw, (15, 1), ":", fill="white", font=proportional(TINY_FONT))
text(draw, (17,1), minutes, fill="white", font=proportional(CP437_FONT))
time.sleep(0.1)
forcurrent_yinrange(1, 9):
helper(current_y)
hours=datetime.now().strftime('%H')
forcurrent_yinrange(9, 1, -1):
helper(current_y)
defanimation(device, from_y, to_y):
'''Animate the whole thing, moving it into/out of the abyss.'''hourstime=datetime.now().strftime('%H')
mintime=datetime.now().strftime('%M')
clock()
mainloop()
But i would like to use the seven segment display to run a countdown timer for various periods of time. Is it possible to get python to print out a timer display in HH:MM the same way it displays time for the clock?
if so can you also program it to do a stopwatch? (the ability to have the display count up and down would be amazing on two different scripts)
The text was updated successfully, but these errors were encountered:
Hello, i just got this led matrix working as clock using the following code:
But i would like to use the seven segment display to run a countdown timer for various periods of time. Is it possible to get python to print out a timer display in HH:MM the same way it displays time for the clock?
if so can you also program it to do a stopwatch? (the ability to have the display count up and down would be amazing on two different scripts)
The text was updated successfully, but these errors were encountered: