master
Eggert Jung 2 years ago
commit 5dc7ee083d

@ -0,0 +1,9 @@
#set xrange [0:1000]
set yrange [30:420]
set grid y
#plot "temps.txt" with lines
#plot 'temps.txt' using 0:1 with lines, '' using 0:2 with lines
set key outside
plot for [col=1:5] 'temps.txt' using 0:col with lines
pause 1
reread

@ -0,0 +1,50 @@
from time import perf_counter
import threading
import numpy as np
import pyqtgraph as pg
import paho.mqtt.client as mqtt
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# client.subscribe("/Filamentanlage/01_Extruder/kraft")
client.subscribe("/Filamentanlage/01_Extruder/state/temp1")
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
update1(msg.payload)
win = pg.GraphicsLayoutWidget(show=True)
win.setWindowTitle('pyqtgraph example: Scrolling Plots')
p1 = win.addPlot()
data1 = np.zeros(5000)
curve1 = p1.plot(data1)
ptr1 = 0
def update1(val):
global data1, ptr1
data1[:-1] = data1[1:] # shift data in the array one sample left
# (see also: np.roll)
data1[-1] = val
curve1.setData(data1)
ptr1 += 1
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("192.168.5.2", 1883, 60)
thread = threading.Thread(target=client.loop_forever)
thread.setDaemon(True)
thread.start()
timer = pg.QtCore.QTimer()
timer.start(50)
pg.exec()
Loading…
Cancel
Save