forked from M-Labs/thermostat
Move t_line setting to method, fixes 0°C bug
The 0 °C fix is an ugly one, ideally we should only update the label when visibility returns.
This commit is contained in:
parent
0e02803b98
commit
355cb8360a
@ -156,8 +156,8 @@ class ChannelGraphs:
|
||||
self._i_plot = LiveLinePlot(name='Measured')
|
||||
self._iset_plot = LiveLinePlot(name='Set', pen=pg.mkPen('r'))
|
||||
|
||||
self.t_line = self._t_widget.getPlotItem().addLine(label='{value} °C')
|
||||
self.t_line.setVisible(False)
|
||||
self._t_line = self._t_widget.getPlotItem().addLine(label='{value} °C')
|
||||
self._t_line.setVisible(False)
|
||||
|
||||
for graph in t_widget, i_widget:
|
||||
time_axis = LiveAxis('bottom', text="Time since Thermostat reset", **{Axis.TICK_FORMAT: Axis.DURATION})
|
||||
@ -203,6 +203,17 @@ class ChannelGraphs:
|
||||
for connector in self.t_connector, self.i_connector, self.iset_connector:
|
||||
connector.clear()
|
||||
|
||||
def set_t_line(self, temp=None, visible=None):
|
||||
if visible is not None:
|
||||
self._t_line.setVisible(visible)
|
||||
if temp is not None:
|
||||
self._t_line.setValue(temp)
|
||||
if visible is False:
|
||||
# PyQtGraph does not update this text when the line
|
||||
# is not visible, but we need it so that the temperature
|
||||
# label doesn't display 0 °C despite not being at 0 °C.
|
||||
self._t_line.label.setText(f"{temp} °C")
|
||||
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
@ -809,7 +820,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.params[channel].child("PID Config", "Max Current Output").setValue(settings["parameters"]["output_max"] * 1000)
|
||||
self.params[channel].child("PID Config", "Min Current Output").setValue(settings["parameters"]["output_min"] * 1000)
|
||||
self.params[channel].child("Output Config", "Control Method", "Set Temperature").setValue(settings["target"])
|
||||
self.channel_graphs[channel].t_line.setValue(round(settings["target"], 6))
|
||||
self.channel_graphs[channel].set_t_line(temp=round(settings["target"], 6))
|
||||
|
||||
@pyqtSlot(list)
|
||||
def update_report(self, report_data):
|
||||
@ -818,7 +829,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.channel_graphs[channel].plot_append(settings)
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Output Config", "Control Method").setValue("Temperature PID" if settings["pid_engaged"] else "Constant Current")
|
||||
self.channel_graphs[channel].t_line.setVisible(settings["pid_engaged"])
|
||||
self.channel_graphs[channel].set_t_line(visible=settings['pid_engaged'])
|
||||
self.params[channel].child("Output Config", "Control Method", "Set Current").setValue(settings["i_set"] * 1000)
|
||||
if settings['temperature'] is not None and settings['tec_i'] is not None:
|
||||
self.params[channel].child("Temperature").setValue(settings['temperature'])
|
||||
|
Loading…
Reference in New Issue
Block a user