-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDMatrix.py
33 lines (27 loc) · 1003 Bytes
/
LEDMatrix.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
import time
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
class LEDMatrix:
def __init__(self):
serial = spi(port=0, device=0, gpio=noop())
self.device = max7219(serial, 8, 8, 1, 0)
def clear(self):
with canvas(self.device) as draw:
draw.rectangle(self.device.bounding_box, outline="black", fill="black")
def show(self):
with canvas(self.device) as draw:
draw.rectangle(self.device.bounding_box, outline="white", fill="white")
for i in range(0 , 255):
self.device.contrast(i)
time.sleep(0.003)
for i in range(255 , 0):
self.device.contrast(i)
time.sleep(0.003)
for i in range(0 , 255):
self.device.contrast(i)
time.sleep(0.005)
for i in range(255 , 0):
self.device.contrast(i)
time.sleep(0.005)
self.clear()