forked from M-Labs/thermostat
Move plot_options_menu stuff into menu
This commit is contained in:
parent
19470b3d02
commit
f141705b0e
@ -2,18 +2,22 @@ from PyQt6 import QtWidgets, QtGui
|
|||||||
|
|
||||||
|
|
||||||
class PlotOptionsMenu(QtWidgets.QMenu):
|
class PlotOptionsMenu(QtWidgets.QMenu):
|
||||||
def __init__(self, max_samples=1000):
|
def __init__(self, channel_graphs, max_samples=1000):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.channel_graphs = channel_graphs
|
||||||
|
|
||||||
self.setTitle("Plot Settings")
|
self.setTitle("Plot Settings")
|
||||||
|
|
||||||
clear = QtGui.QAction("Clear graphs", self)
|
clear = QtGui.QAction("Clear graphs", self)
|
||||||
self.addAction(clear)
|
self.addAction(clear)
|
||||||
self.clear = clear
|
self.clear = clear
|
||||||
|
self.clear.triggered.connect(self.channel_graphs.clear_graphs)
|
||||||
|
|
||||||
self.samples_spinbox = QtWidgets.QSpinBox()
|
self.samples_spinbox = QtWidgets.QSpinBox()
|
||||||
self.samples_spinbox.setRange(2, 100000)
|
self.samples_spinbox.setRange(2, 100000)
|
||||||
self.samples_spinbox.setSuffix(" samples")
|
self.samples_spinbox.setSuffix(" samples")
|
||||||
self.samples_spinbox.setValue(max_samples)
|
self.samples_spinbox.setValue(max_samples)
|
||||||
|
self.samples_spinbox.valueChanged.connect(self.channel_graphs.set_max_samples)
|
||||||
|
|
||||||
limit_samples = QtWidgets.QWidgetAction(self)
|
limit_samples = QtWidgets.QWidgetAction(self)
|
||||||
limit_samples.setDefaultWidget(self.samples_spinbox)
|
limit_samples.setDefaultWidget(self.samples_spinbox)
|
||||||
|
@ -126,11 +126,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.thermostat.report_update.connect(self.channel_graphs.update_report)
|
self.thermostat.report_update.connect(self.channel_graphs.update_report)
|
||||||
self.thermostat.pid_update.connect(self.channel_graphs.update_pid)
|
self.thermostat.pid_update.connect(self.channel_graphs.update_pid)
|
||||||
|
|
||||||
self.plot_options_menu = PlotOptionsMenu()
|
self.plot_options_menu = PlotOptionsMenu(self.channel_graphs)
|
||||||
self.plot_options_menu.clear.triggered.connect(self.clear_graphs)
|
|
||||||
self.plot_options_menu.samples_spinbox.valueChanged.connect(
|
|
||||||
self.channel_graphs.set_max_samples
|
|
||||||
)
|
|
||||||
self.plot_settings.setMenu(self.plot_options_menu)
|
self.plot_settings.setMenu(self.plot_options_menu)
|
||||||
|
|
||||||
self.conn_menu = ConnMenu()
|
self.conn_menu = ConnMenu()
|
||||||
@ -150,9 +146,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.port_set_spin.setValue(int(args.PORT))
|
self.port_set_spin.setValue(int(args.PORT))
|
||||||
self.connect_btn.click()
|
self.connect_btn.click()
|
||||||
|
|
||||||
def clear_graphs(self):
|
|
||||||
self.channel_graphs.clear_graphs()
|
|
||||||
|
|
||||||
@asyncSlot(ThermostatConnectionState)
|
@asyncSlot(ThermostatConnectionState)
|
||||||
async def _on_connection_changed(self, result):
|
async def _on_connection_changed(self, result):
|
||||||
match result:
|
match result:
|
||||||
@ -186,7 +179,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.loading_spinner.stop()
|
self.loading_spinner.stop()
|
||||||
self.thermostat_ctrl_menu.fan_pwm_warning.setPixmap(QtGui.QPixmap())
|
self.thermostat_ctrl_menu.fan_pwm_warning.setPixmap(QtGui.QPixmap())
|
||||||
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
||||||
self.clear_graphs()
|
self.channel_graphs.clear_graphs()
|
||||||
self.report_box.setChecked(False)
|
self.report_box.setChecked(False)
|
||||||
for ch in range(self.NUM_CHANNELS):
|
for ch in range(self.NUM_CHANNELS):
|
||||||
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
||||||
|
Loading…
Reference in New Issue
Block a user