summaryrefslogtreecommitdiff
path: root/visualizer
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-04-17 11:09:45 +0200
committerPacien TRAN-GIRARD2015-04-17 11:09:45 +0200
commitf26c24f83eba172804efbdf506cf18d19f48b176 (patch)
tree007b0fcfa2bb23495e5a3ed13b8f95a1d9108d27 /visualizer
downloadmuseduino-f26c24f83eba172804efbdf506cf18d19f48b176.tar.gz
Import project
Diffstat (limited to 'visualizer')
-rw-r--r--visualizer/visualizer.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/visualizer/visualizer.py b/visualizer/visualizer.py
new file mode 100644
index 0000000..ed65384
--- /dev/null
+++ b/visualizer/visualizer.py
@@ -0,0 +1,53 @@
1
2BINS = 128
3
4
5import serial
6
7s = serial.Serial("/dev/ttyACM0", 115200)
8
9
10def acquire_data():
11
12 nb_val = 0
13 while nb_val != BINS+1:
14 l = s.readline()
15 d = l.decode("utf8")
16 v = d.split(' ')
17 nb_val = len(v)
18
19 n = [0] * BINS
20 for i in range(BINS):
21 try:
22 n[i] = int(v[i])
23
24 except ValueError:
25 n[i] = 0
26
27 return n
28
29
30import matplotlib.pyplot as plt
31import numpy as np
32
33
34fig = plt.figure()
35ax = fig.add_subplot(111)
36
37li, = ax.plot(range(BINS))
38plt.axis([0, BINS, 0, 250])
39
40fig.canvas.draw()
41plt.show(block=False)
42
43
44while True:
45 try:
46 y = acquire_data()
47 print(y)
48 li.set_ydata(y)
49 fig.canvas.draw()
50
51 except KeyboardInterrupt:
52 break
53