forked from NG-SD-Plugins/PowerTools
Fix Fantastic support and SMT bug
This commit is contained in:
parent
c8c0266702
commit
b890e8a2b4
2 changed files with 29 additions and 6 deletions
19
main.py
19
main.py
|
@ -1,5 +1,6 @@
|
||||||
import time
|
import time
|
||||||
#import subprocess
|
#import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
VERSION = "0.4.0"
|
VERSION = "0.4.0"
|
||||||
|
|
||||||
|
@ -9,6 +10,7 @@ class Plugin:
|
||||||
FAN_SPEEDS = [0, 1000, 2000, 3000, 4000, 5000, 6000]
|
FAN_SPEEDS = [0, 1000, 2000, 3000, 4000, 5000, 6000]
|
||||||
|
|
||||||
auto_fan = True
|
auto_fan = True
|
||||||
|
smt = None
|
||||||
|
|
||||||
async def get_version(self) -> str:
|
async def get_version(self) -> str:
|
||||||
return VERSION
|
return VERSION
|
||||||
|
@ -17,6 +19,7 @@ class Plugin:
|
||||||
|
|
||||||
# call from main_view.html with setCPUs(count, smt)
|
# call from main_view.html with setCPUs(count, smt)
|
||||||
async def set_cpus(self, count, smt=True) -> int:
|
async def set_cpus(self, count, smt=True) -> int:
|
||||||
|
self.smt = smt
|
||||||
# print("Setting CPUs")
|
# print("Setting CPUs")
|
||||||
if smt:
|
if smt:
|
||||||
count = min(int(count), self.CPU_COUNT)
|
count = min(int(count), self.CPU_COUNT)
|
||||||
|
@ -43,10 +46,15 @@ class Plugin:
|
||||||
return online_count
|
return online_count
|
||||||
|
|
||||||
async def get_smt(self) -> bool:
|
async def get_smt(self) -> bool:
|
||||||
for cpu in range(1, self.CPU_COUNT, 2):
|
if self.smt is None:
|
||||||
if (not status_cpu(cpu)) and status_cpu(cpu+1):
|
for cpu in range(1, self.CPU_COUNT, 2):
|
||||||
return False
|
if (not status_cpu(cpu)) and status_cpu(cpu+1):
|
||||||
return True
|
self.smt = False
|
||||||
|
return False
|
||||||
|
self.smt = True
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return self.smt
|
||||||
|
|
||||||
async def set_boost(self, enabled: bool) -> bool:
|
async def set_boost(self, enabled: bool) -> bool:
|
||||||
write_to_sys("/sys/devices/system/cpu/cpufreq/boost", int(enabled))
|
write_to_sys("/sys/devices/system/cpu/cpufreq/boost", int(enabled))
|
||||||
|
@ -124,6 +132,9 @@ class Plugin:
|
||||||
return i
|
return i
|
||||||
return len(self.FAN_SPEEDS)-1 # any higher value is considered as highest manual setting
|
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
|
# Battery stuff
|
||||||
|
|
||||||
async def get_charge_now(self) -> int:
|
async def get_charge_now(self) -> int:
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
return call_plugin_method("get_fan_tick", {});
|
return call_plugin_method("get_fan_tick", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFantastic() {
|
||||||
|
return call_plugin_method("fantastic_installed", {});
|
||||||
|
}
|
||||||
|
|
||||||
function getChargeNow() {
|
function getChargeNow() {
|
||||||
return call_plugin_method("get_charge_now", {});
|
return call_plugin_method("get_charge_now", {});
|
||||||
}
|
}
|
||||||
|
@ -75,7 +79,15 @@
|
||||||
selectNotch("cpuThreadsNotch", await getCPUs() - 1, 8);
|
selectNotch("cpuThreadsNotch", await getCPUs() - 1, 8);
|
||||||
selectNotch("frequencyNotch", await getMaxBoost(), 3);
|
selectNotch("frequencyNotch", await getMaxBoost(), 3);
|
||||||
await onReadyGPU();
|
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();
|
await updateBatteryStats();
|
||||||
// this is unimportant; always do it last
|
// this is unimportant; always do it last
|
||||||
await updateVersion();
|
await updateVersion();
|
||||||
|
@ -430,7 +442,7 @@
|
||||||
|
|
||||||
<!-- Fan RPM selector -->
|
<!-- Fan RPM selector -->
|
||||||
<!-- TODO: Make this non-notched slider when PluginLoader PR#41 is merged -->
|
<!-- 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_FieldLabelRow_2VcTl">
|
||||||
<div class="gamepaddialog_FieldLabel_3jMlJ">Fan RPM</div>
|
<div class="gamepaddialog_FieldLabel_3jMlJ">Fan RPM</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue