Sys-clk-OC: remove temp. charging toggle, add charging limiter

This commit is contained in:
KazushiM
2022-10-01 20:40:54 +08:00
parent ff0dcb5ece
commit 1063022b65
8 changed files with 106 additions and 84 deletions

View File

@@ -358,22 +358,22 @@ void ClockManager::ChargingHandler()
serviceDispatch(session, fastChargingConfig ? EnableFastBatteryCharging : DisableFastBatteryCharging);
}
// bool isChargerConnected = (chargeInfoField->ChargerType != ChargerType_None);
// if (isChargerConnected)
// {
// u32 chargeNow = 0;
// if (R_SUCCEEDED(psmGetBatteryChargePercentage(&chargeNow)))
// {
// bool isCharging = ((chargeInfoField->unk_x14 >> 8) & 1);
// u32 chargeLimit = this->GetConfig()->GetConfigValue(SysClkConfigValue_ChargingLimitPercentage);
// if (isCharging && chargeLimit < chargeNow) {
// serviceDispatch(session, DisableBatteryCharging);
// } else if (!isCharging && chargeNow < 100 && chargeLimit > chargeNow) {
// serviceDispatch(session, EnableBatteryCharging);
// }
// }
// }
u32 chargeLimit = this->GetConfig()->GetConfigValue(SysClkConfigValue_ChargingLimitPercentage);
bool isChargerConnected = (chargeInfoField->ChargerType != ChargerType_None);
if (isChargerConnected)
{
u32 chargeNow = 0;
if (R_SUCCEEDED(psmGetBatteryChargePercentage(&chargeNow)))
{
bool isCharging = ((chargeInfoField->unk_x14 >> 8) & 1);
if (isCharging && chargeLimit < chargeNow) {
serviceDispatch(session, DisableBatteryCharging);
}
if (!isCharging && chargeLimit > chargeNow) {
serviceDispatch(session, EnableBatteryCharging);
}
}
}
delete chargeInfoField;
psmExit();