From 3157e1395674a930c74e2ef4cc4ce78dffea8569 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 24 Dec 2008 16:58:41 +0000 Subject: Simplify powermgmt thread loops so it calls functions turn (no more power_thread_sleep). Do other target-friendly simplifications, generic battery switch handling and split sim-specific code. Whoever can, please verify charging on the Archos Recorder (due to change in the charger duty cycle code). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19579 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 34 +++++++++++++++++----------------- apps/menus/main_menu.c | 21 ++++++++++----------- apps/screens.c | 8 +++----- 3 files changed, 30 insertions(+), 33 deletions(-) (limited to 'apps') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index beee39a09b..abb6018a10 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -1603,10 +1603,10 @@ static bool view_battery(void) lcd_puts(0, 2, buf); #endif #if CONFIG_CHARGING -#if CONFIG_CHARGING == CHARGING_CONTROL +#if defined ARCHOS_RECORDER snprintf(buf, 30, "Chgr: %s %s", charger_inserted() ? "present" : "absent", - charger_enabled ? "on" : "off"); + charger_enabled() ? "on" : "off"); lcd_puts(0, 3, buf); snprintf(buf, 30, "short delta: %d", short_delta); lcd_puts(0, 5, buf); @@ -1616,13 +1616,11 @@ static bool view_battery(void) snprintf(buf, 30, "USB Inserted: %s", usb_inserted() ? "yes" : "no"); lcd_puts(0, 8, buf); -#if defined IRIVER_H300_SERIES +#elif defined IRIVER_H300_SERIES snprintf(buf, 30, "USB Charging Enabled: %s", usb_charging_enabled() ? "yes" : "no"); lcd_puts(0, 9, buf); -#endif -#else /* CONFIG_CHARGING != CHARGING_CONTROL */ -#if defined IPOD_NANO || defined IPOD_VIDEO +#elif defined IPOD_NANO || defined IPOD_VIDEO int usb_pwr = (GPIOL_INPUT_VAL & 0x10)?true:false; int ext_pwr = (GPIOL_INPUT_VAL & 0x08)?false:true; int dock = (GPIOA_INPUT_VAL & 0x10)?true:false; @@ -1644,12 +1642,8 @@ static bool view_battery(void) snprintf(buf, 30, "Headphone: %s", headphone ? "connected" : "disconnected"); lcd_puts(0, 7, buf); -#else - snprintf(buf, 30, "Charger: %s", - charger_inserted() ? "present" : "absent"); - lcd_puts(0, 3, buf); -#if defined TOSHIBA_GIGABEAT_S - int line = 4; +#elif defined TOSHIBA_GIGABEAT_S + int line = 3; unsigned int st; static const unsigned char * const chrgstate_strings[] = @@ -1663,6 +1657,10 @@ static bool view_battery(void) "", }; + snprintf(buf, 30, "Charger: %s", + charger_inserted() ? "present" : "absent"); + lcd_puts(0, line++, buf); + st = power_input_status() & (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY); snprintf(buf, 30, "%s%s", @@ -1730,9 +1728,11 @@ static bool view_battery(void) } lcd_puts(0, line++, buf); -#endif /* defined TOSHIBA_GIGABEAT_S */ -#endif /* defined IPOD_NANO || defined IPOD_VIDEO */ -#endif /* CONFIG_CHARGING != CHARGING_CONTROL */ +#else + snprintf(buf, 30, "Charger: %s", + charger_inserted() ? "present" : "absent"); + lcd_puts(0, 3, buf); +#endif /* target type */ #endif /* CONFIG_CHARGING */ break; @@ -1750,7 +1750,7 @@ static bool view_battery(void) case 3: /* remaining time estimation: */ -#if CONFIG_CHARGING == CHARGING_CONTROL +#ifdef ARCHOS_RECORDER snprintf(buf, 30, "charge_state: %d", charge_state); lcd_puts(0, 0, buf); @@ -1765,7 +1765,7 @@ static bool view_battery(void) snprintf(buf, 30, "Trickle sec: %d/60", trickle_sec); lcd_puts(0, 4, buf); -#endif /* CONFIG_CHARGING == CHARGING_CONTROL */ +#endif /* ARCHOS_RECORDER */ snprintf(buf, 30, "Last PwrHist: %d.%03dV", power_history[0] / 1000, diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 4c15b1de4b..b22824d8bd 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c @@ -27,6 +27,7 @@ #include "lang.h" #include "action.h" #include "settings.h" +#include "power.h" #include "powermgmt.h" #include "menu.h" #include "misc.h" @@ -199,15 +200,14 @@ static char* info_getname(int selected_item, void *data, if (charge_state == CHARGING) return (char *)str(LANG_BATTERY_CHARGE); else -#if CONFIG_CHARGING == CHARGING_CONTROL +#ifdef ARCHOS_RECORDER if (charge_state == TOPOFF) return (char *)str(LANG_BATTERY_TOPOFF_CHARGE); - else -#endif - if (charge_state == TRICKLE) + else if (charge_state == TRICKLE) return (char *)str(LANG_BATTERY_TRICKLE_CHARGE); else -#endif +#endif /* ARCHOS_RECORDER */ +#endif /* CONFIG_CHARGING = */ if (battery_level() >= 0) snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_TIME), battery_level(), battery_time() / 60, battery_time() % 60); @@ -282,22 +282,21 @@ static int info_speak_item(int selected_item, void * data) } case INFO_BATTERY: /* battery */ #if CONFIG_CHARGING == CHARGING_SIMPLE - if (charger_input_state == CHARGER) + if (charger_inserted()) talk_id(LANG_BATTERY_CHARGE, true); else #elif CONFIG_CHARGING >= CHARGING_MONITOR if (charge_state == CHARGING) talk_id(LANG_BATTERY_CHARGE, true); else -#if CONFIG_CHARGING == CHARGING_CONTROL +#ifdef ARCHOS_RECORDER if (charge_state == TOPOFF) talk_id(LANG_BATTERY_TOPOFF_CHARGE, true); - else -#endif - if (charge_state == TRICKLE) + else if (charge_state == TRICKLE) talk_id(LANG_BATTERY_TRICKLE_CHARGE, true); else -#endif +#endif /* ARCHOS_RECORDER */ +#endif /* CONFIG_CHARGING = */ if (battery_level() >= 0) { talk_id(LANG_BATTERY_TIME, false); diff --git a/apps/screens.c b/apps/screens.c index 992c740460..230e9ae53c 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -209,8 +209,7 @@ static void charging_display_info(bool animate) lcd_puts(0, 7, buf); } -#if CONFIG_CHARGING == CHARGING_CONTROL - +#ifdef ARCHOS_RECORER snprintf(buf, 32, "Charge mode:"); lcd_puts(0, 2, buf); @@ -224,10 +223,9 @@ static void charging_display_info(bool animate) snprintf(buf, 32, "not charging"); lcd_puts(0, 3, buf); - if (!charger_enabled) + if (!charger_enabled()) animate = false; -#endif /* CONFIG_CHARGING == CHARGING_CONTROL */ - +#endif /* ARCHOS_RECORER */ /* middle part */ memset(charging_logo+3, 0x00, 32); -- cgit v1.2.3