sysclk: finish display refresh rate change support
This commit is contained in:
@@ -28,7 +28,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#define FREQ_DEFAULT_TEXT "Default"
|
||||
|
||||
static inline std::string formatListFreqMHz(std::uint32_t mhz)
|
||||
|
||||
@@ -67,6 +67,32 @@ void AppProfileGui::openFreqChoiceGui(tsl::elm::ListItem* listItem, SysClkProfil
|
||||
);
|
||||
}
|
||||
|
||||
void AppProfileGui::openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
)
|
||||
{
|
||||
tsl::changeTo<ValueChoiceGui>(
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
listener,
|
||||
thresholds,
|
||||
enableThresholds,
|
||||
labels,
|
||||
namedValues,
|
||||
showDefaultValue
|
||||
);
|
||||
}
|
||||
|
||||
void AppProfileGui::addModuleListItem(SysClkProfile profile, SysClkModule module)
|
||||
{
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
@@ -83,7 +109,6 @@ void AppProfileGui::addModuleListItem(SysClkProfile profile, SysClkModule module
|
||||
this->profileList->mhzMap[profile][module] = 0;
|
||||
listItem->setValue(formatListFreqMHz(0));
|
||||
|
||||
// Save the updated profile
|
||||
Result rc = sysclkIpcSetProfiles(this->applicationId, this->profileList);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
@@ -117,12 +142,137 @@ void AppProfileGui::addModuleListItemToggle(SysClkProfile profile, SysClkModule
|
||||
this->listElement->addItem(toggle);
|
||||
}
|
||||
|
||||
void AppProfileGui::addModuleListItemValue(
|
||||
SysClkProfile profile,
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
)
|
||||
{
|
||||
tsl::elm::ListItem* listItem =
|
||||
new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
|
||||
std::uint32_t storedValue = this->profileList->mhzMap[profile][module];
|
||||
if (storedValue == 0) {
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
} else {
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)storedValue / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s", decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s", storedValue / divisor, suffix.c_str());
|
||||
}
|
||||
listItem->setValue(buf);
|
||||
}
|
||||
|
||||
listItem->setClickListener(
|
||||
[this,
|
||||
listItem,
|
||||
profile,
|
||||
module,
|
||||
categoryName,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A)
|
||||
{
|
||||
std::uint32_t currentValue =
|
||||
this->profileList->mhzMap[profile][module] * divisor;
|
||||
|
||||
ValueRange range(
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces
|
||||
);
|
||||
|
||||
this->openValueChoiceGui(
|
||||
listItem,
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
|
||||
[this, listItem, profile, module, divisor, suffix, decimalPlaces](std::uint32_t value) -> bool
|
||||
{
|
||||
this->profileList->mhzMap[profile][module] = value / divisor;
|
||||
|
||||
if (value == 0) {
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
} else {
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)value / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s",
|
||||
decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s",
|
||||
value / divisor, suffix.c_str());
|
||||
}
|
||||
listItem->setValue(buf);
|
||||
}
|
||||
|
||||
Result rc =
|
||||
sysclkIpcSetProfiles(this->applicationId,
|
||||
this->profileList);
|
||||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode(
|
||||
"sysclkIpcSetProfiles", rc);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
ValueThresholds(),
|
||||
false
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if ((keys & HidNpadButton_Y) == HidNpadButton_Y)
|
||||
{
|
||||
this->profileList->mhzMap[profile][module] = 0;
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
|
||||
Result rc =
|
||||
sysclkIpcSetProfiles(this->applicationId,
|
||||
this->profileList);
|
||||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this->listElement->addItem(listItem);
|
||||
}
|
||||
|
||||
void AppProfileGui::addProfileUI(SysClkProfile profile)
|
||||
{
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(sysclkFormatProfile(profile, true) + std::string(" ") + ult::DIVIDER_SYMBOL + " Reset"));
|
||||
this->addModuleListItem(profile, SysClkModule_CPU);
|
||||
this->addModuleListItem(profile, SysClkModule_GPU);
|
||||
this->addModuleListItem(profile, SysClkModule_MEM);
|
||||
this->addModuleListItemValue(profile, HorizonOCModule_Display, "Display", 40, 60, 5, " Hz", 1, 0);
|
||||
this->addModuleListItemToggle(profile, HorizonOCModule_Governor);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
#define SYSCLK_GLOBAL_PROFILE_TID 0xA111111111111111
|
||||
|
||||
class AppProfileGui : public BaseMenuGui
|
||||
@@ -41,6 +42,29 @@ class AppProfileGui : public BaseMenuGui
|
||||
void openFreqChoiceGui(tsl::elm::ListItem* listItem, SysClkProfile profile, SysClkModule module);
|
||||
void addModuleListItem(SysClkProfile profile, SysClkModule module);
|
||||
void addModuleListItemToggle(SysClkProfile profile, SysClkModule module);
|
||||
void openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds = ValueThresholds(),
|
||||
bool enableThresholds = false,
|
||||
const std::map<std::uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
void addModuleListItemValue(
|
||||
SysClkProfile profile,
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
);
|
||||
void addProfileUI(SysClkProfile profile);
|
||||
|
||||
public:
|
||||
|
||||
@@ -56,7 +56,7 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
|
||||
// All constants pre-calculated and cached
|
||||
static constexpr const char* const labels[] = {
|
||||
"App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "BAT", "PMIC", "FAN"
|
||||
"App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "BAT", "PMIC", "FAN", "DISP"
|
||||
};
|
||||
|
||||
static constexpr u32 dataPositions[6] = {63-3+3, 200-1, 344-1-3, 200-1, 342-1, 321-1};
|
||||
@@ -163,6 +163,10 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
|
||||
renderer->drawString(displayStrings[24], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // fan speed
|
||||
|
||||
renderer->drawString(labels[13], false, positions[7], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // fan label
|
||||
|
||||
renderer->drawString(displayStrings[25], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // fan speed
|
||||
|
||||
}
|
||||
|
||||
// Optimized refresh - now does all the string formatting once per second
|
||||
@@ -268,6 +272,8 @@ void BaseMenuGui::refresh()
|
||||
|
||||
sprintf(displayStrings[24], "%u%%", context->PartLoad[HocClkPartLoad_FAN]);
|
||||
|
||||
sprintf(displayStrings[25], "%u Hz", context->realFreqs[HorizonOCModule_Display]);
|
||||
|
||||
}
|
||||
|
||||
tsl::elm::Element* BaseMenuGui::baseUI()
|
||||
|
||||
@@ -1,39 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "global_override_gui.h"
|
||||
|
||||
#include "fatal_gui.h"
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
#include "global_override_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
|
||||
GlobalOverrideGui::GlobalOverrideGui()
|
||||
{
|
||||
for(std::uint16_t m = 0; m < SysClkModule_EnumMax; m++)
|
||||
{
|
||||
for (std::uint16_t m = 0; m < SysClkModule_EnumMax; m++) {
|
||||
this->listItems[m] = nullptr;
|
||||
this->listHz[m] = 0;
|
||||
}
|
||||
@@ -43,16 +15,17 @@ void GlobalOverrideGui::openFreqChoiceGui(SysClkModule module)
|
||||
{
|
||||
std::uint32_t hzList[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t hzCount;
|
||||
Result rc = sysclkIpcGetFreqList(module, &hzList[0], SYSCLK_FREQ_LIST_MAX, &hzCount);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
Result rc =
|
||||
sysclkIpcGetFreqList(module, &hzList[0], SYSCLK_FREQ_LIST_MAX, &hzCount);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetFreqList", rc);
|
||||
return;
|
||||
}
|
||||
tsl::changeTo<FreqChoiceGui>(this->context->overrideFreqs[module], hzList, hzCount, module, [this, module](std::uint32_t hz) {
|
||||
tsl::changeTo<FreqChoiceGui>(
|
||||
this->context->overrideFreqs[module], hzList, hzCount, module,
|
||||
[this, module](std::uint32_t hz) {
|
||||
Result rc = sysclkIpcSetOverride(module, hz);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
@@ -61,78 +34,228 @@ void GlobalOverrideGui::openFreqChoiceGui(SysClkModule module)
|
||||
this->context->overrideFreqs[module] = hz;
|
||||
|
||||
return true;
|
||||
}, true);
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
)
|
||||
{
|
||||
tsl::changeTo<ValueChoiceGui>(
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
listener,
|
||||
thresholds,
|
||||
enableThresholds,
|
||||
labels,
|
||||
namedValues,
|
||||
showDefaultValue
|
||||
);
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::addModuleListItemValue(
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
)
|
||||
{
|
||||
|
||||
this->customFormatModules[module] = std::make_tuple(suffix, divisor, decimalPlaces);
|
||||
|
||||
tsl::elm::ListItem* listItem =
|
||||
new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
|
||||
listItem->setClickListener(
|
||||
[this,
|
||||
listItem,
|
||||
module,
|
||||
categoryName,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A)
|
||||
{
|
||||
if (!this->context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint32_t currentValue =
|
||||
this->context->overrideFreqs[module] * divisor;
|
||||
|
||||
ValueRange range(
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces
|
||||
);
|
||||
|
||||
this->openValueChoiceGui(
|
||||
listItem,
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
|
||||
[this, listItem, module, divisor, suffix, decimalPlaces](std::uint32_t value) -> bool
|
||||
{
|
||||
if (!this->context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->context->overrideFreqs[module] = value / divisor;
|
||||
this->listHz[module] = value / divisor;
|
||||
|
||||
if (value == 0) {
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
} else {
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)value / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s",
|
||||
decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s",
|
||||
value / divisor, suffix.c_str());
|
||||
}
|
||||
listItem->setValue(buf);
|
||||
}
|
||||
|
||||
Result rc =
|
||||
sysclkIpcSetOverride(module, this->context->overrideFreqs[module]);
|
||||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode(
|
||||
"sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
},
|
||||
|
||||
ValueThresholds(),
|
||||
false,
|
||||
std::map<std::uint32_t, std::string>(),
|
||||
std::vector<NamedValue>(),
|
||||
true
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if ((keys & HidNpadButton_Y) == HidNpadButton_Y)
|
||||
{
|
||||
if (!this->context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->context->overrideFreqs[module] = 0;
|
||||
this->listHz[module] = 0;
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
|
||||
Result rc = sysclkIpcSetOverride(module, 0);
|
||||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this->listElement->addItem(listItem);
|
||||
this->listItems[module] = listItem;
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::addModuleListItem(SysClkModule module)
|
||||
{
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
tsl::elm::ListItem *listItem =
|
||||
new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
listItem->setValue(formatListFreqMHz(0));
|
||||
listItem->setClickListener([this, module](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A) {
|
||||
this->openFreqChoiceGui(module);
|
||||
return true;
|
||||
}
|
||||
else if((keys & HidNpadButton_Y) == HidNpadButton_Y)
|
||||
{
|
||||
// Reset override to "Default" (0 Hz)
|
||||
} else if ((keys & HidNpadButton_Y) == HidNpadButton_Y) {
|
||||
Result rc = sysclkIpcSetOverride(module, 0);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update context and tracking variables
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
this->context->overrideFreqs[module] = 0;
|
||||
this->listHz[module] = 0;
|
||||
|
||||
// Update display
|
||||
|
||||
this->listItems[module]->setValue(formatListFreqHz(0));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
this->listElement->addItem(listItem);
|
||||
this->listItems[module] = listItem;
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::addModuleToggleItem(SysClkModule module)
|
||||
{
|
||||
const char* moduleName = sysclkFormatModule(module, true);
|
||||
const char *moduleName = sysclkFormatModule(module, true);
|
||||
bool isOn = this->listHz[module];
|
||||
|
||||
// Create a ToggleListItem
|
||||
tsl::elm::ToggleListItem* toggle = new tsl::elm::ToggleListItem(moduleName, isOn);
|
||||
|
||||
toggle->setStateChangedListener([this, module, toggle](bool state) {
|
||||
|
||||
tsl::elm::ToggleListItem *toggle =
|
||||
new tsl::elm::ToggleListItem(moduleName, isOn);
|
||||
|
||||
toggle->setStateChangedListener([this, module, toggle](bool state) {
|
||||
Result rc = sysclkIpcSetOverride(module, state ? 1 : 0);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
}
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
this->context->overrideFreqs[module] = 0;
|
||||
this->listHz[module] = 0;
|
||||
|
||||
});
|
||||
// Add to list and track
|
||||
this->listElement->addItem(toggle);
|
||||
this->listItems[module] = toggle;
|
||||
}
|
||||
|
||||
|
||||
void GlobalOverrideGui::listUI()
|
||||
{
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Temporary Overrides " + ult::DIVIDER_SYMBOL + " Reset"));
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(
|
||||
"Temporary Overrides " + ult::DIVIDER_SYMBOL + " Reset"));
|
||||
this->addModuleListItem(SysClkModule_CPU);
|
||||
this->addModuleListItem(SysClkModule_GPU);
|
||||
this->addModuleListItem(SysClkModule_MEM);
|
||||
this->addModuleListItemValue(HorizonOCModule_Display, "Display", 40, 60, 5, " Hz", 1, 0);
|
||||
this->addModuleToggleItem(HorizonOCModule_Governor);
|
||||
}
|
||||
|
||||
@@ -143,18 +266,16 @@ void GlobalOverrideGui::refresh()
|
||||
if (!this->context)
|
||||
return;
|
||||
|
||||
for (std::uint16_t m = 0; m < SysClkModule_EnumMax; m++)
|
||||
{
|
||||
if (m == HorizonOCModule_Governor)
|
||||
{
|
||||
auto* toggle = static_cast<tsl::elm::ToggleListItem*>(this->listItems[m]);
|
||||
for (std::uint16_t m = 0; m < SysClkModule_EnumMax; m++) {
|
||||
if (m == HorizonOCModule_Governor) {
|
||||
auto *toggle =
|
||||
static_cast<tsl::elm::ToggleListItem *>(this->listItems[m]);
|
||||
if (!toggle)
|
||||
continue;
|
||||
|
||||
bool newState = this->context->overrideFreqs[m] != 0;
|
||||
|
||||
if (toggle->getState() != newState)
|
||||
{
|
||||
if (toggle->getState() != newState) {
|
||||
toggle->setState(newState);
|
||||
}
|
||||
|
||||
@@ -162,11 +283,33 @@ void GlobalOverrideGui::refresh()
|
||||
}
|
||||
|
||||
if (this->listItems[m] != nullptr &&
|
||||
this->listHz[m] != this->context->overrideFreqs[m])
|
||||
{
|
||||
this->listItems[m]->setValue(
|
||||
formatListFreqHz(this->context->overrideFreqs[m])
|
||||
);
|
||||
this->listHz[m] != this->context->overrideFreqs[m]) {
|
||||
|
||||
auto it = this->customFormatModules.find((SysClkModule)m);
|
||||
if (it != this->customFormatModules.end()) {
|
||||
std::string suffix = std::get<0>(it->second);
|
||||
std::uint32_t divisor = std::get<1>(it->second);
|
||||
int decimalPlaces = std::get<2>(it->second);
|
||||
|
||||
if (this->context->overrideFreqs[m] == 0) {
|
||||
this->listItems[m]->setValue(FREQ_DEFAULT_TEXT);
|
||||
} else {
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)this->context->overrideFreqs[m] / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s",
|
||||
decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s",
|
||||
this->context->overrideFreqs[m] / divisor, suffix.c_str());
|
||||
}
|
||||
this->listItems[m]->setValue(buf);
|
||||
}
|
||||
} else {
|
||||
this->listItems[m]->setValue(
|
||||
formatListFreqHz(this->context->overrideFreqs[m]));
|
||||
}
|
||||
|
||||
this->listHz[m] = this->context->overrideFreqs[m];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,19 +30,44 @@
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
|
||||
#include <string>
|
||||
#include "value_choice_gui.h"
|
||||
class GlobalOverrideGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
std::map<SysClkModule, std::tuple<std::string, std::uint32_t, int>> customFormatModules;
|
||||
tsl::elm::ListItem* listItems[SysClkModule_EnumMax];
|
||||
std::uint32_t listHz[SysClkModule_EnumMax];
|
||||
bool isGovernorEnabled;
|
||||
void openFreqChoiceGui(SysClkModule module);
|
||||
void addModuleListItem(SysClkModule module);
|
||||
void addModuleToggleItem(SysClkModule module);
|
||||
void openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
);
|
||||
void addModuleListItemValue(
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
);
|
||||
public:
|
||||
GlobalOverrideGui();
|
||||
~GlobalOverrideGui() {}
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
void setModuleCustomFormat(SysClkModule module, const std::string& suffix, std::uint32_t divisor, int decimalPlaces);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user