From cd9b51274f383e8b4c463b4467e873604675ecc2 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 9 Sep 2007 20:46:45 +0000 Subject: battery_bench: Fix battery voltage logging for voltages >4.095V by separating the flags from voltage. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14658 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/battery_bench.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 1d3694cbc5..85377e22a9 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -118,8 +118,13 @@ bool thread_stopped = false; /* Struct for battery information */ struct batt_info { - int ticks, level, eta; + /* the size of the struct elements is optimised to make the struct size + * a power of 2 */ + long ticks; + int eta; unsigned int voltage; + short level; + unsigned short flags; } bat[BUF_SIZE/sizeof(struct batt_info)]; struct event_queue thread_q; @@ -150,9 +155,9 @@ bool exit_tsr(bool reenter) else return false; } -#define BIT_CHARGER 0x1000 -#define BIT_CHARGING 0x2000 -#define BIT_USB_POWER 0x4000 +#define BIT_CHARGER 0x1 +#define BIT_CHARGING 0x2 +#define BIT_USB_POWER 0x4 #define HMS(x) (x)/3600,((x)%3600)/60,((x)%3600)%60 @@ -248,21 +253,16 @@ void thread(void) HMS(secs), secs, bat[j].level, bat[j].eta / 60, bat[j].eta % 60, -#if CONFIG_CHARGING || defined(HAVE_USB_POWER) - (bat[j].voltage & - (~(BIT_CHARGER|BIT_CHARGING|BIT_USB_POWER))), -#else bat[j].voltage, -#endif temp + 1 + (j-i) #if CONFIG_CHARGING - ,(bat[j].voltage & BIT_CHARGER)?'A':'-' + ,(bat[j].flags & BIT_CHARGER)?'A':'-' #if CONFIG_CHARGING == CHARGING_MONITOR - ,(bat[j].voltage & BIT_CHARGING)?'C':'-' + ,(bat[j].flags & BIT_CHARGING)?'C':'-' #endif #endif #ifdef HAVE_USB_POWER - ,(bat[j].voltage & BIT_USB_POWER)?'U':'-' + ,(bat[j].flags & BIT_USB_POWER)?'U':'-' #endif ); @@ -313,7 +313,7 @@ void thread(void) bat[i].eta = rb->battery_time(); last_voltage = bat[i].voltage = current_voltage; #if CONFIG_CHARGING || defined(HAVE_USB_POWER) - bat[i].voltage |= last_state = charge_state(); + bat[i].flags = last_state = charge_state(); #endif i++; got_info = true; -- cgit v1.2.3