Skip to content

Commit

Permalink
Add trigger delay for fail-safe to smooth-out temp spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIII committed Jun 9, 2024
1 parent f95eae0 commit 6b0faf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion installer-inno-config.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Thermal Control Center"
#define MyAppVersion "1.5.2"
#define MyAppVersion "1.5.3"
#define MyAppPublisher "AlexIII"
#define MyAppURL "https://github.com/AlexIII/tcc-g15"
#define MyAppExeName "tcc-g15.exe"
Expand Down
4 changes: 2 additions & 2 deletions make-release.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@echo off

echo Compiling Portable version...
pyinstaller --icon=icons/gaugeIcon.ico --add-data icons/gaugeIcon.png;icons --add-data tcc_g15_task.xml;. -w -F -y src/tcc-g15.py || goto :error
pyinstaller --icon=icons/gaugeIcon.ico --add-data icons/gaugeIcon.png;icons --add-data tcc_g15_task.xml;. --hidden-import PySide6 -w -F -y src/tcc-g15.py || goto :error

echo Compiling version for installer...
pyinstaller --icon=icons/gaugeIcon.ico --add-data icons/gaugeIcon.png;icons --add-data tcc_g15_task.xml;. -w -y src/tcc-g15.py || goto :error
pyinstaller --icon=icons/gaugeIcon.ico --add-data icons/gaugeIcon.png;icons --add-data tcc_g15_task.xml;. --hidden-import PySide6 -w -y src/tcc-g15.py || goto :error

echo Compiling installer...
"C:\Program Files (x86)\Inno Setup 6\iscc.exe" installer-inno-config.iss || goto :error
Expand Down
23 changes: 16 additions & 7 deletions src/GUI/AppGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ class TCC_GUI(QtWidgets.QWidget):
TEMP_UPD_PERIOD_MS = 1000
FAILSAFE_CPU_TEMP = 95
FAILSAFE_GPU_TEMP = 85
FAILSAFE_TRIGGER_DELAY_SEC = 8
FAILSAFE_RESET_AFTER_TEMP_IS_OK_FOR_SEC = 60
APP_NAME = "Thermal Control Center for Dell G15"
APP_VERSION = "1.5.2"
APP_VERSION = "1.5.3"
APP_DESCRIPTION = "This app is an open-source replacement for Alienware Control Center "
APP_URL = "github.com/AlexIII/tcc-g15"

Expand All @@ -104,15 +105,17 @@ class TCC_GUI(QtWidgets.QWidget):
CPU_COLOR_LIMITS = (85, 95)

# private
_failsafeTempIsHighTs = 0
_failsafeTrippedPrevModeStr = None
_failsafeTempIsHighTs = 0 # Last time when the temp was registered to be high
_failsafeTempIsHighStartTs: Optional[int] = None # Time when the temp first registered to be high (without going lower than the threshold)
_failsafeTrippedPrevModeStr: Optional[str] = None # Mode (Custom, Balanced) before fail-safe tripped, as a string
_failsafeOn = True

def __init__(self, awcc: AWCCThermal):
super().__init__()
self._awcc = awcc

self.settings = QtCore.QSettings(self.APP_URL, "AWCC")
print(self.settings.fileName())

# Set main window props
self.setFixedSize(600, 0)
Expand Down Expand Up @@ -262,11 +265,13 @@ def onModeChange(val: str):
onModeChange(ThermalMode.Balanced.value)
self._modeSwitch.setOnChange(onModeChange)

def updateOutput():
def updateAppState():
# Get temps and RPMs
gpuTemp = self._awcc.getFanRelatedTemp(self._awcc.GPUFanIdx)
gpuRPM = self._awcc.getFanRPM(self._awcc.GPUFanIdx)
cpuTemp = self._awcc.getFanRelatedTemp(self._awcc.CPUFanIdx)
cpuRPM = self._awcc.getFanRPM(self._awcc.CPUFanIdx)
# Update UI gauges
if gpuTemp is not None: self._thermalGPU.setTemp(gpuTemp)
if gpuRPM is not None: self._thermalGPU.setFanRPM(gpuRPM)
if cpuTemp is not None: self._thermalCPU.setTemp(cpuTemp)
Expand All @@ -282,9 +287,13 @@ def updateOutput():
if tempIsHigh:
self._failsafeTempIsHighTs = time.time()

self._failsafeTempIsHighStartTs = (self._failsafeTempIsHighStartTs or time.time()) if tempIsHigh else None

# Trip fail-safe
if (self._failsafeOn and
self._modeSwitch.getChecked() != ThermalMode.G_Mode.value and
tempIsHigh
tempIsHigh and
time.time() - self._failsafeTempIsHighStartTs > self.FAILSAFE_TRIGGER_DELAY_SEC
):
self._failsafeTrippedPrevModeStr = self._modeSwitch.getChecked()
self._modeSwitch.setChecked(ThermalMode.G_Mode.value)
Expand All @@ -302,8 +311,8 @@ def updateOutput():
trayIcon.update((gpuTemp, cpuTemp))
tray.setIcon(trayIcon)

self._updateGaugesTask = QPeriodic(self, self.TEMP_UPD_PERIOD_MS, updateOutput)
updateOutput()
self._updateGaugesTask = QPeriodic(self, self.TEMP_UPD_PERIOD_MS, updateAppState)
updateAppState()
self._updateGaugesTask.start()

self._thermalGPU.speedSliderChanged(updateFanSpeed)
Expand Down

0 comments on commit 6b0faf4

Please sign in to comment.