-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix_horizontal_scroll_demo.py
More file actions
73 lines (62 loc) · 3.01 KB
/
matrix_horizontal_scroll_demo.py
File metadata and controls
73 lines (62 loc) · 3.01 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.
import re
import time
from datetime import datetime
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT
try:
# create matrix device
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=4, block_orientation=90, blocks_arranged_in_reverse_order=True)
device.contrast(10)
print("Created device")
CurrentTime = datetime.now()
MinutesStr = CurrentTime.strftime('%M') # Minute
HoursStr = CurrentTime.strftime('%-H') # Stunde
# HoursStr = "6"
# 0, 4, 10, 14, 20 = -2
# Scroll in
for i in range(35,-1,-1):
with canvas(device) as draw:
if int(HoursStr) < 10:
if int(HoursStr) == 0 or int(HoursStr) == 4:
text(draw, (i+7, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
else:
text(draw, (i+8, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
else:
if int(HoursStr) == 10 or int(HoursStr) == 14 or int(HoursStr) == 20:
text(draw, (i, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
else:
text(draw, (i+1, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
text(draw, (i+15, 0), ":", fill="white", font=proportional(TINY_FONT))
text(draw, (i+17, 0), MinutesStr, fill="white", font=proportional(CP437_FONT))
time.sleep(0.04)
#for i in range(-1,35,1):
#with canvas(device) as draw:
#text(draw, (i, 0), "10", fill="white", font=proportional(CP437_FONT))
#text(draw, (i+15, 0), ":", fill="white", font=proportional(TINY_FONT))
#text(draw, (i+17, 0), "00", fill="white", font=proportional(CP437_FONT))
#time.sleep(0.04)
time.sleep(5)
# Scroll out
for i in range(-1,-35,-1):
with canvas(device) as draw:
if int(HoursStr) < 10:
if int(HoursStr) == 0 or int(HoursStr) == 4 or int(HoursStr) == 10 or int(HoursStr) == 14 or int(HoursStr) == 20:
text(draw, (i+7, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
else:
text(draw, (i+8, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
else:
text(draw, (i, 0), HoursStr, fill="white", font=proportional(CP437_FONT))
text(draw, (i+15, 0), ":", fill="white", font=proportional(TINY_FONT))
text(draw, (i+17, 0), MinutesStr, fill="white", font=proportional(CP437_FONT))
time.sleep(0.04)
except KeyboardInterrupt:
pass