diff options
author | Brandon Low <lostlogic@rockbox.org> | 2006-03-02 13:37:51 +0000 |
---|---|---|
committer | Brandon Low <lostlogic@rockbox.org> | 2006-03-02 13:37:51 +0000 |
commit | 6d19a569be771c0ebe1f0adcdf28927bfff5681d (patch) | |
tree | b024e3501b62df5b27c5189a575a536b9c708324 /firmware/powermgmt.c | |
parent | 8d0a32eb4b4fd7108b9ebae81f93b3909c3e477f (diff) |
Improved battery status reporting for units which support usb power / charge
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8886 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r-- | firmware/powermgmt.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index b61aed7366..ff635486c1 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -353,7 +353,7 @@ static void battery_status_update(void) /* calculate estimated remaining running time */ /* discharging: remaining running time */ /* charging: remaining charging time */ -#ifdef HAVE_CHARGE_CTRL +#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE) if (charge_state == CHARGING) { powermgmt_est_runningtime_min = (100 - level) * battery_capacity / 100 * 60 / (CURRENT_MAX_CHG - runcurrent()); @@ -497,7 +497,11 @@ static void power_thread_sleep(int ticks) * loop (including the subroutines), and end up back here where we * transition to the appropriate steady state charger on/off state. */ - if(charger_inserted()) { + if(charger_inserted() +#ifdef HAVE_USB_POWER + || usb_powered() +#endif + ) { switch(charger_input_state) { case NO_CHARGER: case CHARGER_UNPLUGGED: @@ -572,6 +576,9 @@ static void power_thread_sleep(int ticks) */ battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000; + /* update battery status every time an update is available */ + battery_status_update(); + } #if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) @@ -628,9 +635,6 @@ static void power_thread(void) /* insert new value at the start, in centivolts 8-) */ power_history[0] = battery_centivolts; - /* update battery status every minute */ - battery_status_update(); - #if CONFIG_BATTERY == BATT_LIION2200 /* We use the information from the ADC_EXT_POWER ADC channel, which tells us the charging current from the LTC1734. When DC is |