From c1bd9b0361ba92c29ceef68d74093e70a1a3e481 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 3 Jan 2012 23:44:38 +0000 Subject: Rework powermgmt to enable code re-use on appliation and sims. * Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application) to break powermgmt.c's assumption about the ability to read battery voltage. There's now additionally percentage (android) and remaining time measure (maemo). No measure at all also works (sdl app). If voltage can't be measured, then battery_level() is king and it'll be used for power_history and runtime estimation. * Implement target's API in the simulator, i.e. _battery_voltage(), so it doesn't need to implement it's own powermgmt.c and other stubs. Now the sim behaves much more like a native target, although it still changes the simulated battery voltage quickly, * Other changes include include renaming battery_adc_voltage() to _battery_voltage(), for consistency with the new target functions and making some of the apps code aware that voltage and runtime estimation is not always available. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/powermgmt.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'firmware/export/powermgmt.h') diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 837767f56b..9e9d3d0fd8 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -78,8 +78,6 @@ extern unsigned int power_thread_inputs; /* Start up power management thread */ void powermgmt_init(void) INIT_ATTR; -#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) - /* Generic current values that are intentionally meaningless - config header * should define proper numbers.*/ @@ -130,13 +128,18 @@ extern const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11]; extern const unsigned short percent_to_volt_charge[11]; #endif -#endif /* PLATFORM_NATIVE */ - -/* Returns battery statust */ +/* Returns battery status, filtered for runtime estimation */ int battery_level(void); /* percent */ int battery_time(void); /* minutes */ -unsigned int battery_adc_voltage(void); /* voltage from ADC in millivolts */ -unsigned int battery_voltage(void); /* filtered batt. voltage in millivolts */ +int battery_voltage(void); /* filtered batt. voltage in millivolts */ + +/* Implemented by the target, unfiltered */ +int _battery_level(void); /* percent */ +int _battery_time(void); /* minutes */ +int _battery_voltage(void); /* voltage in millivolts */ +#if CONFIG_CHARGING >= CHARGING_TARGET +void powermgmt_init_target(void); +#endif #ifdef HAVE_BATTERY_SWITCH unsigned int input_millivolts(void); /* voltage that device is running from */ -- cgit v1.2.3