From 207f4d20f279467efb49e35dbd1c003a6464568b Mon Sep 17 00:00:00 2001 From: Uwe Freese Date: Sat, 14 Dec 2002 22:05:01 +0000 Subject: no inclusion of apps/settings.h anymore (simulator build error), new enable_trickle_charge function git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2995 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings_menu.c | 1 + firmware/powermgmt.c | 44 ++++++++++++++++++++++++++++---------------- firmware/powermgmt.h | 1 + 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/apps/settings_menu.c b/apps/settings_menu.c index b6375bcc9d..57df93786c 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -441,6 +441,7 @@ static bool trickle_charge(void) { bool result; result = set_bool( str(LANG_TRICKLE_CHARGE), &global_settings.trickle_charge ); + enable_trickle_charge(result); return result; } #endif diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 62bc5d3814..aa45357c7b 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -33,7 +33,7 @@ #include "mpeg.h" #include "usb.h" #include "powermgmt.h" -#include "../apps/settings.h" +#include "backlight.h" #ifdef SIMULATOR @@ -70,11 +70,26 @@ static int percent_to_volt_nocharge[11] = /* voltages (centivolt) of 0%, 10%, .. }; #ifdef HAVE_CHARGE_CTRL + +char power_message[POWER_MESSAGE_LEN] = ""; +char charge_restart_level = CHARGE_RESTART_HI; + +int powermgmt_last_cycle_startstop_min = 20; /* how many minutes ago was the charging started or stopped? */ +int powermgmt_last_cycle_level = 0; /* which level had the batteries at this time? */ +bool trickle_charge_enabled = true; +int trickle_sec = 0; /* how many seconds should the charger be enabled per minute for trickle charging? */ +int charge_state = 0; /* at the beginning, the charger does nothing */ + static int percent_to_volt_charge[11] = /* voltages (centivolt) of 0%, 10%, ... 100% when charging enabled */ { 476, 544, 551, 556, 561, 564, 566, 576, 582, 584, 585 }; -#endif + +void enable_trickle_charge(bool on) +{ + trickle_charge_enabled = on; +} +#endif /* HAVE_CHARGE_CTRL */ int battery_lazyness[20] = /* how does the battery react when plugging in/out the charger */ { @@ -92,15 +107,6 @@ static bool sleeptimer_active = false; static unsigned long sleeptimer_endtick; unsigned short power_history[POWER_HISTORY_LEN]; -#ifdef HAVE_CHARGE_CTRL -char power_message[POWER_MESSAGE_LEN] = ""; -char charge_restart_level = CHARGE_RESTART_HI; - -int powermgmt_last_cycle_startstop_min = 20; /* how many minutes ago was the charging started or stopped? */ -int powermgmt_last_cycle_level = 0; /* which level had the batteries at this time? */ -int trickle_sec = 0; /* how many seconds should the charger be enabled per minute for trickle charging? */ -int charge_state = 0; /* at the beginning, the charger does nothing */ -#endif int battery_time(void) @@ -344,14 +350,20 @@ static void power_thread(void) powermgmt_est_runningtime_min = (100 - battery_level()) * BATTERY_CAPACITY / 100 * 60 / CURRENT_CHARGING; } else { -#endif current = CURRENT_NORMAL; - if (global_settings.backlight_timeout == 1) /* LED always on */ + if ((backlight_get_timeout() == 1) || (charger_inserted() && backlight_get_on_when_charging())) + /* LED always on or LED on when charger connected */ current += CURRENT_BACKLIGHT; powermgmt_est_runningtime_min = battery_level() * BATTERY_CAPACITY / 100 * 60 / current; + } +#else + current = CURRENT_NORMAL; + if (backlight_get_timeout() == 1) /* LED always on */ + current += CURRENT_BACKLIGHT; + powermgmt_est_runningtime_min = battery_level() * BATTERY_CAPACITY / 100 * 60 / current; +#endif #ifdef HAVE_CHARGE_CTRL - } if (charge_pause > 0) charge_pause--; @@ -397,7 +409,7 @@ static void power_thread(void) /* disable charging for several hours from this point, just to be sure */ charge_pause = CHARGE_PAUSE_LEN; /* enable trickle charging */ - if (global_settings.trickle_charge) { + if (trickle_charge_enabled) { trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */ trickle_time = 0; charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ @@ -419,7 +431,7 @@ static void power_thread(void) /* disable charging for several hours from this point, just to be sure */ charge_pause = CHARGE_PAUSE_LEN; /* enable trickle charging */ - if (global_settings.trickle_charge) { + if (trickle_charge_enabled) { trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */ trickle_time = 0; charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ diff --git a/firmware/powermgmt.h b/firmware/powermgmt.h index 5e828e265f..dbecc12d44 100644 --- a/firmware/powermgmt.h +++ b/firmware/powermgmt.h @@ -58,6 +58,7 @@ extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was the c extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */ extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */ +void enable_trickle_charge(bool on); extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */ extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ -- cgit v1.2.3