diff --git a/client/brewpi.ui b/client/brewpi.ui index 9b13aff..4f2ad4f 100644 --- a/client/brewpi.ui +++ b/client/brewpi.ui @@ -3727,16 +3727,16 @@ Set the simulated/assumed ambient temperature - 1 + 0 - 0.000000000000000 + -999.000000000000000 - 50.000000000000000 + 999.000000000000000 - 0.500000000000000 + 1.000000000000000 diff --git a/client/brewpi_gui.py b/client/brewpi_gui.py index ad95762..220aa58 100755 --- a/client/brewpi_gui.py +++ b/client/brewpi_gui.py @@ -365,6 +365,15 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): self.checkbox_heater_activate.stateChanged.connect(self.on_checkbox_changed) self.checkbox_stirrer_activate.stateChanged.connect(self.on_checkbox_stirrer_activate_changed) self.checkbox_tc_enable.stateChanged.connect(self.on_checkbox_tc_enable_changed) + # Show the last value we had before the GUI last closed (see + # closeEvent()) right away, rather than the spinbox's bare design-time + # default - blockSignals so this doesn't queue a spurious 'AmbientTemp' + # send before the user has touched anything. + remembered_ambient = self.user_config.get('ambient_temperature') + if remembered_ambient is not None: + self.doubleSpinBox_ambient.blockSignals(True) + self.doubleSpinBox_ambient.setValue(remembered_ambient) + self.doubleSpinBox_ambient.blockSignals(False) self.doubleSpinBox_ambient.valueChanged.connect(self.on_ambient_entry_changed) self.btn_pot_reset.clicked.connect(self.on_action_pot_reset) # Only meaningful (and only shown) once the server confirms its Pot @@ -424,11 +433,12 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): # on_sud_changed() routes the reply to update_sud_forecast() instead # of a save dialog. self.msg_sud.send({'Save': True}) - # Re-apply the last ambient temperature we set, in case the server - # restarted since (and so fell back to its own config.json default). - remembered_ambient = self.user_config.get('ambient_temperature') - if remembered_ambient is not None: - self.msg_system.send({'AmbientTemp': remembered_ambient}) + # Re-apply our own ambient temperature, in case the server restarted + # since (and so fell back to its own config.json default) - the + # spinbox's current value, not the on-disk user config (which is + # only refreshed on shutdown - see closeEvent()), so this also picks + # up a change made earlier in the same session, before a reconnect. + self.msg_system.send({'AmbientTemp': self.doubleSpinBox_ambient.value()}) def _elapsed_min(self): """Simulated-schedule minutes elapsed since the run started, or @@ -493,10 +503,11 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): self.checkbox_tc_enable.blockSignals(False) self.Slider_temp_soll.setEnabled(False) self.doubleSpinBox_heatrate_soll.setEnabled(False) + # ambient_temp (the server's last echoed reading, shown in the + # status bar) is no longer trustworthy, but the spinbox itself is + # a client-owned setting (see closeEvent()/connect()) - leave it + # showing whatever the user last set rather than blanking it. self.ambient_temp = None - self.doubleSpinBox_ambient.blockSignals(True) - self.doubleSpinBox_ambient.setValue(self.doubleSpinBox_ambient.minimum()) - self.doubleSpinBox_ambient.blockSignals(False) self.btn_pot_reset.setVisible(False) self.warp_factor = 1.0 self.sud_elapsed_seconds = None @@ -549,7 +560,9 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): self.msg_pot.send({'Reset': True}) def on_ambient_entry_changed(self, value): - self.user_config.set('ambient_temperature', value) + # Persisted on shutdown instead (see closeEvent()), not on every + # spinbox tick - this fires on every keystroke/arrow click while + # editing. self.msg_system.send({'AmbientTemp': value}) def update_status_env_label(self): @@ -945,6 +958,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): def closeEvent(self, event): print("Exitting gracefully!") + self.user_config.set('ambient_temperature', self.doubleSpinBox_ambient.value()) self.ws_client.disconnect() diff --git a/client/main_window.py b/client/main_window.py index 93c02a4..0b2ff16 100644 --- a/client/main_window.py +++ b/client/main_window.py @@ -1239,10 +1239,10 @@ class Ui_MainWindow(object): self.label_ambient.setObjectName("label_ambient") self.doubleSpinBox_ambient = QtWidgets.QDoubleSpinBox(self.centralwidget) self.doubleSpinBox_ambient.setGeometry(QtCore.QRect(620, 500, 70, 31)) - self.doubleSpinBox_ambient.setDecimals(1) - self.doubleSpinBox_ambient.setMinimum(0.0) - self.doubleSpinBox_ambient.setMaximum(50.0) - self.doubleSpinBox_ambient.setSingleStep(0.5) + self.doubleSpinBox_ambient.setDecimals(0) + self.doubleSpinBox_ambient.setMinimum(-999.0) + self.doubleSpinBox_ambient.setMaximum(999.0) + self.doubleSpinBox_ambient.setSingleStep(1.0) self.doubleSpinBox_ambient.setObjectName("doubleSpinBox_ambient") self.btn_pot_reset = QtWidgets.QPushButton(self.centralwidget) self.btn_pot_reset.setGeometry(QtCore.QRect(700, 500, 220, 31))