1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michael Giacomelli 2010-03-16 17:13:25 +00:00
parent 3b5418e814
commit 589abcd416
2 changed files with 15 additions and 9 deletions

View file

@ -77,12 +77,8 @@ extern unsigned int power_thread_inputs;
#ifndef SIMULATOR #ifndef SIMULATOR
/* Generic current values that are intentionally meaningless - config header /* Generic current values that are intentionally meaningless - config header
* should define proper numbers. Use insane values here to remind people * should define proper numbers.*/
* to define the correct values in the proper header*/
#ifndef CURRENT_NORMAL
#define CURRENT_NORMAL 5 /* usual current in mA */
#endif
#ifndef CURRENT_BACKLIGHT #ifndef CURRENT_BACKLIGHT
#define CURRENT_BACKLIGHT 5 /* additional current when backlight always on */ #define CURRENT_BACKLIGHT 5 /* additional current when backlight always on */

View file

@ -113,7 +113,10 @@ static long last_event_tick;
static int voltage_to_battery_level(int battery_millivolts); static int voltage_to_battery_level(int battery_millivolts);
static void battery_status_update(void); static void battery_status_update(void);
#ifdef CURRENT_NORMAL /*only used if we have run current*/
static int runcurrent(void); static int runcurrent(void);
#endif
void battery_read_info(int *voltage, int *level) 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); 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 */ /* calculate estimated remaining running time */
#if CONFIG_CHARGING >= CHARGING_MONITOR #if CONFIG_CHARGING >= CHARGING_MONITOR
if (charging_state()) { if (charging_state()) {
@ -281,6 +286,7 @@ static void battery_status_update(void)
} }
else else
#endif #endif
/* discharging: remaining running time */ /* discharging: remaining running time */
if (battery_millivolts > percent_to_volt_discharge[0][0]) { if (battery_millivolts > percent_to_volt_discharge[0][0]) {
/* linear extrapolation */ /* linear extrapolation */
@ -290,6 +296,9 @@ static void battery_status_update(void)
if (0 > powermgmt_est_runningtime_min) { if (0 > powermgmt_est_runningtime_min) {
powermgmt_est_runningtime_min = 0; powermgmt_est_runningtime_min = 0;
} }
#else
powermgmt_est_runningtime_min=-1;
#endif
battery_percent = level; battery_percent = level;
send_battery_level_event(); 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. * Estimate how much current we are drawing just to run.
*/ */
static int runcurrent(void) static int runcurrent(void)
{ {
int current; int current = CURRENT_NORMAL;
current = CURRENT_NORMAL;
#ifndef BOOTLOADER #ifndef BOOTLOADER
if (usb_inserted() if (usb_inserted()
@ -410,6 +419,7 @@ static int runcurrent(void)
return current; return current;
} }
#endif /* CURRENT_NORMAL */
/* Check to see whether or not we've received an alarm in the last second */ /* Check to see whether or not we've received an alarm in the last second */
#ifdef HAVE_RTC_ALARM #ifdef HAVE_RTC_ALARM