Skip to content

Commit

Permalink
Disable some UI elements when the polling thread is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
akej74 committed Sep 29, 2016
1 parent 416d884 commit 6437eda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions grid-control/gridcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ def init_communication(self):
self.ui.horizontalSliderFan5.setEnabled(True)
self.ui.horizontalSliderFan6.setEnabled(True)

# Enable other UI elements
self.ui.radioButtonManual.setEnabled(True)
self.ui.radioButtonAutomatic.setEnabled(True)
self.ui.checkBoxSimulateTemp.setEnabled(True)
self.ui.horizontalSliderCPUTemp.setEnabled(True)
self.ui.horizontalSliderGPUTemp.setEnabled(True)

# Initialize the Grid+ V2 device
if grid.initialize_grid(self.ser, self.lock):
# Set the initial fan speeds based on UI values
Expand Down Expand Up @@ -337,14 +344,21 @@ def init_communication(self):
# Update status in UI
self.ui.labelPollingStatus.setText('<b><font color="red">Stopped</font></b>')

# If no serial port is selected, disable horizontal sliders
# If no serial port is selected, disable UI elements
else:
self.ui.horizontalSliderFan1.setEnabled(False)
self.ui.horizontalSliderFan2.setEnabled(False)
self.ui.horizontalSliderFan3.setEnabled(False)
self.ui.horizontalSliderFan4.setEnabled(False)
self.ui.horizontalSliderFan5.setEnabled(False)
self.ui.horizontalSliderFan6.setEnabled(False)
self.ui.radioButtonManual.setEnabled(False)
self.ui.radioButtonAutomatic.setEnabled(False)
self.ui.checkBoxSimulateTemp.setEnabled(False)
self.ui.horizontalSliderCPUTemp.setEnabled(False)
self.ui.horizontalSliderGPUTemp.setEnabled(False)
self.ui.horizontalSliderCPUTemp.setValue(0)
self.ui.horizontalSliderGPUTemp.setValue(0)

def reset_data(self):
"""Reset fan rpm and voltage to "---" and activate the red status icon.
Expand Down Expand Up @@ -379,8 +393,8 @@ def reset_data(self):
self.ui.lcdNumberCurrentGPU.display(0)

# Update status in UI
self.ui.labelPollingStatus.setText('<b><font color="red">Disconnected</font></b>')
self.ui.labelHWMonStatus.setText('<b><font color="red">Disconnected</font></b>')
self.ui.labelPollingStatus.setText('<b><font color="red">Stopped</font></b>')
self.ui.labelHWMonStatus.setText('<b><font color="red">---</font></b>')

def initialize_fans(self):
"""Initialize fans to the initial slider values."""
Expand Down Expand Up @@ -517,7 +531,7 @@ def simulate_temperatures(self):

# Update CPU and GPU values from current horizontal slider values
self.ui.lcdNumberCurrentCPU.display(self.ui.horizontalSliderCPUTemp.value())
self.ui.lcdNumberCurrentGPU.display(self.ui.horizontalSliderCPUTemp.value())
self.ui.lcdNumberCurrentGPU.display(self.ui.horizontalSliderGPUTemp.value())

# Disconnect temperature signals from polling thread
self.thread.cpu_temp_signal.disconnect(self.ui.lcdNumberCurrentCPU.display)
Expand Down Expand Up @@ -676,7 +690,7 @@ def closeEvent(self, event):
win = GridControl()

# Set program version
win.setWindowTitle("Grid Control 1.0")
win.setWindowTitle("Grid Control 1.0.2")

# Show window
win.show()
Expand Down
2 changes: 1 addition & 1 deletion grid-control/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def run(self):

# If both CPU and GPU temp are 0, set OpenHardwareMonitor status to "Disconnected"
if current_cpu_temp == current_gpu_temp == 0:
self.hwmon_status_signal.emit('<b><font color="red">Disconnected</font></b>')
self.hwmon_status_signal.emit('<b><font color="red">---</font></b>')
else:
self.hwmon_status_signal.emit('<b><font color="green">Connected</font></b>')

Expand Down

0 comments on commit 6437eda

Please sign in to comment.