summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-02 13:37:51 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-02 13:37:51 +0000
commit6d19a569be771c0ebe1f0adcdf28927bfff5681d (patch)
treeb024e3501b62df5b27c5189a575a536b9c708324
parent8d0a32eb4b4fd7108b9ebae81f93b3909c3e477f (diff)
downloadrockbox-6d19a569be771c0ebe1f0adcdf28927bfff5681d.tar.gz
rockbox-6d19a569be771c0ebe1f0adcdf28927bfff5681d.zip
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
-rw-r--r--apps/gui/statusbar.c17
-rw-r--r--firmware/drivers/power.c3
-rw-r--r--firmware/powermgmt.c14
3 files changed, 18 insertions, 16 deletions
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index 34ac5283af..8acfd1ca7f 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -185,7 +185,6 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
CONFIG_BATTERY == BATT_LIION2200
/* zero battery run time if charging */
if (charge_state > DISCHARGING) {
- global_settings.runtime = 0;
lasttime = current_tick;
}
@@ -196,7 +195,6 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#endif
) {
#else
- global_settings.runtime = 0;
lasttime = current_tick;
{
#endif
@@ -227,19 +225,20 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#ifdef HAVE_LCD_BITMAP
if (battery_state)
gui_statusbar_icon_battery(display, bar->info.battlevel);
- /* draw power plug if charging */
- if (bar->info.inserted)
- display->mono_bitmap(bitmap_icons_7x8[Icon_Plug],
- STATUSBAR_PLUG_X_POS,
- STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH,
- STATUSBAR_HEIGHT);
#ifdef HAVE_USB_POWER
- else if (bar->info.usb_power)
+ if (bar->info.usb_power)
display->mono_bitmap(bitmap_icons_7x8[Icon_USBPlug],
STATUSBAR_PLUG_X_POS,
STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH,
STATUSBAR_HEIGHT);
+ else
#endif /* HAVE_USB_POWER */
+ /* draw power plug if charging */
+ if (bar->info.inserted)
+ display->mono_bitmap(bitmap_icons_7x8[Icon_Plug],
+ STATUSBAR_PLUG_X_POS,
+ STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH,
+ STATUSBAR_HEIGHT);
bar->info.redraw_volume = gui_statusbar_icon_volume(bar,
bar->info.volume);
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index b62121298d..c6d49f5aa9 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -120,8 +120,7 @@ bool charger_inserted(void)
return adc_read(ADC_EXT_POWER) > 0x100;
#elif defined (HAVE_FMADC)
/* FM or V2, can also charge from the USB port */
- return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF) ||
- (adc_read(ADC_USB_POWER) < 0x1FF);
+ return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF);
#elif defined(TOSHIBA_GIGABEAT_F)
return false;
#else
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