-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathled_matrix.py
executable file
·66 lines (56 loc) · 1.59 KB
/
led_matrix.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class LEDMatrix(object):
def __init__(self, microcontroller):
self.mc = microcontroller
self._turn_on()
def _select_row(self, row):
row = row % 8 if self.mc.smallBoard else row % 16
if row & 0x1:
self.mc.A.value(1)
else:
self.mc.A.value(0)
if row & 0x1 << 1:
self.mc.B.value(1)
else:
self.mc.B.value(0)
if row & 0x1 << 2:
self.mc.C.value(1)
else:
self.mc.C.value(0)
if row & 0x1 << 3:
self.mc.D.value(1)
else:
self.mc.D.value(0)
def _turn_on(self):
self.mc.OE.value(0)
def _turn_off(self):
self.mc.OE.value(1)
def _toggle_on_off(self):
value = 0 if self.mc.OE.value() else 1
self.mc.OE.value(value)
def _select_row(self, row):
row = row % 8 if self.mc.smallBoard else row % 16
if row & 0x1:
self.mc.A.value(1)
else:
self.mc.A.value(0)
if row & 0x1 << 1:
self.mc.B.value(1)
else:
self.mc.B.value(0)
if row & 0x1 << 2:
self.mc.C.value(1)
else:
self.mc.C.value(0)
if row & 0x1 << 3:
self.mc.D.value(1)
else:
self.mc.D.value(0)
def _turn_on(self):
self.mc.OE.value(0)
def _turn_off(self):
self.mc.OE.value(1)
def _toggle_on_off(self):
value = 0 if self.mc.OE.value() else 1
self.mc.OE.value(value)
def set_pixel(i, j, color):
raise NotImplementedError