-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.py
46 lines (35 loc) · 877 Bytes
/
debug.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
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from threading import Thread
import usbtinyisp
from pdb import set_trace
samples = 1000
channels = 4
fig, ax = plt.subplots()
ydata = np.zeros([samples, channels])
lns = plt.plot(ydata)
tiny = usbtinyisp.usbtiny()
tiny.power_on()
def aquire():
global ydata
while True:
ydata = np.roll(ydata, -1, 0)
for j in range(channels):
dat = tiny.spi1(0)
ydata[-1, j] = dat[0]
th = Thread(target=aquire)
th.daemon = True
th.start()
def init():
ax.set_ylim(0, 255)
ax.set_xlim(0, samples)
return lns
def update(frame):
#set_trace()
for ln, dat in zip(lns, ydata.T):
ln.set_ydata(dat)
return lns
ani = FuncAnimation(fig, update, interval=100,
init_func=init, blit=True)
plt.show()