-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.py
48 lines (40 loc) · 1.07 KB
/
clock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import time
import datetime
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.legacy import show_message
from luma.core.legacy.font import (
proportional,
LCD_FONT,
)
def run():
try:
print("running clock...")
serial = spi(port=0, device=0, gpio=noop())
device = max7219(
serial,
cascaded=4,
block_orientation=-90,
rotate=0,
blocks_arranged_in_reverse_order=False,
)
while True:
now = datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
print("date and time:", now)
show_message(
device,
now,
fill="white",
font=proportional(LCD_FONT),
scroll_delay=0.02,
)
except Exception as e:
print("Error: ", e)
if __name__ == "__main__":
try:
time.sleep(5)
run()
except KeyboardInterrupt:
pass
except Exception as e:
print("Error in main: ", e)