mirror of
https://github.com/CTCaer/hekate.git
synced 2024-12-24 12:14:11 +00:00
hekate: fix a bug in low battery monitor
Do not try to deinit display if it's not enabled. Can happen if LBM disables display to reserve power while charging and user presses both VOL buttons to exit the mode.
This commit is contained in:
parent
0e526bf9e8
commit
3fa01a1975
@ -1211,6 +1211,7 @@ static void _check_low_battery()
|
||||
|
||||
enough_battery = charge_status ? 3250 : 3000;
|
||||
|
||||
// If battery voltage is enough, exit.
|
||||
if (batt_volt > enough_battery || !batt_volt)
|
||||
goto out;
|
||||
|
||||
@ -1243,6 +1244,7 @@ static void _check_low_battery()
|
||||
max17050_get_property(MAX17050_AvgVCELL, &batt_volt);
|
||||
enough_battery = current_charge_status ? 3250 : 3000;
|
||||
|
||||
// If battery voltage is enough, exit.
|
||||
if (batt_volt > enough_battery)
|
||||
break;
|
||||
|
||||
@ -1258,17 +1260,21 @@ static void _check_low_battery()
|
||||
// Check if it's time to turn off display.
|
||||
if (screen_on && timer < get_tmr_ms())
|
||||
{
|
||||
// If battery is not charging, power off.
|
||||
if (!current_charge_status)
|
||||
{
|
||||
max77620_low_battery_monitor_config(true);
|
||||
|
||||
// Handle full hw deinit and power off.
|
||||
power_set_state(POWER_OFF_RESET);
|
||||
}
|
||||
|
||||
// If charging, just disable display.
|
||||
display_end();
|
||||
screen_on = false;
|
||||
}
|
||||
|
||||
// Check if charging status changed or Power button was pressed.
|
||||
// Check if charging status changed or Power button was pressed and enable display.
|
||||
if ((charge_status != current_charge_status) || (btn_wait_timeout_single(0, BTN_POWER) & BTN_POWER))
|
||||
{
|
||||
if (!screen_on)
|
||||
@ -1299,7 +1305,8 @@ static void _check_low_battery()
|
||||
charge_status = current_charge_status;
|
||||
}
|
||||
|
||||
display_end();
|
||||
if (screen_on)
|
||||
display_end();
|
||||
|
||||
free(battery_icon);
|
||||
free(charging_icon);
|
||||
|
Loading…
Reference in New Issue
Block a user