-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathneo16x16.py
62 lines (54 loc) · 1.7 KB
/
neo16x16.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
from microbit import *
from neopixel import NeoPixel
class neo16x16:
def __init__(self, pin):
self.np = NeoPixel(pin, 256)
self.color = (0,0,8)
def clear(self):
self.np.clear()
def set(self, n, color=''):
if color!='':
self.np[n] = color
else:
self.np[n] = self.color
self.np.show()
def setcolor(self, color):
self.color = color
def show(self, dat, pos=0, clear = True, color=''):
if color != '':
self.color = color
if clear:
for i in range(256):
self.np[i]=(0,0,0)
for x in range(16):
for y in range(16):
if (x+pos)>=len(dat):
self.np[x*16+y]=(0,0,0)
else:
if (1<<y)&dat[x+pos]:
if pos%2==0:
self.np[x*16 + y] = self.color
else:
self.np[x*16 +15 - y] = self.color
self.np.show()
def _delay(t):
while t>0:
t = t - 1
npdat=[
0x3F80,0x01FC,0x0080,0x01FC,0x3F80,0x0180,0x3F80,0x01FC,
0x0000,0x0000,0x3F98,0x19FC,0x3F98,0x0000,0x0000,0x0000,
0x0F00,0x01F8,0x3F80,0x010C,0x3080,0x019C,0x1980,0x0090,
0x0000,0x01FC,0x3F80,0x01FC,0x0180,0x0100,0x0080,0x0000,
0x0F00,0x01F8,0x3F80,0x010C,0x3080,0x01FC,0x1F80,0x00F0,
0x0000,0x0000,0x3080,0x010C,0x3080,0x0000,0x0000,0x0000,
0x3FF8,0x1FFC,0x3FF8,0x010C,0x3080,0x01FC,0x1F80,0x00F0,
0x0000,0x0000,0x3F98,0x19FC,0x3F98,0x0000,0x0000,0x0000,
0x0080,0x0100,0x1FF0,0x0FFC,0x3FF0,0x0104,0x3080,0x000C,
]
ne = neo16x16(pin1)
ne.setcolor((16,16,31))
n = 0
while True:
ne.show(npdat, n)
n = (n+1)%63
_delay(100)