Fix Fantastic support and SMT bug

This commit is contained in:
NGnius (Graham) 2022-05-09 13:14:28 -04:00
parent c8c0266702
commit b890e8a2b4
2 changed files with 29 additions and 6 deletions

19
main.py
View file

@ -1,5 +1,6 @@
import time
#import subprocess
import os
VERSION = "0.4.0"
@ -9,6 +10,7 @@ class Plugin:
FAN_SPEEDS = [0, 1000, 2000, 3000, 4000, 5000, 6000]
auto_fan = True
smt = None
async def get_version(self) -> str:
return VERSION
@ -17,6 +19,7 @@ class Plugin:
# call from main_view.html with setCPUs(count, smt)
async def set_cpus(self, count, smt=True) -> int:
self.smt = smt
# print("Setting CPUs")
if smt:
count = min(int(count), self.CPU_COUNT)
@ -43,10 +46,15 @@ class Plugin:
return online_count
async def get_smt(self) -> bool:
for cpu in range(1, self.CPU_COUNT, 2):
if (not status_cpu(cpu)) and status_cpu(cpu+1):
return False
return True
if self.smt is None:
for cpu in range(1, self.CPU_COUNT, 2):
if (not status_cpu(cpu)) and status_cpu(cpu+1):
self.smt = False
return False
self.smt = True
return True
else:
return self.smt
async def set_boost(self, enabled: bool) -> bool:
write_to_sys("/sys/devices/system/cpu/cpufreq/boost", int(enabled))
@ -124,6 +132,9 @@ class Plugin:
return i
return len(self.FAN_SPEEDS)-1 # any higher value is considered as highest manual setting
async def fantastic_installed(self) -> bool:
return os.path.exists("/home/deck/homebrew/plugins/Fantastic")
# Battery stuff
async def get_charge_now(self) -> int:

View file

@ -54,6 +54,10 @@
return call_plugin_method("get_fan_tick", {});
}
function getFantastic() {
return call_plugin_method("fantastic_installed", {});
}
function getChargeNow() {
return call_plugin_method("get_charge_now", {});
}
@ -75,7 +79,15 @@
selectNotch("cpuThreadsNotch", await getCPUs() - 1, 8);
selectNotch("frequencyNotch", await getMaxBoost(), 3);
await onReadyGPU();
selectNotch("fanNotch", await getFanTick(), 8);
let isFantasticInstalled = await getFantastic();
if (isFantasticInstalled) {
// Don't fight with Fantastic
let fanRoot = document.getElementById("fanRoot");
fanRoot.style.visibility = "hidden";
fanRoot.style.height = "0px";
} else {
selectNotch("fanNotch", await getFanTick(), 8);
}
await updateBatteryStats();
// this is unimportant; always do it last
await updateVersion();
@ -430,7 +442,7 @@
<!-- Fan RPM selector -->
<!-- TODO: Make this non-notched slider when PluginLoader PR#41 is merged -->
<div class="gamepaddialog_Field_eKmEX gamepaddialog_WithFirstRow_2bDqk gamepaddialog_WithChildrenBelow_37xzV gamepaddialog_InlineWrapShiftsChildrenBelow_3LCXh gamepaddialog_WithBottomSeparator_3YKpU gamepaddialog_ChildrenWidthFixed_ljcbL gamepaddialog_ExtraPaddingOnChildrenBelow_3nLNL gamepaddialog_StandardPadding_xIITX gamepaddialog_HighlightOnFocus_2HFrm Panel Focusable">
<div class="gamepaddialog_Field_eKmEX gamepaddialog_WithFirstRow_2bDqk gamepaddialog_WithChildrenBelow_37xzV gamepaddialog_InlineWrapShiftsChildrenBelow_3LCXh gamepaddialog_WithBottomSeparator_3YKpU gamepaddialog_ChildrenWidthFixed_ljcbL gamepaddialog_ExtraPaddingOnChildrenBelow_3nLNL gamepaddialog_StandardPadding_xIITX gamepaddialog_HighlightOnFocus_2HFrm Panel Focusable" id="fanRoot">
<div class="gamepaddialog_FieldLabelRow_2VcTl">
<div class="gamepaddialog_FieldLabel_3jMlJ">Fan RPM</div>
</div>