-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprueba.py
More file actions
83 lines (57 loc) · 2.08 KB
/
prueba.py
File metadata and controls
83 lines (57 loc) · 2.08 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import matplotlib.pyplot as plt
from datetime import datetime
from matplotlib import pyplot
from matplotlib.animation import FuncAnimation
from matplotlib.widgets import Button
import random
from tkinter import *
from tkinter import ttk
import matplotlib.animation as animacion
DEVICE_FILE = "/dev/ASMAN_driver"
def write(channel):
file = open(DEVICE_FILE, "w")
file.write(channel)
file.close()
def read_sensor():
#cat
file = open(DEVICE_FILE,"r")
value = file.read()
file.close()
return value
#objeto grafico
class Index:
#inicializacion
def __init__(self):
self.figA = plt.figure()
self.figA.set_size_inches(10,8)
self.x_data = []
self.y_data = []
self.line, = pyplot.plot_date(self.x_data, self.y_data, '-')
plt.style.use('ggplot')
self.anim = FuncAnimation(self.figA,
self.animada,
interval=1000,
blit=True,frames=20, repeat=False)
#esta funcion se llama en en cada step
def animada(self,i):
valor1 = float(read_sensor())
print("Valor: ",valor1,"\n")
time1 = datetime.now()
self.x_data.append(time1)
self.y_data.append(valor1)
self.line.set_data(self.x_data, self.y_data)
self.figA.gca().relim()
self.figA.gca().autoscale_view()
return self.line,
#grafica la señal indicada por channel
def graficar(self,channel):
write(channel)
plt.show()
while(True):
channel=input("seleccione el canal \"a\" o \"b\": ")
while (channel!='a' and channel!='b' and channel!='exit' ):
channel=input("el channle "+channel+" no existe, elija \"a\", \"b\" o \"exit\" para salir: ")
if(channel=="exit"):
break
grafica=Index()
grafica.graficar(channel)