Move sigActivatedHandle to CtrlPanel

This commit is contained in:
atse 2024-08-26 15:22:41 +08:00
parent 375e159c39
commit ba369c880e
2 changed files with 13 additions and 11 deletions

View File

@ -5,6 +5,7 @@ from pyqtgraph.parametertree import (
registerParameterType,
)
from qasync import asyncSlot
from functools import partial
class MutexParameter(pTypes.ListParameter):
@ -83,9 +84,21 @@ class CtrlPanel(QObject):
self.params[i].setValue = self._setValue
self.params[i].sigTreeStateChanged.connect(self.send_command)
self.params[i].child("Save to flash").sigActivated.connect(
partial(self.thermostat.save_cfg, i)
)
self.params[i].child("Load from flash").sigActivated.connect(
partial(self.thermostat.load_cfg, i)
)
for handle in sigActivated_handles[i]:
self.params[i].child(*handle[0]).sigActivated.connect(handle[1])
self.thermostat.pid_update.connect(self.update_pid)
self.thermostat.report_update.connect(self.update_report)
self.thermostat.thermistor_update.connect(self.update_thermistor)
self.thermostat.pwm_update.connect(self.update_pwm)
self.thermostat.postfilter_update.connect(self.update_postfilter)
def _setValue(self, value, blockSignal=None):
"""
Implement 'lock' mechanism for Parameter Type

View File

@ -85,8 +85,6 @@ class MainWindow(QtWidgets.QMainWindow):
param_tree_sigActivated_handles = [
[
[["Save to flash"], partial(self.thermostat.save_cfg, ch)],
[["Load from flash"], partial(self.thermostat.load_cfg, ch)],
[
["PID Config", "PID Auto Tune", "Run"],
partial(self.pid_auto_tune_request, ch),
@ -112,17 +110,8 @@ class MainWindow(QtWidgets.QMainWindow):
)
self.thermostat.fan_update.connect(self.fan_update)
self.thermostat.report_update.connect(self.ctrl_panel_view.update_report)
self.thermostat.report_update.connect(self.autotuners.tick)
self.thermostat.report_update.connect(self.pid_autotune_handler)
self.thermostat.pid_update.connect(self.ctrl_panel_view.update_pid)
self.thermostat.pwm_update.connect(self.ctrl_panel_view.update_pwm)
self.thermostat.thermistor_update.connect(
self.ctrl_panel_view.update_thermistor
)
self.thermostat.postfilter_update.connect(
self.ctrl_panel_view.update_postfilter
)
self.thermostat.interval_update.connect(
self.autotuners.update_sampling_interval
)