SHA256
grafica v2
This commit is contained in:
1 parent
48eeb7f944
commit
835813b7a2
1 file changed
+14
-9
+14
-9
@@ -7,19 +7,24 @@ from pyqtgraph.Qt import QtCore
|
|||||||
def graficar(cola_clean, cola_filtrada, cola_buffer_size):
|
def graficar(cola_clean, cola_filtrada, cola_buffer_size):
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
win = pg.GraphicsLayoutWidget(show=True, title="Monitor de Señal")
|
win = pg.GraphicsLayoutWidget(show=True, title="Monitor de Señal")
|
||||||
p1 = win.addPlot(title="Señal Cruda y Filtrada (Bloques de 1s)")
|
|
||||||
p1.addLegend()
|
|
||||||
|
|
||||||
curve1 = p1.plot(pen=pg.mkPen("r", width=1), name="Cruda")
|
# Gráfica 1: Señal Cruda (Arriba)
|
||||||
curve2 = p1.plot(pen=pg.mkPen("b", width=2), name="Filtrada")
|
p1 = win.addPlot(title="Señal Cruda", row=0, col=0)
|
||||||
|
curve1 = p1.plot(pen=pg.mkPen("r", width=1.5))
|
||||||
|
|
||||||
|
# Gráfica 2: Señal Filtrada (Abajo)
|
||||||
|
p2 = win.addPlot(title="Señal Filtrada", row=1, col=0)
|
||||||
|
curve2 = p2.plot(pen=pg.mkPen("b", width=1.5))
|
||||||
|
|
||||||
|
# Sincronizar el eje X para que el zoom afecte a ambas
|
||||||
|
p2.setXLink(p1)
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
# Vaciamos la cola de tamaño por si llega,
|
# Vaciamos la cola de tamaño (ya no se usa aquí pero evitamos que se estanque)
|
||||||
# aunque ya no necesitamos inicializar arreglos vacíos.
|
|
||||||
while not cola_buffer_size.empty():
|
while not cola_buffer_size.empty():
|
||||||
cola_buffer_size.get()
|
cola_buffer_size.get()
|
||||||
|
|
||||||
# Extraemos el último bloque de 1s de la señal cruda
|
# Extraemos y dibujamos el bloque de la señal cruda
|
||||||
actualizar_cruda = False
|
actualizar_cruda = False
|
||||||
datos_crudos = None
|
datos_crudos = None
|
||||||
while not cola_clean.empty():
|
while not cola_clean.empty():
|
||||||
@@ -29,7 +34,7 @@ def graficar(cola_clean, cola_filtrada, cola_buffer_size):
|
|||||||
if actualizar_cruda and datos_crudos is not None:
|
if actualizar_cruda and datos_crudos is not None:
|
||||||
curve1.setData(datos_crudos)
|
curve1.setData(datos_crudos)
|
||||||
|
|
||||||
# Extraemos el último bloque de 1s de la señal filtrada
|
# Extraemos y dibujamos el bloque de la señal filtrada
|
||||||
actualizar_filtrada = False
|
actualizar_filtrada = False
|
||||||
datos_filtrados = None
|
datos_filtrados = None
|
||||||
while not cola_filtrada.empty():
|
while not cola_filtrada.empty():
|
||||||
@@ -41,6 +46,6 @@ def graficar(cola_clean, cola_filtrada, cola_buffer_size):
|
|||||||
|
|
||||||
timer = QtCore.QTimer()
|
timer = QtCore.QTimer()
|
||||||
timer.timeout.connect(update)
|
timer.timeout.connect(update)
|
||||||
timer.start(50) # Revisa la cola cada 50ms, pero la gráfica cambiará cada 1s
|
timer.start(50)
|
||||||
|
|
||||||
app.exec_()
|
app.exec_()
|
||||||
Reference in new issue
Block a user