From 8291b2052f4f43da2e928369de99af66a2f85d9a Mon Sep 17 00:00:00 2001 From: atse Date: Thu, 20 Jul 2023 13:49:11 +0800 Subject: [PATCH] Add thermistor config & sync Note: The formula is not actually Steinhart-Hart --- pytec/tec_qt.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 81498fe..7108d3c 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -79,6 +79,7 @@ class ClientWatcher(QObject): pwm_update = pyqtSignal(list) report_update = pyqtSignal(list) pid_update = pyqtSignal(list) + thermistor_update = pyqtSignal(list) def __init__(self, parent, client, update_s): self.update_s = update_s @@ -98,6 +99,7 @@ class ClientWatcher(QObject): self.pwm_update.emit(await self.client.get_pwm()) self.report_update.emit(await self.client._command("report")) self.pid_update.emit(await self.client.get_pid()) + self.thermistor_update.emit(await self.client.get_steinhart_hart()) def start_watching(self): self.watch_task = asyncio.create_task(self.run()) @@ -136,6 +138,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.client_watcher.fan_update.connect(self.fan_update) self.client_watcher.report_update.connect(self.update_report) self.client_watcher.pid_update.connect(self.update_pid) + self.client_watcher.thermistor_update.connect(self.update_thermistor) self.report_apply_btn.clicked.connect( lambda: self.client_watcher.set_update_s(self.report_refresh_spin.value()) ) @@ -290,6 +293,15 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): with QSignalBlocker(params[channel]): params[channel].child("Temperature PID").setValue(settings["pid_engaged"]) + @pyqtSlot(list) + def update_thermistor(self, sh_data): + for sh_param in sh_data: + channel = sh_param["channel"] + with QSignalBlocker(params[channel]): + params[channel].child("Thermistor Config", "T₀").setValue(sh_param["params"]["t0"] - 273.15) + params[channel].child("Thermistor Config", "R₀").setValue(sh_param["params"]["r0"]) + params[channel].child("Thermistor Config", "β").setValue(sh_param["params"]["b"]) + async def coro_main(): args = get_argparser().parse_args()