From 589abcd416165827f935c49e5c05582b2c35e9eb Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Tue, 16 Mar 2010 17:13:25 +0000 Subject: Disable runtime estimation altogether when there is no runtime current defined. It doens't work and people somehow got confused by seeing obviously wrong values. Now it will just return -1 if you try to estimate runtime without having the current defined. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25222 a1c6a512-1295-4272-9138-f99709370657 --- firmware/powermgmt.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'firmware/powermgmt.c') diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index f8c3995e1a..f1dd83ef52 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -113,7 +113,10 @@ static long last_event_tick; static int voltage_to_battery_level(int battery_millivolts); static void battery_status_update(void); + +#ifdef CURRENT_NORMAL /*only used if we have run current*/ static int runcurrent(void); +#endif void battery_read_info(int *voltage, int *level) { @@ -272,6 +275,8 @@ static void battery_status_update(void) { int level = voltage_to_battery_level(battery_millivolts); +#ifdef CURRENT_NORMAL /*don't try to estimate run or charge + time without normal current defined*/ /* calculate estimated remaining running time */ #if CONFIG_CHARGING >= CHARGING_MONITOR if (charging_state()) { @@ -281,6 +286,7 @@ static void battery_status_update(void) } else #endif + /* discharging: remaining running time */ if (battery_millivolts > percent_to_volt_discharge[0][0]) { /* linear extrapolation */ @@ -290,6 +296,9 @@ static void battery_status_update(void) if (0 > powermgmt_est_runningtime_min) { powermgmt_est_runningtime_min = 0; } +#else + powermgmt_est_runningtime_min=-1; +#endif battery_percent = level; send_battery_level_event(); @@ -364,14 +373,14 @@ static void handle_auto_poweroff(void) } } +#ifdef CURRENT_NORMAL /*check that we have a current defined in a config file*/ + /* * Estimate how much current we are drawing just to run. */ static int runcurrent(void) { - int current; - - current = CURRENT_NORMAL; + int current = CURRENT_NORMAL; #ifndef BOOTLOADER if (usb_inserted() @@ -406,10 +415,11 @@ static int runcurrent(void) current += CURRENT_REMOTE; #endif #endif /* BOOTLOADER */ - + return current; } +#endif /* CURRENT_NORMAL */ /* Check to see whether or not we've received an alarm in the last second */ #ifdef HAVE_RTC_ALARM -- cgit