-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpixel.py
42 lines (33 loc) · 842 Bytes
/
pixel.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
import board
import displayio as dpio
from PixelDisplay import PixelDisplay, PixelThumb
disp = board.DISPLAY
g = dpio.Group()
disp.show(g)
pix = PixelDisplay(11, 11)
pix.scale = 2
pix.x = 16
pix.y = 10
g.append(pix)
thumb = PixelThumb(11, 11, 2, 8)
thumb.scale = 2
thumb.x = 252
thumb.y = 10
g.append(thumb)
with open("pixel.dat", "r") as f :
dat = eval("".join(f.readlines()))
assert len(dat) <= thumb.nx * thumb.ny
for i, d in enumerate(dat) :
if d is not None : thumb.set(i % thumb.nx, i // thumb.nx, d)
while len(dat) < thumb.nx * thumb.ny : dat.append(None)
while True :
d = pix.dump()
x = thumb.edit(d)
if x is None :
break
elif isinstance(x, tuple) :
dat[x[0] + x[1] * thumb.nx] = d
elif isinstance(x, bytearray) :
pix.restore(x)
pix.edit()
print(repr(dat))