From 5487a689a690957bef140fea937e42e56bfc918c Mon Sep 17 00:00:00 2001 From: Dunestorm Date: Sat, 19 Aug 2023 19:50:26 +0100 Subject: [PATCH] LiquidGUI [1.0.1.3] Bugfix Release - Moved device init into dedicated function to prevent unwanted device re-init. - Library renaming. --- liquidctl_worker.py => LiquidCTL_Helper.py | 17 ++++++++++------- main.pyw | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 18 deletions(-) rename liquidctl_worker.py => LiquidCTL_Helper.py (72%) diff --git a/liquidctl_worker.py b/LiquidCTL_Helper.py similarity index 72% rename from liquidctl_worker.py rename to LiquidCTL_Helper.py index 05df6a2..e896b2b 100644 --- a/liquidctl_worker.py +++ b/LiquidCTL_Helper.py @@ -1,22 +1,25 @@ from liquidctl import find_liquidctl_devices -class LiquidCTL_Init(): +class LiquidCTL_Helper(): device_name = None device_temp = 0 device_fanSpeed = 0 device_pumpSpeed = 0 - device_fwVers = 0 + device_fwVers = None devices = find_liquidctl_devices() for dev in devices: with dev.connect(): #print(f'{dev.description}') device_name = dev.description - init_status = dev.initialize() - if init_status: - for key, value, unit in init_status: - #print(f'- {key}: {value} {unit}') - device_fwVers = value + device_fwVers = ''.join(map(str, dev.firmware_version)) + + def ForceInit(self): + init_status = self.dev.initialize() + if init_status: + for key, value, unit in init_status: + #print(f'- {key}: {value} {unit}') + device_fwVers = value def TestConnectionState(self): if self.device_name != None: diff --git a/main.pyw b/main.pyw index 99dd6a3..d063ace 100644 --- a/main.pyw +++ b/main.pyw @@ -5,8 +5,8 @@ import resources from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QGroupBox from PySide6.QtCore import Qt, QTimer, QThreadPool from PySide6.QtGui import QFont, QIcon -from liquidctl_worker import LiquidCTL_Init -from messagehandler import MessageHandler +from LiquidCTL_Helper import LiquidCTL_Helper +from MessageHandler import MessageHandler class MainWindow(QMainWindow): def __init__(self): @@ -53,17 +53,17 @@ class MainWindow(QMainWindow): self.timer = QTimer() self.timer.setInterval(1000) - self.timer.timeout.connect(lambda: self.thread_manager.start(lctl_worker.Update)) + self.timer.timeout.connect(lambda: self.thread_manager.start(lctl_helper.Update)) self.timer.timeout.connect(self.update_widgets) self.timer.start() def update_widgets(self): - self.lbl_device_name.setText(lctl_worker.device_name) - self.prg_temp.setValue(lctl_worker.device_temp) - self.prg_fanSpeed.setValue(lctl_worker.device_fanSpeed) - self.prg_pumpSpeed.setValue(lctl_worker.device_pumpSpeed) - if lctl_worker.device_fwVers != 0 or None: - self.lbl_fwVers.setText(f"Firmware: v{lctl_worker.device_fwVers}") + self.lbl_device_name.setText(lctl_helper.device_name) + self.prg_temp.setValue(lctl_helper.device_temp) + self.prg_fanSpeed.setValue(lctl_helper.device_fanSpeed) + self.prg_pumpSpeed.setValue(lctl_helper.device_pumpSpeed) + if lctl_helper.device_fwVers != None: + self.lbl_fwVers.setText(f"Firmware: v{lctl_helper.device_fwVers}") app = QApplication(sys.argv) icon = QIcon(":/icons/LiquidGUI.ico") @@ -71,9 +71,9 @@ app.setWindowIcon(icon) messagehandler = MessageHandler() -lctl_worker = LiquidCTL_Init() +lctl_helper = LiquidCTL_Helper() # Show error and quit app if no devices are found -if lctl_worker.TestConnectionState() == True: +if lctl_helper.TestConnectionState() == True: messagehandler.ShowNoDevicesFoundError() sys.exit(1)