This reverts commit b54252ccac, reversing
changes made to 96ff480607.
This commit is contained in:
souldbminersmwc
2025-11-12 18:41:37 -05:00
parent b54252ccac
commit d4fad33020
14 changed files with 2455 additions and 164 deletions

View File

@@ -207,12 +207,13 @@ void MiscGui::listUI()
this->listElement->addItem(new tsl::elm::CategoryHeader("Experimental"));
addConfigToggle(HocClkConfigValue_ThermalThrottle, nullptr);
addConfigToggle(HocClkConfigValue_HandheldTDP, nullptr);
addConfigToggle(HocClkConfigValue_EnforceBoardLimit, nullptr);
ValueThresholds tdpThresholds(8600, 9500);
addConfigButton(
HocClkConfigValue_HandheldTDPLimit,
"TDP Threshold",
ValueRange(5000, 10000, 100, "mW", 1),
ValueRange(5000, 10000, 200, "mW", 1),
"Power",
&tdpThresholds
);
@@ -221,7 +222,7 @@ void MiscGui::listUI()
addConfigButton(
HocClkConfigValue_LiteTDPLimit,
"Lite TDP Threshold",
ValueRange(4000, 8000, 100, "mW", 1),
ValueRange(4000, 8000, 200, "mW", 1),
"Power",
&tdpThresholdsLite
);
@@ -230,7 +231,7 @@ void MiscGui::listUI()
addConfigButton(
HocClkConfigValue_ThermalThrottleThreshold,
"Thermal Throttle Limit",
ValueRange(50, 85, 1, "°C", 1),
ValueRange(50, 85, 5, "°C", 1),
"Temp",
&throttleThresholds
);
@@ -244,6 +245,16 @@ void MiscGui::listUI()
addFreqButton(HocClkConfigValue_EristaMaxGpuClock, nullptr, SysClkModule_GPU);
addFreqButton(HocClkConfigValue_EristaMaxMemClock, nullptr, SysClkModule_MEM);
}
ValueThresholds emcUvThresholds(1212500, 1250000);
addConfigButton(
HocClkConfigValue_EMCVdd2VoltageUV,
"EMC VDD2 Voltage",
ValueRange(1100000, 1350000, 12500, "mV", 1000, 1),
"EMC VDD2 Voltage",
&emcUvThresholds
);
tsl::elm::ListItem* applyBtn = new tsl::elm::ListItem("Apply EMC Regs");
applyBtn->setClickListener([](u64 keys) {
if (keys & HidNpadButton_A) {

View File

@@ -1,145 +1,118 @@
/*
* 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 "value_choice_gui.h"
#include "../format.h"
#include "fatal_gui.h"
#include <sstream>
#include <iomanip>
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue,
const ValueRange& range,
const std::string& categoryName,
ValueChoiceListener listener,
const ValueThresholds& thresholds,
bool enableThresholds)
: selectedValue(selectedValue),
range(range),
categoryName(categoryName),
listener(listener),
thresholds(thresholds),
enableThresholds(enableThresholds)
{
}
#include "value_choice_gui.h"
#include "../format.h"
#include "fatal_gui.h"
#include <sstream>
#include <iomanip>
ValueChoiceGui::~ValueChoiceGui()
{
}
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue,
const ValueRange& range,
const std::string& categoryName,
ValueChoiceListener listener,
const ValueThresholds& thresholds,
bool enableThresholds)
: selectedValue(selectedValue),
range(range),
categoryName(categoryName),
listener(listener),
thresholds(thresholds),
enableThresholds(enableThresholds)
{
}
std::string ValueChoiceGui::formatValue(std::uint32_t value)
{
std::ostringstream oss;
ValueChoiceGui::~ValueChoiceGui()
{
}
if (value == 0) {
return VALUE_DEFAULT_TEXT;
}
std::string ValueChoiceGui::formatValue(std::uint32_t value)
{
std::ostringstream oss;
// Convert to floating point for division
double displayValue = static_cast<double>(value) / static_cast<double>(range.divisor);
if (value == 0) {
// Set precision and formatting
oss << std::fixed << std::setprecision(range.decimalPlaces) << displayValue;
if (!range.suffix.empty()) {
oss << " " << range.suffix;
}
return oss.str();
}
return VALUE_DEFAULT_TEXT;
}
int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
{
// if (!enableThresholds) {
// return 0;
// }
std::uint32_t displayValue = value / range.divisor;
std::uint32_t scaledValue = value / range.divisor;
oss << displayValue;
if (!range.suffix.empty()) {
oss << " " << range.suffix;
}
return oss.str();
}
if (value > thresholds.danger) {
return 2;
}
if (value > thresholds.warning) {
return 1;
}
return 0;
}
int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
{
if (!enableThresholds) {
return 0;
}
tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety)
{
std::string text = formatValue(value);
if (selected) {
text += " \uE14B";
}
std::uint32_t scaledValue = value / range.divisor;
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, "", false);
if (scaledValue > thresholds.danger) {
return 2;
}
if (scaledValue > thresholds.warning) {
return 1;
}
return 0;
}
switch (safety)
{
case 0:
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
break;
case 1:
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
break;
case 2:
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
break;
}
tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety)
{
std::string text = formatValue(value);
if (selected) {
text += " \uE14B";
}
listItem->setClickListener([this, value](u64 keys)
{
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
if (this->listener(value)) {
tsl::goBack();
}
return true;
}
return false;
});
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, "", false);
return listItem;
}
switch (safety)
{
case 0:
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
break;
case 1:
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
break;
case 2:
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
break;
}
void ValueChoiceGui::listUI()
{
if (!categoryName.empty()) {
this->listElement->addItem(new tsl::elm::CategoryHeader(categoryName));
}
listItem->setClickListener([this, value](u64 keys)
{
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
this->listElement->addItem(this->createValueListItem(0, this->selectedValue == 0, 0));
if (this->listener(value)) {
tsl::goBack();
}
return true;
}
return false;
});
for (std::uint32_t value = range.min; value <= range.max; value += range.step)
{
int safety = getSafetyLevel(value);
bool selected = (value == this->selectedValue);
this->listElement->addItem(this->createValueListItem(value, selected, safety));
}
return listItem;
}
void ValueChoiceGui::listUI()
{
if (!categoryName.empty()) {
this->listElement->addItem(new tsl::elm::CategoryHeader(categoryName));
}
this->listElement->addItem(this->createValueListItem(0, this->selectedValue == 0, 0));
for (std::uint32_t value = range.min; value <= range.max; value += range.step)
{
int safety = getSafetyLevel(value);
bool selected = (value == this->selectedValue);
this->listElement->addItem(this->createValueListItem(value, selected, safety));
}
this->listElement->jumpToItem("", "\uE14B");
}
this->listElement->jumpToItem("", "\uE14B");
}

View File

@@ -37,20 +37,20 @@
#define VALUE_DEFAULT_TEXT "Default"
struct ValueRange {
std::uint32_t min;
std::uint32_t max;
std::uint32_t step;
std::string suffix;
std::uint32_t divisor; // Divide input values by this for display
// Default constructor
ValueRange() : min(0), max(0), step(1), suffix(""), divisor(1) {}
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step,
const std::string& suffix = "", std::uint32_t divisor = 1)
: min(min), max(max), step(step), suffix(suffix), divisor(divisor) {}
};
std::uint32_t min;
std::uint32_t max;
std::uint32_t step;
std::string suffix;
std::uint32_t divisor; // Divide input values by this for display
int decimalPlaces; // Number of decimal places to display (0-6)
ValueRange() : min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {}
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step,
const std::string& suffix = "", std::uint32_t divisor = 1, int decimalPlaces = 0)
: min(min), max(max), step(step), suffix(suffix), divisor(divisor), decimalPlaces(decimalPlaces) {}
};
struct ValueThresholds {
std::uint32_t warning; // Values >= this show orange
std::uint32_t danger; // Values >= this show red