LiquidGUI [1.1.0.0] DEV
- Moved device init into dedicated function to prevent unwanted device re-init. - Library renaming.
This commit is contained in:
@@ -1,22 +1,25 @@
|
|||||||
from liquidctl import find_liquidctl_devices, cli
|
from liquidctl import find_liquidctl_devices, cli
|
||||||
|
|
||||||
class LiquidCTL_Init():
|
class LiquidCTL_Helper():
|
||||||
device_name = None
|
device_name = None
|
||||||
device_temp = 0
|
device_temp = 0
|
||||||
device_fanSpeed = 0
|
device_fanSpeed = 0
|
||||||
device_pumpSpeed = 0
|
device_pumpSpeed = 0
|
||||||
device_fwVers = 0
|
device_fwVers = None
|
||||||
|
|
||||||
devices = find_liquidctl_devices()
|
devices = find_liquidctl_devices()
|
||||||
for dev in devices:
|
for dev in devices:
|
||||||
with dev.connect():
|
with dev.connect():
|
||||||
#print(f'{dev.description}')
|
#print(f'{dev.description}')
|
||||||
device_name = dev.description
|
device_name = dev.description
|
||||||
init_status = dev.initialize()
|
device_fwVers = ''.join(map(str, dev.firmware_version))
|
||||||
if init_status:
|
|
||||||
for key, value, unit in init_status:
|
def ForceInit(self):
|
||||||
#print(f'- {key}: {value} {unit}')
|
init_status = self.dev.initialize()
|
||||||
device_fwVers = value
|
if init_status:
|
||||||
|
for key, value, unit in init_status:
|
||||||
|
#print(f'- {key}: {value} {unit}')
|
||||||
|
device_fwVers = value
|
||||||
|
|
||||||
def TestConnectionState(self):
|
def TestConnectionState(self):
|
||||||
if self.device_name != None:
|
if self.device_name != None:
|
||||||
@@ -5,13 +5,13 @@ import resources
|
|||||||
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QPushButton
|
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QPushButton
|
||||||
from PySide6.QtCore import Qt, QTimer, QThreadPool
|
from PySide6.QtCore import Qt, QTimer, QThreadPool
|
||||||
from PySide6.QtGui import QFont, QIcon
|
from PySide6.QtGui import QFont, QIcon
|
||||||
from liquidctl_worker import LiquidCTL_Init
|
from LiquidCTL_Helper import LiquidCTL_Helper
|
||||||
from messagehandler import MessageHandler
|
from MessageHandler import MessageHandler
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self.setWindowTitle("LiquidGUI (v.1.0.1.2)")
|
self.setWindowTitle("LiquidGUI (v.1.1.0.0)")
|
||||||
self.setFixedSize(450, 350)
|
self.setFixedSize(450, 350)
|
||||||
self.setWindowFlags(Qt.WindowType.Dialog)
|
self.setWindowFlags(Qt.WindowType.Dialog)
|
||||||
widget = QWidget(self)
|
widget = QWidget(self)
|
||||||
@@ -56,20 +56,20 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.timer = QTimer()
|
self.timer = QTimer()
|
||||||
self.timer.setInterval(1000)
|
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.timeout.connect(self.update_widgets)
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
|
|
||||||
def update_widgets(self):
|
def update_widgets(self):
|
||||||
self.lbl_device_name.setText(lctl_worker.device_name)
|
self.lbl_device_name.setText(lctl_helper.device_name)
|
||||||
self.prg_temp.setValue(lctl_worker.device_temp)
|
self.prg_temp.setValue(lctl_helper.device_temp)
|
||||||
self.prg_fanSpeed.setValue(lctl_worker.device_fanSpeed)
|
self.prg_fanSpeed.setValue(lctl_helper.device_fanSpeed)
|
||||||
self.prg_pumpSpeed.setValue(lctl_worker.device_pumpSpeed)
|
self.prg_pumpSpeed.setValue(lctl_helper.device_pumpSpeed)
|
||||||
if lctl_worker.device_fwVers != 0 or None:
|
if lctl_helper.device_fwVers != None:
|
||||||
self.lbl_fwVers.setText(f"Firmware: v{lctl_worker.device_fwVers}")
|
self.lbl_fwVers.setText(f"Firmware: v{lctl_helper.device_fwVers}")
|
||||||
|
|
||||||
def max_fan_speed(self):
|
def max_fan_speed(self):
|
||||||
lctl_worker.SetFanSpeed(100)
|
lctl_helper.SetFanSpeed(100)
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
icon = QIcon(":/icons/LiquidGUI.ico")
|
icon = QIcon(":/icons/LiquidGUI.ico")
|
||||||
@@ -77,9 +77,9 @@ app.setWindowIcon(icon)
|
|||||||
|
|
||||||
messagehandler = MessageHandler()
|
messagehandler = MessageHandler()
|
||||||
|
|
||||||
lctl_worker = LiquidCTL_Init()
|
lctl_helper = LiquidCTL_Helper()
|
||||||
# Show error and quit app if no devices are found
|
# Show error and quit app if no devices are found
|
||||||
if lctl_worker.TestConnectionState() == True:
|
if lctl_helper.TestConnectionState() == True:
|
||||||
messagehandler.ShowNoDevicesFoundError()
|
messagehandler.ShowNoDevicesFoundError()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user