main: Add empty battery screen

This disables low battery monitor shutdown (LBM shutdown) on boot and checks if battery is enough.

The logic is as follows:

If battery is not enough:
- If not charging and 15s pass, it will re enable LBM shutdown and power off.
- If charging, it will wait until it is charged above the limit.
 Screen will auto turn off to save power. A press on Power button or a change on charger, will enable it for another 15s.

If battery is enough:
- Enables LBM shutdown and continues with the boot process.
This commit is contained in:
CTCaer
2020-04-06 05:54:45 +03:00
parent 52c506af9a
commit 5f142b4c86
7 changed files with 179 additions and 10 deletions

View File

@@ -169,9 +169,9 @@ void max77620_config_default()
_max77620_try_set_reg(MAX77620_REG_SD_CFG2, 4);
}
void max77620_low_battery_monitor_config()
void max77620_low_battery_monitor_config(bool enable)
{
_max77620_try_set_reg(MAX77620_REG_CNFGGLBL1,
MAX77620_CNFGGLBL1_LBDAC_EN | MAX77620_CNFGGLBL1_MPPLD |
MAX77620_CNFGGLBL1_LBDAC_EN | (enable ? MAX77620_CNFGGLBL1_MPPLD : 0) |
MAX77620_CNFGGLBL1_LBHYST_200 | MAX77620_CNFGGLBL1_LBDAC_2800);
}

View File

@@ -113,6 +113,6 @@ int max77620_regulator_set_voltage(u32 id, u32 mv);
int max77620_regulator_enable(u32 id, int enable);
int max77620_regulator_set_volt_and_flags(u32 id, u32 mv, u8 flags);
void max77620_config_default();
void max77620_low_battery_monitor_config();
void max77620_low_battery_monitor_config(bool enable);
#endif