summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-11-30 19:18:10 +0000
committerAidan MacDonald <amachronic@protonmail.com>2021-12-23 11:39:58 +0000
commit1a313dc9bff109d155e35bac79c475ea65198aea (patch)
tree034772dd7c6cbe3858fc1d3015256b69ad375bc5 /firmware
parentfc678bd001937f4a218e57db629c7dae8648bf4a (diff)
downloadrockbox-1a313dc9bff109d155e35bac79c475ea65198aea.tar.gz
rockbox-1a313dc9bff109d155e35bac79c475ea65198aea.zip
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/config/erosqnative.h2
-rw-r--r--firmware/export/config/fiiom3k.h2
-rw-r--r--firmware/export/config/shanlingq1.h2
-rw-r--r--firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c10
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c10
-rw-r--r--firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c10
6 files changed, 33 insertions, 3 deletions
diff --git a/firmware/export/config/erosqnative.h b/firmware/export/config/erosqnative.h
index f68830e211..17a2b250f2 100644
--- a/firmware/export/config/erosqnative.h
+++ b/firmware/export/config/erosqnative.h
@@ -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
diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h
index 61b6123a67..558ff41dd7 100644
--- a/firmware/export/config/fiiom3k.h
+++ b/firmware/export/config/fiiom3k.h
@@ -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
diff --git a/firmware/export/config/shanlingq1.h b/firmware/export/config/shanlingq1.h
index 16ce888958..18786e9a4b 100644
--- a/firmware/export/config/shanlingq1.h
+++ b/firmware/export/config/shanlingq1.h
@@ -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
diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
index 5573919aa2..a1a4d2c2b2 100644
--- a/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
+++ b/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c
@@ -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
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
index 5c92fa81e2..2d28ad0975 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
@@ -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
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c
index 17fbe1cede..75f8031dd9 100644
--- a/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c
+++ b/firmware/target/mips/ingenic_x1000/shanlingq1/power-shanlingq1.c
@@ -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)
{