1
0
Fork 0
forked from len0rd/rockbox

Report battery current on all X1000 native targets

This allows battery run time to be calculated from the
actual battery usage on the FiiO M3K and Shanling Q1.
This isn't very good for the time being and the estimate
tends to go all over the place due to small variations
in current or voltage.

The Eros Q can support this feature as well, but since
it already has fixed estimates defined and the quality
of the "real time" estimate is low I am not enabling it
there.

Change-Id: Id34a93ee4b7d66f9f7e56ef0f5149f67e8e72039
This commit is contained in:
Aidan MacDonald 2021-11-30 19:18:10 +00:00
parent fc678bd001
commit 1a313dc9bf
6 changed files with 33 additions and 3 deletions

View file

@ -83,7 +83,7 @@
#define STORAGE_NEEDS_BOUNCE_BUFFER
/* Power management */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CONFIG_BATTERY_MEASURE (VOLTAGE_MEASURE/*|CURRENT_MEASURE*/)
#define CONFIG_CHARGING CHARGING_MONITOR
#define HAVE_SW_POWEROFF

View file

@ -88,7 +88,7 @@
/* TODO: implement HAVE_RTC_ALARM */
/* Power management */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CONFIG_BATTERY_MEASURE (VOLTAGE_MEASURE|CURRENT_MEASURE)
#define CONFIG_CHARGING CHARGING_MONITOR
#define HAVE_SW_POWEROFF

View file

@ -76,7 +76,7 @@
/* TODO: implement HAVE_RTC_ALARM */
/* Power management */
#define CONFIG_BATTERY_MEASURE (VOLTAGE_MEASURE)
#define CONFIG_BATTERY_MEASURE (VOLTAGE_MEASURE|CURRENT_MEASURE)
#define CONFIG_CHARGING CHARGING_MONITOR
#define HAVE_SW_POWEROFF

View file

@ -111,3 +111,13 @@ int _battery_voltage(void)
{
return axp_adc_read(ADC_BATTERY_VOLTAGE);
}
#if CONFIG_BATTERY_MEASURE & CURRENT_MEASURE
int _battery_current(void)
{
if(charging_state())
return axp_adc_read(ADC_CHARGE_CURRENT);
else
return axp_adc_read(ADC_DISCHARGE_CURRENT);
}
#endif

View file

@ -106,3 +106,13 @@ int _battery_voltage(void)
{
return axp_adc_read(ADC_BATTERY_VOLTAGE);
}
#if CONFIG_BATTERY_MEASURE & CURRENT_MEASURE
int _battery_current(void)
{
if(charging_state())
return axp_adc_read(ADC_CHARGE_CURRENT);
else
return axp_adc_read(ADC_DISCHARGE_CURRENT);
}
#endif

View file

@ -121,6 +121,16 @@ int _battery_voltage(void)
return axp_adc_read(ADC_BATTERY_VOLTAGE);
}
#if CONFIG_BATTERY_MEASURE & CURRENT_MEASURE
int _battery_current(void)
{
if(charging_state())
return axp_adc_read(ADC_CHARGE_CURRENT);
else
return axp_adc_read(ADC_DISCHARGE_CURRENT);
}
#endif
#if defined(HAVE_CW2015) && (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) != 0
int _battery_level(void)
{