sysclk: refinements to pwm dimming
This commit is contained in:
@@ -652,6 +652,12 @@ protected:
|
|||||||
}
|
}
|
||||||
if(IsAula()) {
|
if(IsAula()) {
|
||||||
addConfigToggle(HorizonOCConfigValue_PWMDimming, nullptr);
|
addConfigToggle(HorizonOCConfigValue_PWMDimming, nullptr);
|
||||||
|
tsl::elm::CustomDrawer* sleepWakeInfo = new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *renderer, s32 x, s32 y, s32 w, s32 h) {
|
||||||
|
renderer->drawString("\uE152 Changing this setting", false, x + 20, y + 30, 18, tsl::style::color::ColorText);
|
||||||
|
renderer->drawString("requires a sleep/wake or", false, x + 20, y + 50, 18, tsl::style::color::ColorText);
|
||||||
|
renderer->drawString("a reboot", false, x + 20, y + 70, 18, tsl::style::color::ColorText);
|
||||||
|
});
|
||||||
|
sleepWakeInfo->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, 90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -676,7 +682,7 @@ protected:
|
|||||||
ValueThresholds tdpThresholdsLite(6400, 7500);
|
ValueThresholds tdpThresholdsLite(6400, 7500);
|
||||||
addConfigButton(
|
addConfigButton(
|
||||||
HocClkConfigValue_LiteTDPLimit,
|
HocClkConfigValue_LiteTDPLimit,
|
||||||
"TDP Threshold",
|
"TDP Threshold",e
|
||||||
ValueRange(4000, 8000, 100, "mW", 1),
|
ValueRange(4000, 8000, 100, "mW", 1),
|
||||||
"Power",
|
"Power",
|
||||||
&tdpThresholdsLite,
|
&tdpThresholdsLite,
|
||||||
|
|||||||
@@ -595,28 +595,6 @@ void ClockManager::HandleSafetyFeatures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClockManager::HandleMiscFeatures() {
|
void ClockManager::HandleMiscFeatures() {
|
||||||
static u32 prevBrightness = 100;
|
|
||||||
static bool wasPWMDimEnabled = false;
|
|
||||||
if(Board::GetConsoleType() == HorizonOCConsoleType_Aula && this->config->GetConfigValue(HorizonOCConfigValue_PWMDimming)) {
|
|
||||||
float out = 1.0;
|
|
||||||
Result rc = lblGetCurrentBrightnessSetting(&out);
|
|
||||||
ASSERT_RESULT_OK(rc, "lblGetCurrentBrightnessSetting");
|
|
||||||
u32 brightness = (u32)(out * 100);
|
|
||||||
Board::SetPWMDimEnabled(true);
|
|
||||||
Board::SetPWMDimBrightness(prevBrightness, brightness, true);
|
|
||||||
prevBrightness = brightness;
|
|
||||||
wasPWMDimEnabled = true;
|
|
||||||
} else if (Board::GetConsoleType() == HorizonOCConsoleType_Aula && wasPWMDimEnabled) {
|
|
||||||
Board::SetPWMDimEnabled(false);
|
|
||||||
Board::SetPWMDimBrightness(0, 0, false);
|
|
||||||
float out = 1.0;
|
|
||||||
Result rc = lblGetCurrentBrightnessSetting(&out);
|
|
||||||
ASSERT_RESULT_OK(rc, "lblGetCurrentBrightnessSetting");
|
|
||||||
rc = lblSetCurrentBrightnessSetting(out);
|
|
||||||
ASSERT_RESULT_OK(rc, "lblSetCurrentBrightnessSetting");
|
|
||||||
wasPWMDimEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)) {
|
if(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)) {
|
||||||
I2c_Bq24193_SetFastChargeCurrentLimit(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent));
|
I2c_Bq24193_SetFastChargeCurrentLimit(this->config->GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent));
|
||||||
}
|
}
|
||||||
@@ -767,6 +745,32 @@ void ClockManager::HandleFreqReset(SysClkModule module, bool isBoost) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClockManager::HandlePWMDimming() {
|
||||||
|
static u32 prevBrightness = 100;
|
||||||
|
static bool wasPWMDimEnabled = false;
|
||||||
|
static u32 tick = 0;
|
||||||
|
tick++;
|
||||||
|
if(tick > 50) {
|
||||||
|
if(this->config->GetConfigValue(HorizonOCConfigValue_PWMDimming)) {
|
||||||
|
float out = 1.0;
|
||||||
|
Result rc = lblGetCurrentBrightnessSetting(&out);
|
||||||
|
ASSERT_RESULT_OK(rc, "lblGetCurrentBrightnessSetting");
|
||||||
|
u32 brightness = (u32)(out * 100);
|
||||||
|
Board::SetPWMDimEnabled(true);
|
||||||
|
Board::SetPWMDimBrightness(prevBrightness, brightness, false);
|
||||||
|
prevBrightness = brightness;
|
||||||
|
wasPWMDimEnabled = true;
|
||||||
|
|
||||||
|
} else if (wasPWMDimEnabled) {
|
||||||
|
Board::SetPWMDimEnabled(false);
|
||||||
|
Board::SetPWMDimBrightness(0, 0, false);
|
||||||
|
|
||||||
|
wasPWMDimEnabled = false;
|
||||||
|
}
|
||||||
|
tick = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ClockManager::SetClocks(bool isBoost) {
|
void ClockManager::SetClocks(bool isBoost) {
|
||||||
std::uint32_t targetHz = 0;
|
std::uint32_t targetHz = 0;
|
||||||
std::uint32_t maxHz = 0;
|
std::uint32_t maxHz = 0;
|
||||||
@@ -875,6 +879,9 @@ void ClockManager::Tick()
|
|||||||
|
|
||||||
HandleSafetyFeatures();
|
HandleSafetyFeatures();
|
||||||
|
|
||||||
|
if(Board::GetConsoleType() == HorizonOCConsoleType_Aula)
|
||||||
|
HandlePWMDimming();
|
||||||
|
|
||||||
if (this->RefreshContext() || this->config->Refresh())
|
if (this->RefreshContext() || this->config->Refresh())
|
||||||
{
|
{
|
||||||
HandleMiscFeatures();
|
HandleMiscFeatures();
|
||||||
|
|||||||
@@ -140,7 +140,11 @@ class ClockManager
|
|||||||
* @param isBoost Is in boost mode
|
* @param isBoost Is in boost mode
|
||||||
*/
|
*/
|
||||||
void SetClocks(bool isBoost);
|
void SetClocks(bool isBoost);
|
||||||
|
/**
|
||||||
|
* Handle PWM dimming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void HandlePWMDimming();
|
||||||
/**
|
/**
|
||||||
* Main function, runs every 5s in sleep mode, and a user specified amount when awake
|
* Main function, runs every 5s in sleep mode, and a user specified amount when awake
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user