mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 13:45:03 -05:00
hosted: Consolidate the code that polls the battery charging status
affects all hiby targets, fiiom3k, and ibasso dx50/dx90 As well as deduplicating a small pile of code, this also implements hysteresis so we're not doing a sysfs read/lookup multiple times back-to-back every time the power management tick fires. Change-Id: I2f7672acbb36341becf67e07960c24c681270d09
This commit is contained in:
parent
b3b8310e4e
commit
555299af9f
19 changed files with 80 additions and 187 deletions
|
|
@ -35,28 +35,6 @@ const char * const sysfs_bat_voltage =
|
|||
const char * const sysfs_bat_capacity =
|
||||
"/sys/class/power_supply/battery/capacity";
|
||||
|
||||
const char * const sysfs_bat_status =
|
||||
"/sys/class/power_supply/battery/status";
|
||||
|
||||
const char * const sysfs_pow_supply =
|
||||
"/sys/class/power_supply/usb/present";
|
||||
|
||||
unsigned int xduoo_power_input_status(void)
|
||||
{
|
||||
int present = 0;
|
||||
sysfs_get_int(sysfs_pow_supply, &present);
|
||||
|
||||
return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
|
||||
}
|
||||
|
||||
bool xduoo_power_charging_status(void)
|
||||
{
|
||||
char buf[12] = {0};
|
||||
sysfs_get_string(sysfs_bat_status, buf, sizeof(buf));
|
||||
|
||||
return (strncmp(buf, "Charging", 8) == 0);
|
||||
}
|
||||
|
||||
unsigned int xduoo_power_get_battery_voltage(void)
|
||||
{
|
||||
int battery_voltage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue