2022-06-11 01:02:05 +01:00
|
|
|
import {
|
2022-09-01 01:18:15 +01:00
|
|
|
ButtonItem,
|
2022-06-11 01:02:05 +01:00
|
|
|
definePlugin,
|
2022-09-01 01:18:15 +01:00
|
|
|
//DialogButton,
|
2022-06-11 01:02:05 +01:00
|
|
|
//Menu,
|
|
|
|
//MenuItem,
|
|
|
|
PanelSection,
|
|
|
|
PanelSectionRow,
|
2022-11-19 20:21:09 +00:00
|
|
|
Router,
|
2022-06-11 01:02:05 +01:00
|
|
|
ServerAPI,
|
|
|
|
//showContextMenu,
|
|
|
|
staticClasses,
|
2022-07-04 22:12:13 +01:00
|
|
|
SliderField,
|
|
|
|
ToggleField,
|
2022-11-14 02:18:48 +00:00
|
|
|
Dropdown,
|
|
|
|
Field,
|
|
|
|
//DropdownOption,
|
|
|
|
SingleDropdownOption,
|
2022-06-11 01:02:05 +01:00
|
|
|
//NotchLabel
|
2022-11-19 20:21:09 +00:00
|
|
|
//gamepadDialogClasses,
|
|
|
|
//joinClassNames,
|
2022-06-11 01:02:05 +01:00
|
|
|
} from "decky-frontend-lib";
|
|
|
|
import { VFC, useState } from "react";
|
2022-06-11 01:34:19 +01:00
|
|
|
import { GiDrill } from "react-icons/gi";
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
//import * as python from "./python";
|
|
|
|
import * as backend from "./backend";
|
|
|
|
import {set_value, get_value, target_usdpl, version_usdpl} from "usdpl-front";
|
2022-06-11 01:02:05 +01:00
|
|
|
|
|
|
|
var periodicHook: NodeJS.Timer | null = null;
|
|
|
|
var lifetimeHook: any = null;
|
|
|
|
var startHook: any = null;
|
2022-09-01 01:18:15 +01:00
|
|
|
var usdplReady = false;
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
var eggCount = 0;
|
|
|
|
|
|
|
|
//var smtAllowed = true;
|
2022-11-14 02:18:48 +00:00
|
|
|
var advancedMode = false;
|
|
|
|
var advancedCpu = 1;
|
|
|
|
|
|
|
|
type MinMax = {
|
|
|
|
min: number | null;
|
|
|
|
max: number | null;
|
|
|
|
}
|
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
// usdpl persistent store keys
|
2022-07-10 19:04:50 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const BACKEND_INFO = "VINFO";
|
2023-01-03 02:22:53 +00:00
|
|
|
const DRIVER_INFO = "GENERAL_provider";
|
2022-07-10 19:04:50 +01:00
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
const LIMITS_INFO = "LIMITS_all";
|
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const CURRENT_BATT = "BATTERY_current_now";
|
|
|
|
const CHARGE_RATE_BATT = "BATTERY_charge_rate";
|
2022-11-22 01:58:35 +00:00
|
|
|
const CHARGE_MODE_BATT = "BATTERY_charge_mode";
|
2022-09-05 22:02:02 +01:00
|
|
|
const CHARGE_NOW_BATT = "BATTERY_charge_now";
|
|
|
|
const CHARGE_FULL_BATT = "BATTERY_charge_full";
|
|
|
|
const CHARGE_DESIGN_BATT = "BATTERY_charge_design"
|
2022-07-10 19:04:50 +01:00
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
//const TOTAL_CPUS = "CPUs_total";
|
2022-09-01 01:18:15 +01:00
|
|
|
const ONLINE_CPUS = "CPUs_online";
|
2022-11-14 02:18:48 +00:00
|
|
|
const ONLINE_STATUS_CPUS = "CPUs_status_online";
|
2022-11-13 17:41:45 +00:00
|
|
|
const SMT_CPU = "CPUs_SMT";
|
2022-09-01 01:18:15 +01:00
|
|
|
const CLOCK_MIN_CPU = "CPUs_min_clock";
|
|
|
|
const CLOCK_MAX_CPU = "CPUs_max_clock";
|
2022-11-14 02:18:48 +00:00
|
|
|
const CLOCK_MIN_MAX_CPU = "CPUs_minmax_clocks";
|
2022-09-01 01:18:15 +01:00
|
|
|
const GOVERNOR_CPU = "CPUs_governor";
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const FAST_PPT_GPU = "GPU_fastPPT";
|
|
|
|
const SLOW_PPT_GPU = "GPU_slowPPT";
|
|
|
|
const CLOCK_MIN_GPU = "GPU_min_clock";
|
|
|
|
const CLOCK_MAX_GPU = "GPU_max_clock";
|
|
|
|
const SLOW_MEMORY_GPU = "GPU_slow_memory";
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const PERSISTENT_GEN = "GENERAL_persistent";
|
|
|
|
const NAME_GEN = "GENERAL_name";
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-06 02:36:01 +01:00
|
|
|
function countCpus(statii: boolean[]): number {
|
|
|
|
let count = 0;
|
|
|
|
for (let i = 0; i < statii.length; i++) {
|
|
|
|
if (statii[i]) {
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2022-11-14 02:18:48 +00:00
|
|
|
function syncPlebClockToAdvanced() {
|
2022-11-19 20:21:09 +00:00
|
|
|
const cpuCount = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.count;
|
2022-11-14 02:18:48 +00:00
|
|
|
const minClock = get_value(CLOCK_MIN_CPU);
|
|
|
|
const maxClock = get_value(CLOCK_MAX_CPU);
|
|
|
|
let clockArr = [];
|
|
|
|
for (let i = 0; i < cpuCount; i++) {
|
|
|
|
clockArr.push({
|
|
|
|
min: minClock,
|
|
|
|
max: maxClock,
|
|
|
|
} as MinMax);
|
|
|
|
}
|
|
|
|
set_value(CLOCK_MIN_MAX_CPU, clockArr);
|
|
|
|
}
|
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const reload = function() {
|
|
|
|
if (!usdplReady) {return;}
|
2022-07-10 19:04:50 +01:00
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
backend.resolve(backend.getLimits(), (limits) => {
|
|
|
|
set_value(LIMITS_INFO, limits);
|
2023-01-05 00:42:59 +00:00
|
|
|
console.debug("POWERTOOLS: got limits ", limits);
|
2022-11-19 20:21:09 +00:00
|
|
|
});
|
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.getBatteryCurrent(), (rate: number) => { set_value(CURRENT_BATT, rate) });
|
|
|
|
backend.resolve(backend.getBatteryChargeRate(), (rate: number) => { set_value(CHARGE_RATE_BATT, rate) });
|
2022-11-22 01:58:35 +00:00
|
|
|
backend.resolve(backend.getBatteryChargeMode(), (mode: string) => { set_value(CHARGE_MODE_BATT, mode) });
|
2022-09-05 22:02:02 +01:00
|
|
|
backend.resolve(backend.getBatteryChargeNow(), (rate: number) => { set_value(CHARGE_NOW_BATT, rate) });
|
|
|
|
backend.resolve(backend.getBatteryChargeFull(), (rate: number) => { set_value(CHARGE_FULL_BATT, rate) });
|
|
|
|
backend.resolve(backend.getBatteryChargeDesign(), (rate: number) => { set_value(CHARGE_DESIGN_BATT, rate) });
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
//backend.resolve(backend.getCpuCount(), (count: number) => { set_value(TOTAL_CPUS, count)});
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.getCpusOnline(), (statii: boolean[]) => {
|
2022-11-14 02:18:48 +00:00
|
|
|
set_value(ONLINE_STATUS_CPUS, statii);
|
2022-09-06 02:36:01 +01:00
|
|
|
const count = countCpus(statii);
|
2022-09-01 01:18:15 +01:00
|
|
|
set_value(ONLINE_CPUS, count);
|
2022-11-19 20:21:09 +00:00
|
|
|
set_value(SMT_CPU, statii.length > 3 && statii[0] == statii[1] && statii[2] == statii[3]);
|
2022-09-01 01:18:15 +01:00
|
|
|
});
|
|
|
|
backend.resolve(backend.getCpuClockLimits(0), (limits: number[]) => {
|
|
|
|
set_value(CLOCK_MIN_CPU, limits[0]);
|
|
|
|
set_value(CLOCK_MAX_CPU, limits[1]);
|
2022-11-14 02:18:48 +00:00
|
|
|
syncPlebClockToAdvanced();
|
|
|
|
});
|
|
|
|
backend.resolve(backend.getCpusGovernor(), (governors: string[]) => {
|
|
|
|
set_value(GOVERNOR_CPU, governors);
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Info, "POWERTOOLS: Governors from backend " + governors.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
});
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.getGpuPpt(), (ppts: number[]) => {
|
|
|
|
set_value(FAST_PPT_GPU, ppts[0]);
|
|
|
|
set_value(SLOW_PPT_GPU, ppts[1]);
|
|
|
|
});
|
|
|
|
backend.resolve(backend.getGpuClockLimits(), (limits: number[]) => {
|
|
|
|
set_value(CLOCK_MIN_GPU, limits[0]);
|
|
|
|
set_value(CLOCK_MAX_GPU, limits[1]);
|
|
|
|
});
|
|
|
|
backend.resolve(backend.getGpuSlowMemory(), (status: boolean) => { set_value(SLOW_MEMORY_GPU, status) });
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.getGeneralPersistent(), (value: boolean) => { set_value(PERSISTENT_GEN, value) });
|
|
|
|
backend.resolve(backend.getGeneralSettingsName(), (name: string) => { set_value(NAME_GEN, name) });
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.getInfo(), (info: string) => { set_value(BACKEND_INFO, info) });
|
2023-01-03 02:22:53 +00:00
|
|
|
backend.resolve(backend.getDriverProviderName("gpu"), (driver: string) => { set_value(DRIVER_INFO, driver) });
|
2022-09-01 01:18:15 +01:00
|
|
|
};
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
// init USDPL WASM and connection to back-end
|
|
|
|
(async function(){
|
|
|
|
await backend.initBackend();
|
|
|
|
usdplReady = true;
|
|
|
|
set_value(NAME_GEN, "Default");
|
|
|
|
reload(); // technically this is only a load
|
2022-07-05 23:14:50 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
// register Steam callbacks
|
|
|
|
//@ts-ignore
|
|
|
|
lifetimeHook = SteamClient.GameSessions.RegisterForAppLifetimeNotifications((update) => {
|
|
|
|
if (update.bRunning) {
|
2023-01-05 00:42:59 +00:00
|
|
|
//backend.log(backend.LogLevel.Debug, "AppID " + update.unAppID.toString() + " is now running");
|
2022-09-01 01:18:15 +01:00
|
|
|
} else {
|
2023-01-05 00:42:59 +00:00
|
|
|
//backend.log(backend.LogLevel.Debug, "AppID " + update.unAppID.toString() + " is no longer running");
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(
|
|
|
|
backend.loadGeneralDefaultSettings(),
|
2023-01-05 00:42:59 +00:00
|
|
|
(ok: boolean) => {backend.log(backend.LogLevel.Debug, "Loading default settings ok? " + ok)}
|
2022-09-01 01:18:15 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//@ts-ignore
|
|
|
|
startHook = SteamClient.Apps.RegisterForGameActionStart((actionType, id) => {
|
|
|
|
//@ts-ignore
|
|
|
|
let gameInfo: any = appStore.GetAppOverviewByGameID(id);
|
2022-09-09 01:01:01 +01:00
|
|
|
// don't use gameInfo.appid, haha
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(
|
2022-09-09 01:01:01 +01:00
|
|
|
backend.loadGeneralSettings(id.toString() + ".json", gameInfo.display_name),
|
2023-01-05 00:42:59 +00:00
|
|
|
(ok: boolean) => {backend.log(backend.LogLevel.Debug, "Loading settings ok? " + ok)}
|
2022-09-01 01:18:15 +01:00
|
|
|
);
|
|
|
|
});
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Registered PowerTools callbacks, hello!");
|
2022-09-01 01:18:15 +01:00
|
|
|
})();
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const periodicals = function() {
|
|
|
|
backend.resolve(backend.getBatteryCurrent(), (rate: number) => { set_value(CURRENT_BATT, rate) });
|
2022-09-05 22:02:02 +01:00
|
|
|
backend.resolve(backend.getBatteryChargeNow(), (rate: number) => { set_value(CHARGE_NOW_BATT, rate) });
|
|
|
|
backend.resolve(backend.getBatteryChargeFull(), (rate: number) => { set_value(CHARGE_FULL_BATT, rate) });
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.getGeneralPersistent(), (value: boolean) => { set_value(PERSISTENT_GEN, value) });
|
|
|
|
backend.resolve(backend.getGeneralSettingsName(), (name: string) => {
|
|
|
|
const oldValue = get_value(NAME_GEN);
|
|
|
|
set_value(NAME_GEN, name);
|
|
|
|
if (name != oldValue) {
|
|
|
|
reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-09-01 01:18:15 +01:00
|
|
|
const [_idc, reloadGUI] = useState<any>("/shrug");
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-07-10 19:04:50 +01:00
|
|
|
if (periodicHook != null) {
|
|
|
|
clearInterval(periodicHook);
|
|
|
|
periodicHook = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
periodicHook = setInterval(function() {
|
2022-09-01 01:18:15 +01:00
|
|
|
periodicals();
|
|
|
|
reloadGUI("periodic" + (new Date()).getTime().toString());
|
2022-07-10 19:04:50 +01:00
|
|
|
}, 1000);
|
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
//const FieldWithSeparator = joinClassNames(gamepadDialogClasses.Field, gamepadDialogClasses.WithBottomSeparatorStandard);
|
2022-06-11 01:02:05 +01:00
|
|
|
|
2022-11-19 20:21:09 +00:00
|
|
|
const total_cpus = (get_value(LIMITS_INFO) as backend.SettingsLimits | null)?.cpu.count ?? 8;
|
2022-11-14 02:18:48 +00:00
|
|
|
const advancedCpuIndex = advancedCpu - 1;
|
2022-11-19 20:21:09 +00:00
|
|
|
const smtAllowed = (get_value(LIMITS_INFO) as backend.SettingsLimits | null)?.cpu.smt_capable ?? true;
|
|
|
|
|
|
|
|
const governorOptions: SingleDropdownOption[] = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].governors.map((elem) => {return {
|
|
|
|
data: elem,
|
|
|
|
label: <span>{elem}</span>,
|
|
|
|
};});
|
2022-09-01 01:18:15 +01:00
|
|
|
|
2022-11-22 01:58:35 +00:00
|
|
|
const chargeModeOptions: SingleDropdownOption[] = (get_value(LIMITS_INFO) as backend.SettingsLimits).battery.charge_modes.map((elem) => {return {
|
|
|
|
data: elem,
|
|
|
|
label: <span>{elem}</span>,
|
|
|
|
};});
|
|
|
|
|
2022-06-11 01:02:05 +01:00
|
|
|
return (
|
|
|
|
<PanelSection>
|
2022-11-14 02:18:48 +00:00
|
|
|
{/* CPU */}
|
2022-06-11 01:02:05 +01:00
|
|
|
<div className={staticClasses.PanelSectionTitle}>
|
|
|
|
CPU
|
|
|
|
</div>
|
2022-11-14 02:18:48 +00:00
|
|
|
<PanelSectionRow>
|
|
|
|
<ToggleField
|
|
|
|
checked={advancedMode}
|
|
|
|
label="Advanced"
|
|
|
|
description="Enables per-thread configuration"
|
|
|
|
onChange={(advanced: boolean) => {
|
|
|
|
advancedMode = advanced;
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</PanelSectionRow>
|
|
|
|
{/* CPU plebeian mode */}
|
|
|
|
{!advancedMode && smtAllowed && <PanelSectionRow>
|
2022-07-04 22:12:13 +01:00
|
|
|
<ToggleField
|
2022-11-13 17:41:45 +00:00
|
|
|
checked={get_value(SMT_CPU)}
|
2022-06-11 01:02:05 +01:00
|
|
|
label="SMT"
|
|
|
|
description="Enables odd-numbered CPUs"
|
|
|
|
onChange={(smt: boolean) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "SMT is now " + smt.toString());
|
2023-01-06 02:16:37 +00:00
|
|
|
//const cpus = get_value(ONLINE_CPUS);
|
2022-11-14 02:18:48 +00:00
|
|
|
const smtNow = smt && smtAllowed;
|
2023-01-06 02:16:37 +00:00
|
|
|
backend.resolve(backend.setCpuSmt(smtNow), (statii: boolean[]) => {
|
|
|
|
set_value(SMT_CPU, smtNow);
|
2022-11-14 02:18:48 +00:00
|
|
|
set_value(ONLINE_STATUS_CPUS, statii);
|
2022-09-06 02:36:01 +01:00
|
|
|
const count = countCpus(statii);
|
2022-09-05 19:24:01 +01:00
|
|
|
set_value(ONLINE_CPUS, count);
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("SMT");
|
|
|
|
});
|
2022-06-11 01:02:05 +01:00
|
|
|
}}
|
|
|
|
/>
|
2022-09-01 01:18:15 +01:00
|
|
|
</PanelSectionRow>}
|
2022-11-14 02:18:48 +00:00
|
|
|
{!advancedMode && <PanelSectionRow>
|
2022-07-04 22:12:13 +01:00
|
|
|
<SliderField
|
2022-06-11 01:02:05 +01:00
|
|
|
label="Threads"
|
2022-09-01 01:18:15 +01:00
|
|
|
value={get_value(ONLINE_CPUS)}
|
2022-06-11 01:02:05 +01:00
|
|
|
step={1}
|
2023-01-06 02:16:37 +00:00
|
|
|
max={(get_value(SMT_CPU) || !smtAllowed) ? total_cpus : total_cpus/2}
|
2022-06-11 01:02:05 +01:00
|
|
|
min={1}
|
|
|
|
showValue={true}
|
|
|
|
onChange={(cpus: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "CPU slider is now " + cpus.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const onlines = get_value(ONLINE_CPUS);
|
|
|
|
if (cpus != onlines) {
|
2022-09-06 02:36:01 +01:00
|
|
|
set_value(ONLINE_CPUS, cpus);
|
2022-11-13 17:41:45 +00:00
|
|
|
const smtNow = get_value(SMT_CPU);
|
2022-09-06 02:36:01 +01:00
|
|
|
let onlines: boolean[] = [];
|
2022-09-01 01:18:15 +01:00
|
|
|
for (let i = 0; i < total_cpus; i++) {
|
2022-11-13 17:41:45 +00:00
|
|
|
const online = smtNow? i < cpus : (i % 2 == 0) && (i < cpus * 2);
|
2022-09-06 02:36:01 +01:00
|
|
|
onlines.push(online);
|
2022-09-01 01:18:15 +01:00
|
|
|
}
|
2022-09-06 02:36:01 +01:00
|
|
|
backend.resolve(backend.setCpuOnlines(onlines), (statii: boolean[]) => {
|
2022-11-14 02:18:48 +00:00
|
|
|
set_value(ONLINE_STATUS_CPUS, statii);
|
2022-09-06 02:36:01 +01:00
|
|
|
const count = countCpus(statii);
|
2022-09-05 19:24:01 +01:00
|
|
|
set_value(ONLINE_CPUS, count);
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("CPUs");
|
|
|
|
});
|
2022-09-06 02:36:01 +01:00
|
|
|
reloadGUI("CPUsImmediate");
|
2022-06-11 01:02:05 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
2022-11-14 02:18:48 +00:00
|
|
|
</PanelSectionRow>}
|
|
|
|
{!advancedMode && <PanelSectionRow>
|
2022-07-04 22:12:13 +01:00
|
|
|
<ToggleField
|
2022-11-19 20:21:09 +00:00
|
|
|
checked={get_value(CLOCK_MIN_CPU) != null || get_value(CLOCK_MAX_CPU) != null}
|
2022-09-01 01:18:15 +01:00
|
|
|
label="Frequency Limits"
|
2022-09-05 19:24:01 +01:00
|
|
|
description="Set bounds on clock speed"
|
2022-09-01 01:18:15 +01:00
|
|
|
onChange={(value: boolean) => {
|
|
|
|
if (value) {
|
2022-11-19 20:21:09 +00:00
|
|
|
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_min_limits != null) {
|
|
|
|
set_value(CLOCK_MIN_CPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_min_limits!.min);
|
|
|
|
}
|
|
|
|
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_max_limits != null) {
|
|
|
|
set_value(CLOCK_MAX_CPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_max_limits!.max);
|
|
|
|
}
|
2022-11-14 02:18:48 +00:00
|
|
|
syncPlebClockToAdvanced();
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("CPUFreqToggle");
|
|
|
|
} else {
|
|
|
|
set_value(CLOCK_MIN_CPU, null);
|
|
|
|
set_value(CLOCK_MAX_CPU, null);
|
|
|
|
for (let i = 0; i < total_cpus; i++) {
|
|
|
|
backend.resolve(backend.unsetCpuClockLimits(i), (_idc: any[]) => {});
|
|
|
|
}
|
2022-11-13 17:41:45 +00:00
|
|
|
backend.resolve(backend.waitForComplete(), (_: boolean) => {
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("CPUUnsetFreq");
|
|
|
|
});
|
2022-11-14 02:18:48 +00:00
|
|
|
syncPlebClockToAdvanced();
|
2022-09-01 01:18:15 +01:00
|
|
|
}
|
2022-06-11 01:02:05 +01:00
|
|
|
}}
|
|
|
|
/>
|
2022-11-14 02:18:48 +00:00
|
|
|
</PanelSectionRow>}
|
2022-11-19 20:21:09 +00:00
|
|
|
{!advancedMode && (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_min_limits != null && <PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
{get_value(CLOCK_MIN_CPU) != null && <SliderField
|
|
|
|
label="Minimum (MHz)"
|
|
|
|
value={get_value(CLOCK_MIN_CPU)}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_min_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_min_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CLOCK_MIN_CPU) == null}
|
2022-06-11 01:02:05 +01:00
|
|
|
onChange={(freq: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Min freq slider is now " + freq.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const freqNow = get_value(CLOCK_MIN_CPU);
|
|
|
|
if (freq != freqNow) {
|
2022-09-06 02:36:01 +01:00
|
|
|
set_value(CLOCK_MIN_CPU, freq);
|
2022-09-01 01:18:15 +01:00
|
|
|
for (let i = 0; i < total_cpus; i++) {
|
|
|
|
backend.resolve(backend.setCpuClockLimits(i, freq, get_value(CLOCK_MAX_CPU)),
|
|
|
|
(limits: number[]) => {
|
|
|
|
set_value(CLOCK_MIN_CPU, limits[0]);
|
|
|
|
set_value(CLOCK_MAX_CPU, limits[1]);
|
2022-11-14 02:18:48 +00:00
|
|
|
syncPlebClockToAdvanced();
|
2022-09-01 01:18:15 +01:00
|
|
|
});
|
|
|
|
}
|
2022-11-13 17:41:45 +00:00
|
|
|
backend.resolve(backend.waitForComplete(), (_: boolean) => {
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("CPUMinFreq");
|
|
|
|
});
|
2022-09-06 02:36:01 +01:00
|
|
|
reloadGUI("CPUMinFreqImmediate");
|
2022-06-11 01:02:05 +01:00
|
|
|
}
|
|
|
|
}}
|
2022-09-01 01:18:15 +01:00
|
|
|
/>}
|
2022-11-14 02:18:48 +00:00
|
|
|
</PanelSectionRow>}
|
2022-11-19 20:21:09 +00:00
|
|
|
{!advancedMode && (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_max_limits != null && <PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
{get_value(CLOCK_MAX_CPU) != null && <SliderField
|
|
|
|
label="Maximum (MHz)"
|
|
|
|
value={get_value(CLOCK_MAX_CPU)}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_max_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_max_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[0].clock_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CLOCK_MAX_CPU) == null}
|
|
|
|
onChange={(freq: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Max freq slider is now " + freq.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const freqNow = get_value(CLOCK_MAX_CPU);
|
|
|
|
if (freq != freqNow) {
|
2022-09-06 02:36:01 +01:00
|
|
|
set_value(CLOCK_MAX_CPU, freq);
|
2022-09-01 01:18:15 +01:00
|
|
|
for (let i = 0; i < total_cpus; i++) {
|
|
|
|
backend.resolve(backend.setCpuClockLimits(i, get_value(CLOCK_MIN_CPU), freq),
|
|
|
|
(limits: number[]) => {
|
|
|
|
set_value(CLOCK_MIN_CPU, limits[0]);
|
|
|
|
set_value(CLOCK_MAX_CPU, limits[1]);
|
2022-11-14 02:18:48 +00:00
|
|
|
syncPlebClockToAdvanced();
|
2022-09-01 01:18:15 +01:00
|
|
|
});
|
|
|
|
}
|
2022-11-13 17:41:45 +00:00
|
|
|
backend.resolve(backend.waitForComplete(), (_: boolean) => {
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("CPUMaxFreq");
|
|
|
|
});
|
2022-09-06 02:36:01 +01:00
|
|
|
reloadGUI("CPUMaxFreqImmediate");
|
2022-09-01 01:18:15 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
2022-11-14 02:18:48 +00:00
|
|
|
</PanelSectionRow>}
|
|
|
|
{/* CPU advanced mode */}
|
|
|
|
{advancedMode && <PanelSectionRow>
|
|
|
|
<SliderField
|
2022-11-19 20:21:09 +00:00
|
|
|
label="Selected CPU"
|
2022-11-14 02:18:48 +00:00
|
|
|
value={advancedCpu}
|
|
|
|
step={1}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={total_cpus}
|
2022-11-14 02:18:48 +00:00
|
|
|
min={1}
|
|
|
|
showValue={true}
|
|
|
|
onChange={(cpuNum: number) => {
|
|
|
|
advancedCpu = cpuNum;
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</PanelSectionRow>}
|
|
|
|
{advancedMode && <PanelSectionRow>
|
|
|
|
<ToggleField
|
2022-11-19 20:21:09 +00:00
|
|
|
checked={get_value(ONLINE_STATUS_CPUS)[advancedCpuIndex]}
|
2022-11-14 02:18:48 +00:00
|
|
|
label="Online"
|
2022-11-19 20:21:09 +00:00
|
|
|
description="Allow the CPU thread to do work"
|
2022-11-14 02:18:48 +00:00
|
|
|
onChange={(status: boolean) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "CPU " + advancedCpu.toString() + " is now " + status.toString());
|
2023-01-06 02:16:37 +00:00
|
|
|
if (!get_value(SMT_CPU)) {
|
|
|
|
backend.resolve(backend.setCpuSmt(true), (_newVal: boolean[]) => {
|
|
|
|
set_value(SMT_CPU, true);
|
2022-11-14 02:18:48 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
backend.resolve(backend.setCpuOnline(advancedCpuIndex, status), (newVal: boolean) => {
|
|
|
|
const onlines = get_value(ONLINE_STATUS_CPUS);
|
|
|
|
onlines[advancedCpuIndex] = newVal;
|
|
|
|
set_value(ONLINE_STATUS_CPUS, onlines);
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</PanelSectionRow>}
|
|
|
|
{advancedMode && <PanelSectionRow>
|
|
|
|
<ToggleField
|
2022-11-19 20:21:09 +00:00
|
|
|
checked={get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].min != null || get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].max != null}
|
2022-11-14 02:18:48 +00:00
|
|
|
label="Frequency Limits"
|
|
|
|
description="Set bounds on clock speed"
|
|
|
|
onChange={(value: boolean) => {
|
|
|
|
if (value) {
|
|
|
|
const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[];
|
2022-11-19 20:21:09 +00:00
|
|
|
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_min_limits != null) {
|
|
|
|
clocks[advancedCpuIndex].min = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_min_limits!.min;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_max_limits != null) {
|
|
|
|
clocks[advancedCpuIndex].max = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_max_limits!.max;
|
|
|
|
}
|
2022-11-14 02:18:48 +00:00
|
|
|
set_value(CLOCK_MIN_MAX_CPU, clocks);
|
|
|
|
reloadGUI("CPUFreqToggle");
|
|
|
|
} else {
|
|
|
|
const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[];
|
|
|
|
clocks[advancedCpuIndex].min = null;
|
|
|
|
clocks[advancedCpuIndex].max = null;
|
|
|
|
set_value(CLOCK_MIN_MAX_CPU, clocks);
|
|
|
|
backend.resolve(backend.unsetCpuClockLimits(advancedCpuIndex), (_idc: any[]) => {
|
|
|
|
reloadGUI("CPUUnsetFreq");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</PanelSectionRow>}
|
2022-11-19 20:21:09 +00:00
|
|
|
{advancedMode && (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_min_limits != null && <PanelSectionRow>
|
2022-11-14 02:18:48 +00:00
|
|
|
{get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].min != null && <SliderField
|
|
|
|
label="Minimum (MHz)"
|
|
|
|
value={get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].min}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_min_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_min_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_step}
|
2022-11-14 02:18:48 +00:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].min == null}
|
|
|
|
onChange={(freq: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Min freq slider for " + advancedCpu.toString() + " is now " + freq.toString());
|
2022-11-14 02:18:48 +00:00
|
|
|
const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax;
|
|
|
|
if (freq != freqNow.min) {
|
|
|
|
backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freq, freqNow.max!),
|
|
|
|
(limits: number[]) => {
|
|
|
|
const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[];
|
|
|
|
clocks[advancedCpuIndex].min = limits[0];
|
|
|
|
clocks[advancedCpuIndex].max = limits[1];
|
|
|
|
set_value(CLOCK_MIN_MAX_CPU, clocks);
|
|
|
|
reloadGUI("CPUMinFreq");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
|
|
|
</PanelSectionRow>}
|
2022-11-19 20:21:09 +00:00
|
|
|
{advancedMode && (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_max_limits != null && <PanelSectionRow>
|
2022-11-14 02:18:48 +00:00
|
|
|
{get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].max != null && <SliderField
|
|
|
|
label="Maximum (MHz)"
|
|
|
|
value={get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].max}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_max_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_max_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].clock_step}
|
2022-11-14 02:18:48 +00:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex].max == null}
|
|
|
|
onChange={(freq: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Max freq slider for " + advancedCpu.toString() + " is now " + freq.toString());
|
2022-11-14 02:18:48 +00:00
|
|
|
const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax;
|
|
|
|
if (freq != freqNow.max) {
|
|
|
|
backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freqNow.min!, freq),
|
|
|
|
(limits: number[]) => {
|
|
|
|
const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[];
|
|
|
|
clocks[advancedCpuIndex].min = limits[0];
|
|
|
|
clocks[advancedCpuIndex].max = limits[1];
|
|
|
|
set_value(CLOCK_MIN_MAX_CPU, clocks);
|
|
|
|
reloadGUI("CPUMaxFreq");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
|
|
|
</PanelSectionRow>}
|
2022-11-22 01:58:35 +00:00
|
|
|
{advancedMode && governorOptions.length != 0 && <PanelSectionRow>
|
2022-11-14 02:18:48 +00:00
|
|
|
<Field
|
|
|
|
label="Governor"
|
|
|
|
>
|
|
|
|
<Dropdown
|
|
|
|
menuLabel="Governor"
|
|
|
|
rgOptions={governorOptions}
|
|
|
|
selectedOption={governorOptions.find((val: SingleDropdownOption, _index, _arr) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "POWERTOOLS: array item " + val.toString());
|
|
|
|
backend.log(backend.LogLevel.Debug, "POWERTOOLS: looking for data " + get_value(GOVERNOR_CPU)[advancedCpuIndex].toString());
|
2022-11-14 02:18:48 +00:00
|
|
|
return val.data == get_value(GOVERNOR_CPU)[advancedCpuIndex];
|
|
|
|
})}
|
|
|
|
strDefaultLabel={get_value(GOVERNOR_CPU)[advancedCpuIndex]}
|
|
|
|
onChange={(elem: SingleDropdownOption) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Governor dropdown selected " + elem.data.toString());
|
2022-11-14 02:18:48 +00:00
|
|
|
backend.resolve(backend.setCpuGovernor(advancedCpuIndex, elem.data as string), (gov: string) => {
|
|
|
|
const governors = get_value(GOVERNOR_CPU);
|
|
|
|
governors[advancedCpuIndex] = gov;
|
|
|
|
set_value(GOVERNOR_CPU, governors);
|
|
|
|
reloadGUI("CPUGovernor");
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Field>
|
|
|
|
</PanelSectionRow>}
|
2022-06-11 01:02:05 +01:00
|
|
|
{/* GPU */}
|
|
|
|
<div className={staticClasses.PanelSectionTitle}>
|
|
|
|
GPU
|
|
|
|
</div>
|
2022-11-19 20:21:09 +00:00
|
|
|
{ ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits != null ||(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits != null) && <PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
<ToggleField
|
2022-11-19 20:21:09 +00:00
|
|
|
checked={get_value(SLOW_PPT_GPU) != null || get_value(FAST_PPT_GPU) != null}
|
2022-09-01 01:18:15 +01:00
|
|
|
label="PowerPlay Limits"
|
|
|
|
description="Override APU TDP settings"
|
|
|
|
onChange={(value: boolean) => {
|
|
|
|
if (value) {
|
2022-11-19 20:21:09 +00:00
|
|
|
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits != null) {
|
|
|
|
set_value(SLOW_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits!.max);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits != null) {
|
|
|
|
set_value(FAST_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits!.max);
|
|
|
|
}
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("GPUPPTToggle");
|
|
|
|
} else {
|
|
|
|
set_value(SLOW_PPT_GPU, null);
|
|
|
|
set_value(FAST_PPT_GPU, null);
|
|
|
|
backend.resolve(backend.unsetGpuPpt(), (_: any[]) => {
|
|
|
|
reloadGUI("GPUUnsetPPT");
|
|
|
|
});
|
2022-06-11 01:02:05 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
2022-11-19 20:21:09 +00:00
|
|
|
</PanelSectionRow>}
|
2022-06-11 01:02:05 +01:00
|
|
|
<PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
{ get_value(SLOW_PPT_GPU) != null && <SliderField
|
2022-11-19 20:21:09 +00:00
|
|
|
label="SlowPPT (W)"
|
2022-09-01 01:18:15 +01:00
|
|
|
value={get_value(SLOW_PPT_GPU)}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.ppt_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(SLOW_PPT_GPU) == null}
|
|
|
|
onChange={(ppt: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "SlowPPT is now " + ppt.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const pptNow = get_value(SLOW_PPT_GPU);
|
2022-11-19 20:21:09 +00:00
|
|
|
const realPpt = ppt;
|
|
|
|
if (realPpt != pptNow) {
|
|
|
|
backend.resolve(backend.setGpuPpt(get_value(FAST_PPT_GPU), realPpt),
|
2022-09-01 01:18:15 +01:00
|
|
|
(limits: number[]) => {
|
|
|
|
set_value(FAST_PPT_GPU, limits[0]);
|
|
|
|
set_value(SLOW_PPT_GPU, limits[1]);
|
|
|
|
reloadGUI("GPUSlowPPT");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
|
|
|
</PanelSectionRow>
|
|
|
|
<PanelSectionRow>
|
|
|
|
{get_value(FAST_PPT_GPU) != null && <SliderField
|
2022-11-19 20:21:09 +00:00
|
|
|
label="FastPPT (W)"
|
2022-09-01 01:18:15 +01:00
|
|
|
value={get_value(FAST_PPT_GPU)}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.ppt_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(FAST_PPT_GPU) == null}
|
2022-06-11 01:02:05 +01:00
|
|
|
onChange={(ppt: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "FastPPT is now " + ppt.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const pptNow = get_value(FAST_PPT_GPU);
|
2022-11-19 20:21:09 +00:00
|
|
|
const realPpt = ppt;
|
|
|
|
if (realPpt != pptNow) {
|
|
|
|
backend.resolve(backend.setGpuPpt(realPpt, get_value(SLOW_PPT_GPU)),
|
2022-09-01 01:18:15 +01:00
|
|
|
(limits: number[]) => {
|
|
|
|
set_value(FAST_PPT_GPU, limits[0]);
|
|
|
|
set_value(SLOW_PPT_GPU, limits[1]);
|
|
|
|
reloadGUI("GPUFastPPT");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
|
|
|
</PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
{((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_min_limits != null || (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_max_limits != null) && <PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
<ToggleField
|
2022-11-19 20:21:09 +00:00
|
|
|
checked={get_value(CLOCK_MIN_GPU) != null || get_value(CLOCK_MAX_GPU) != null}
|
2022-09-01 01:18:15 +01:00
|
|
|
label="Frequency Limits"
|
2022-09-05 19:24:01 +01:00
|
|
|
description="Override bounds on gpu clock"
|
2022-09-01 01:18:15 +01:00
|
|
|
onChange={(value: boolean) => {
|
|
|
|
if (value) {
|
2022-11-19 20:21:09 +00:00
|
|
|
let clock_min_limits = (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_min_limits;
|
|
|
|
let clock_max_limits = (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_max_limits;
|
|
|
|
if (clock_min_limits != null) {
|
|
|
|
set_value(CLOCK_MIN_GPU, clock_min_limits.min);
|
|
|
|
}
|
|
|
|
if (clock_max_limits != null) {
|
|
|
|
set_value(CLOCK_MAX_GPU, clock_max_limits.max);
|
|
|
|
}
|
2022-09-01 01:18:15 +01:00
|
|
|
reloadGUI("GPUFreqToggle");
|
|
|
|
} else {
|
|
|
|
set_value(CLOCK_MIN_GPU, null);
|
2022-09-01 01:29:08 +01:00
|
|
|
set_value(CLOCK_MAX_GPU, null);
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(backend.unsetGpuClockLimits(), (_: any[]) => {
|
|
|
|
reloadGUI("GPUUnsetFreq");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
2022-11-19 20:21:09 +00:00
|
|
|
</PanelSectionRow>}
|
2022-09-01 01:18:15 +01:00
|
|
|
<PanelSectionRow>
|
|
|
|
{ get_value(CLOCK_MIN_GPU) != null && <SliderField
|
|
|
|
label="Minimum (MHz)"
|
|
|
|
value={get_value(CLOCK_MIN_GPU)}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_min_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_min_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CLOCK_MIN_GPU) == null}
|
|
|
|
onChange={(val: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "GPU Clock Min is now " + val.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const valNow = get_value(CLOCK_MIN_GPU);
|
|
|
|
if (val != valNow) {
|
|
|
|
backend.resolve(backend.setGpuClockLimits(val, get_value(CLOCK_MAX_GPU)),
|
|
|
|
(limits: number[]) => {
|
|
|
|
set_value(CLOCK_MIN_GPU, limits[0]);
|
|
|
|
set_value(CLOCK_MAX_GPU, limits[1]);
|
|
|
|
reloadGUI("GPUMinClock");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
|
|
|
</PanelSectionRow>
|
|
|
|
<PanelSectionRow>
|
|
|
|
{get_value(CLOCK_MAX_GPU) != null && <SliderField
|
|
|
|
label="Maximum (MHz)"
|
|
|
|
value={get_value(CLOCK_MAX_GPU)}
|
2022-11-19 20:21:09 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_max_limits!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_max_limits!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.clock_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CLOCK_MAX_GPU) == null}
|
|
|
|
onChange={(val: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "GPU Clock Max is now " + val.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const valNow = get_value(CLOCK_MAX_GPU);
|
|
|
|
if (val != valNow) {
|
|
|
|
backend.resolve(backend.setGpuClockLimits(get_value(CLOCK_MIN_GPU), val),
|
|
|
|
(limits: number[]) => {
|
|
|
|
set_value(CLOCK_MIN_GPU, limits[0]);
|
|
|
|
set_value(CLOCK_MAX_GPU, limits[1]);
|
|
|
|
reloadGUI("GPUMaxClock");
|
|
|
|
});
|
2022-06-11 01:02:05 +01:00
|
|
|
}
|
|
|
|
}}
|
2022-09-01 01:18:15 +01:00
|
|
|
/>}
|
|
|
|
</PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
{(get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.memory_control_capable && <PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
<ToggleField
|
|
|
|
checked={get_value(SLOW_MEMORY_GPU)}
|
|
|
|
label="Downclock Memory"
|
|
|
|
description="Force RAM into low-power mode"
|
|
|
|
onChange={(value: boolean) => {
|
|
|
|
backend.resolve(backend.setGpuSlowMemory(value), (val: boolean) => {
|
|
|
|
set_value(SLOW_MEMORY_GPU, val);
|
|
|
|
reloadGUI("GPUSlowMemory");
|
|
|
|
})
|
|
|
|
}}
|
2022-06-11 01:02:05 +01:00
|
|
|
/>
|
2022-11-19 20:21:09 +00:00
|
|
|
</PanelSectionRow>}
|
2022-06-11 01:02:05 +01:00
|
|
|
{/* Battery */}
|
|
|
|
<div className={staticClasses.PanelSectionTitle}>
|
|
|
|
Battery
|
|
|
|
</div>
|
2022-11-19 20:21:09 +00:00
|
|
|
{get_value(CHARGE_NOW_BATT) != null && get_value(CHARGE_FULL_BATT) != null && <PanelSectionRow>
|
|
|
|
<Field
|
|
|
|
label="Now (Charge)"
|
|
|
|
onClick={()=> eggCount++}
|
|
|
|
focusable={false}>
|
|
|
|
{get_value(CHARGE_NOW_BATT).toFixed(1)} Wh ({(100 * get_value(CHARGE_NOW_BATT) / get_value(CHARGE_FULL_BATT)).toFixed(1)}%)
|
|
|
|
</Field>
|
|
|
|
</PanelSectionRow>}
|
|
|
|
{get_value(CHARGE_FULL_BATT) != null && get_value(CHARGE_DESIGN_BATT) != null && <PanelSectionRow>
|
|
|
|
<Field
|
|
|
|
label="Max (Design)"
|
|
|
|
onClick={()=> eggCount++}
|
|
|
|
focusable={false}>
|
|
|
|
{get_value(CHARGE_FULL_BATT).toFixed(1)} Wh ({(100 * get_value(CHARGE_FULL_BATT) / get_value(CHARGE_DESIGN_BATT)).toFixed(1)}%)
|
|
|
|
</Field>
|
|
|
|
</PanelSectionRow>}
|
2022-11-21 22:00:43 +00:00
|
|
|
{(get_value(LIMITS_INFO) as backend.SettingsLimits).battery.charge_current != null && <PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
<ToggleField
|
|
|
|
checked={get_value(CHARGE_RATE_BATT) != null}
|
|
|
|
label="Charge Current Limits"
|
2022-09-06 02:36:01 +01:00
|
|
|
description="Control battery charge rate when awake"
|
2022-09-01 01:18:15 +01:00
|
|
|
onChange={(value: boolean) => {
|
|
|
|
if (value) {
|
|
|
|
set_value(CHARGE_RATE_BATT, 2500);
|
|
|
|
reloadGUI("BATTChargeRateToggle");
|
|
|
|
} else {
|
|
|
|
set_value(CHARGE_RATE_BATT, null);
|
|
|
|
backend.resolve(backend.unsetBatteryChargeRate(), (_: any[]) => {
|
|
|
|
reloadGUI("BATTUnsetChargeRate");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{ get_value(CHARGE_RATE_BATT) != null && <SliderField
|
|
|
|
label="Maximum (mA)"
|
|
|
|
value={get_value(CHARGE_RATE_BATT)}
|
2022-11-21 22:00:43 +00:00
|
|
|
max={(get_value(LIMITS_INFO) as backend.SettingsLimits).battery.charge_current!.max}
|
|
|
|
min={(get_value(LIMITS_INFO) as backend.SettingsLimits).battery.charge_current!.min}
|
|
|
|
step={(get_value(LIMITS_INFO) as backend.SettingsLimits).battery.charge_current_step}
|
2022-09-01 01:18:15 +01:00
|
|
|
showValue={true}
|
|
|
|
disabled={get_value(CHARGE_RATE_BATT) == null}
|
|
|
|
onChange={(val: number) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Charge rate is now " + val.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
const rateNow = get_value(CHARGE_RATE_BATT);
|
|
|
|
if (val != rateNow) {
|
|
|
|
backend.resolve(backend.setBatteryChargeRate(val),
|
|
|
|
(rate: number) => {
|
|
|
|
set_value(CHARGE_RATE_BATT, rate);
|
|
|
|
reloadGUI("BATTChargeRate");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>}
|
2022-11-19 20:21:09 +00:00
|
|
|
</PanelSectionRow>}
|
2022-11-22 01:58:35 +00:00
|
|
|
{chargeModeOptions.length != 0 && <PanelSectionRow>
|
|
|
|
<ToggleField
|
|
|
|
checked={get_value(CHARGE_MODE_BATT) != null}
|
|
|
|
label="Charge Mode"
|
|
|
|
description="Force battery charge mode"
|
|
|
|
onChange={(value: boolean) => {
|
|
|
|
if (value) {
|
|
|
|
set_value(CHARGE_MODE_BATT, chargeModeOptions[0].data as string);
|
|
|
|
reloadGUI("BATTChargeModeToggle");
|
|
|
|
} else {
|
|
|
|
set_value(CHARGE_MODE_BATT, null);
|
|
|
|
backend.resolve(backend.unsetBatteryChargeMode(), (_: any[]) => {
|
|
|
|
reloadGUI("BATTUnsetChargeMode");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{get_value(CHARGE_MODE_BATT) != null && <Field
|
|
|
|
label="Mode"
|
|
|
|
>
|
|
|
|
<Dropdown
|
|
|
|
menuLabel="Charge Mode"
|
|
|
|
rgOptions={chargeModeOptions}
|
|
|
|
selectedOption={chargeModeOptions.find((val: SingleDropdownOption, _index, _arr) => {
|
|
|
|
return val.data == get_value(CHARGE_MODE_BATT);
|
|
|
|
})}
|
|
|
|
strDefaultLabel={get_value(CHARGE_MODE_BATT)}
|
|
|
|
onChange={(elem: SingleDropdownOption) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Charge mode dropdown selected " + elem.data.toString());
|
2022-11-22 01:58:35 +00:00
|
|
|
backend.resolve(backend.setBatteryChargeMode(elem.data as string), (mode: string) => {
|
|
|
|
set_value(CHARGE_MODE_BATT, mode);
|
|
|
|
reloadGUI("BATTChargeMode");
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Field>}
|
|
|
|
</PanelSectionRow>}
|
2022-06-11 01:02:05 +01:00
|
|
|
<PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
<Field
|
|
|
|
label="Current"
|
|
|
|
onClick={()=> eggCount++}
|
|
|
|
focusable={false}>
|
|
|
|
{get_value(CURRENT_BATT)} mA
|
|
|
|
</Field>
|
2022-06-11 01:02:05 +01:00
|
|
|
</PanelSectionRow>
|
|
|
|
{/* Persistence */}
|
2022-09-01 01:18:15 +01:00
|
|
|
<div className={staticClasses.PanelSectionTitle}>
|
|
|
|
Miscellaneous
|
|
|
|
</div>
|
2022-06-11 01:02:05 +01:00
|
|
|
<PanelSectionRow>
|
2022-07-04 22:12:13 +01:00
|
|
|
<ToggleField
|
2022-09-01 01:18:15 +01:00
|
|
|
checked={get_value(PERSISTENT_GEN)}
|
2022-06-11 01:02:05 +01:00
|
|
|
label="Persistent"
|
2022-11-13 04:37:54 +00:00
|
|
|
description="Save profile and load it next time"
|
2022-06-11 01:02:05 +01:00
|
|
|
onChange={(persist: boolean) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Persist is now " + persist.toString());
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(
|
|
|
|
backend.setGeneralPersistent(persist),
|
|
|
|
(val: boolean) => {set_value(PERSISTENT_GEN, val)}
|
|
|
|
);
|
2022-06-11 01:02:05 +01:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</PanelSectionRow>
|
|
|
|
<PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
<Field
|
|
|
|
label="Profile"
|
|
|
|
onClick={()=> eggCount++}
|
|
|
|
focusable={false}>
|
|
|
|
{get_value(NAME_GEN)}
|
|
|
|
</Field>
|
2022-06-11 01:02:05 +01:00
|
|
|
</PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
{/* Version Info */}
|
2022-06-11 01:02:05 +01:00
|
|
|
<div className={staticClasses.PanelSectionTitle}>
|
2022-11-19 20:21:09 +00:00
|
|
|
{eggCount % 10 == 9 ? "Ha! Nerd" : "Debug"}
|
2022-06-11 01:02:05 +01:00
|
|
|
</div>
|
|
|
|
<PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
<Field
|
|
|
|
label={eggCount % 10 == 9 ? "PowerTools" : "Native"}
|
|
|
|
onClick={()=> {
|
|
|
|
if (eggCount % 10 == 9) {
|
|
|
|
// you know you're bored and/or conceited when you spend time adding an easter egg
|
|
|
|
// that just sends people to your own project's repo
|
|
|
|
Router.NavigateToExternalWeb("https://github.com/NGnius/PowerTools");
|
|
|
|
}
|
|
|
|
eggCount++;
|
|
|
|
}}>
|
|
|
|
{eggCount % 10 == 9 ? "by NGnius" : get_value(BACKEND_INFO)}
|
|
|
|
</Field>
|
2022-06-11 01:02:05 +01:00
|
|
|
</PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
<PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
<Field
|
|
|
|
label="Framework"
|
|
|
|
onClick={()=> eggCount++}>
|
|
|
|
{eggCount % 10 == 9 ? "<3 <3 <3" : target_usdpl()}
|
|
|
|
</Field>
|
2022-09-01 01:18:15 +01:00
|
|
|
</PanelSectionRow>
|
2023-01-03 02:22:53 +00:00
|
|
|
<PanelSectionRow>
|
|
|
|
<Field
|
|
|
|
label="Driver"
|
|
|
|
onClick={()=> eggCount++}>
|
|
|
|
{eggCount % 10 == 9 ? "Tracy Chapman" : get_value(DRIVER_INFO)}
|
|
|
|
</Field>
|
|
|
|
</PanelSectionRow>
|
2022-09-01 01:18:15 +01:00
|
|
|
<PanelSectionRow>
|
2022-11-19 20:21:09 +00:00
|
|
|
<Field
|
|
|
|
label="USDPL"
|
|
|
|
onClick={()=> {
|
|
|
|
if (eggCount % 10 == 9) {
|
|
|
|
// you know you're bored and/or conceited when you spend time adding an easter egg
|
|
|
|
// that just sends people to your own project's repo
|
|
|
|
Router.NavigateToExternalWeb("https://github.com/NGnius/usdpl-rs");
|
|
|
|
}
|
|
|
|
eggCount++;
|
|
|
|
}}>
|
|
|
|
v{version_usdpl()}
|
|
|
|
</Field>
|
2022-09-01 01:18:15 +01:00
|
|
|
</PanelSectionRow>
|
2022-11-21 22:00:43 +00:00
|
|
|
{eggCount % 10 == 9 && <PanelSectionRow>
|
|
|
|
<ButtonItem
|
|
|
|
layout="below"
|
|
|
|
onClick={(_: MouseEvent) => {
|
|
|
|
backend.idk();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
???
|
|
|
|
</ButtonItem>
|
|
|
|
</PanelSectionRow>}
|
2022-09-01 01:18:15 +01:00
|
|
|
<PanelSectionRow>
|
|
|
|
<ButtonItem
|
|
|
|
layout="below"
|
|
|
|
onClick={(_: MouseEvent) => {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Loading default PowerTools settings");
|
2022-09-01 01:18:15 +01:00
|
|
|
backend.resolve(
|
|
|
|
backend.setGeneralPersistent(false),
|
|
|
|
(val: boolean) => {
|
|
|
|
set_value(PERSISTENT_GEN, val);
|
2022-11-13 17:41:45 +00:00
|
|
|
backend.resolve(backend.loadGeneralSystemSettings(), (_) => {
|
2022-09-01 01:18:15 +01:00
|
|
|
reload();
|
2022-11-13 17:41:45 +00:00
|
|
|
backend.resolve(backend.waitForComplete(), (_) => {reloadGUI("LoadSystemDefaults")});
|
2022-09-01 01:18:15 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Defaults
|
|
|
|
</ButtonItem>
|
|
|
|
</PanelSectionRow>
|
2022-06-11 01:02:05 +01:00
|
|
|
</PanelSection>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default definePlugin((serverApi: ServerAPI) => {
|
|
|
|
return {
|
|
|
|
title: <div className={staticClasses.Title}>PowerTools</div>,
|
|
|
|
content: <Content serverAPI={serverApi} />,
|
2022-06-11 01:34:19 +01:00
|
|
|
icon: <GiDrill />,
|
2022-06-11 01:02:05 +01:00
|
|
|
onDismount() {
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "PowerTools shutting down");
|
2022-06-11 01:02:05 +01:00
|
|
|
clearInterval(periodicHook!);
|
2022-07-10 19:04:50 +01:00
|
|
|
periodicHook = null;
|
2022-07-05 23:14:50 +01:00
|
|
|
lifetimeHook!.unregister();
|
|
|
|
startHook!.unregister();
|
2022-06-11 01:02:05 +01:00
|
|
|
serverApi.routerHook.removeRoute("/decky-plugin-test");
|
2023-01-05 00:42:59 +00:00
|
|
|
backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, goodbye.");
|
2022-06-11 01:02:05 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|