forked from len0rd/rockbox
using the new charge state variable instead of trickle_enable
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2991 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
82785295f9
commit
48e8e98efa
1 changed files with 27 additions and 21 deletions
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Heikki Hannikainen
|
* Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
|
||||||
*
|
*
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
@ -99,6 +99,7 @@ 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_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 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 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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,7 +293,6 @@ static void power_thread(void)
|
||||||
int charged_time = 0;
|
int charged_time = 0;
|
||||||
int charge_max_time_now = 0;
|
int charge_max_time_now = 0;
|
||||||
int charge_pause = 0; /* no charging pause at the beginning */
|
int charge_pause = 0; /* no charging pause at the beginning */
|
||||||
bool trickle_enabled = false; /* enable trickle charging only after a complete charging cycle */
|
|
||||||
int trickle_time = 0; /* how many minutes trickle charging already? */
|
int trickle_time = 0; /* how many minutes trickle charging already? */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -372,6 +372,7 @@ static void power_thread(void)
|
||||||
/* disable charging for several hours from this point, just to be sure */
|
/* disable charging for several hours from this point, just to be sure */
|
||||||
charge_pause = CHARGE_PAUSE_LEN;
|
charge_pause = CHARGE_PAUSE_LEN;
|
||||||
/* no trickle charge here, because the charging cycle didn't end the right way */
|
/* no trickle charge here, because the charging cycle didn't end the right way */
|
||||||
|
charge_state = 0; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
} else {
|
} else {
|
||||||
if (charged_time > CHARGE_MIN_TIME) {
|
if (charged_time > CHARGE_MIN_TIME) {
|
||||||
/* have charged continuously over the minimum charging time,
|
/* have charged continuously over the minimum charging time,
|
||||||
|
@ -396,9 +397,11 @@ static void power_thread(void)
|
||||||
/* disable charging for several hours from this point, just to be sure */
|
/* disable charging for several hours from this point, just to be sure */
|
||||||
charge_pause = CHARGE_PAUSE_LEN;
|
charge_pause = CHARGE_PAUSE_LEN;
|
||||||
/* enable trickle charging */
|
/* enable trickle charging */
|
||||||
trickle_enabled = true;
|
if (global_settings.trickle_charge) {
|
||||||
trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */
|
trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */
|
||||||
trickle_time = 0;
|
trickle_time = 0;
|
||||||
|
charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* if we didn't disable the charger in the previous test, check for low positive delta */
|
/* if we didn't disable the charger in the previous test, check for low positive delta */
|
||||||
delta = ( power_history[POWER_HISTORY_LEN-1] * 100
|
delta = ( power_history[POWER_HISTORY_LEN-1] * 100
|
||||||
|
@ -416,9 +419,11 @@ static void power_thread(void)
|
||||||
/* disable charging for several hours from this point, just to be sure */
|
/* disable charging for several hours from this point, just to be sure */
|
||||||
charge_pause = CHARGE_PAUSE_LEN;
|
charge_pause = CHARGE_PAUSE_LEN;
|
||||||
/* enable trickle charging */
|
/* enable trickle charging */
|
||||||
trickle_enabled = true;
|
if (global_settings.trickle_charge) {
|
||||||
trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */
|
trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */
|
||||||
trickle_time = 0;
|
trickle_time = 0;
|
||||||
|
charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,12 +431,10 @@ static void power_thread(void)
|
||||||
} else { /* charged inserted but not enabled */
|
} else { /* charged inserted but not enabled */
|
||||||
|
|
||||||
/* trickle charging */
|
/* trickle charging */
|
||||||
if (trickle_enabled) {
|
if (charge_state > 1) { /* top off or trickle? */
|
||||||
/* adjust trickle charge time */
|
/* adjust trickle charge time */
|
||||||
if ( ((trickle_time <= TOPOFF_MAX_TIME)
|
if ( ((charge_state == 2) && (power_history[POWER_HISTORY_LEN-1] > TOPOFF_VOLTAGE))
|
||||||
&& (power_history[POWER_HISTORY_LEN-1] > TOPOFF_VOLTAGE))
|
|| ((charge_state == 3) && (power_history[POWER_HISTORY_LEN-1] > TRICKLE_VOLTAGE)) ) { /* charging too much */
|
||||||
|| ((trickle_time > TOPOFF_MAX_TIME)
|
|
||||||
&& (power_history[POWER_HISTORY_LEN-1] > TRICKLE_VOLTAGE)) ) { /* charging too much */
|
|
||||||
trickle_sec--;
|
trickle_sec--;
|
||||||
} else { /* charging too less */
|
} else { /* charging too less */
|
||||||
trickle_sec++;
|
trickle_sec++;
|
||||||
|
@ -448,9 +451,12 @@ static void power_thread(void)
|
||||||
/* trickle charging long enough? */
|
/* trickle charging long enough? */
|
||||||
|
|
||||||
if (trickle_time++ > TRICKLE_MAX_TIME + TOPOFF_MAX_TIME) {
|
if (trickle_time++ > TRICKLE_MAX_TIME + TOPOFF_MAX_TIME) {
|
||||||
trickle_enabled = false;
|
|
||||||
trickle_sec = 0; /* show in debug menu that trickle is off */
|
trickle_sec = 0; /* show in debug menu that trickle is off */
|
||||||
|
charge_state = 0; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((charge_state == 2) && (trickle_time > TOPOFF_MAX_TIME)) /* change state? */
|
||||||
|
charge_state = 3; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if battery is not full, enable charging */
|
/* if battery is not full, enable charging */
|
||||||
|
@ -475,7 +481,7 @@ static void power_thread(void)
|
||||||
charged_time = 0;
|
charged_time = 0;
|
||||||
|
|
||||||
charger_enable(true);
|
charger_enable(true);
|
||||||
|
charge_state = 1; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
/* clear the power history so that we don't use values before
|
/* clear the power history so that we don't use values before
|
||||||
* discharge for the long-term delta
|
* discharge for the long-term delta
|
||||||
*/
|
*/
|
||||||
|
@ -491,9 +497,9 @@ static void power_thread(void)
|
||||||
DEBUGF("power: charger disconnected, disabling\n");
|
DEBUGF("power: charger disconnected, disabling\n");
|
||||||
powermgmt_last_cycle_level = battery_level();
|
powermgmt_last_cycle_level = battery_level();
|
||||||
powermgmt_last_cycle_startstop_min = 0;
|
powermgmt_last_cycle_startstop_min = 0;
|
||||||
trickle_enabled = false;
|
|
||||||
trickle_sec = 0; /* show in debug menu that trickle is off */
|
trickle_sec = 0; /* show in debug menu that trickle is off */
|
||||||
charger_enable(false);
|
charger_enable(false);
|
||||||
|
charge_state = 0; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
|
||||||
snprintf(power_message, POWER_MESSAGE_LEN, "Charger disc");
|
snprintf(power_message, POWER_MESSAGE_LEN, "Charger disc");
|
||||||
}
|
}
|
||||||
/* charger not inserted and disabled, so we're discharging */
|
/* charger not inserted and disabled, so we're discharging */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue