summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Freese <thebreaker@rockbox.org>2002-12-14 22:46:00 +0000
committerUwe Freese <thebreaker@rockbox.org>2002-12-14 22:46:00 +0000
commitc29b538440fac97fbb292328c7ed123727a6486b (patch)
treed5a58ffe21baa75df530f5a56105abba53068da7
parente2a6aee66178607fe2f396a737e84b1b067fc031 (diff)
downloadrockbox-c29b538440fac97fbb292328c7ed123727a6486b.zip
rockbox-c29b538440fac97fbb292328c7ed123727a6486b.tar.gz
rockbox-c29b538440fac97fbb292328c7ed123727a6486b.tar.bz2
rockbox-c29b538440fac97fbb292328c7ed123727a6486b.tar.xz
battery capacity setting function
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2997 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/powermgmt.c18
-rw-r--r--firmware/powermgmt.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 7f89434..a05c54f 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -79,12 +79,18 @@ int powermgmt_last_cycle_level = 0; /* which level had the batteries at
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 */
+int battery_capacity = 1800; /* only a default value */
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
};
+void set_battery_capacity(int capacity)
+{
+ battery_capacity = capacity;
+}
+
void enable_trickle_charge(bool on)
{
trickle_charge_enabled = on;
@@ -345,22 +351,22 @@ static void power_thread(void)
/* so consider it because there's the battery lazyness inside the the battery_level */
if (powermgmt_last_cycle_startstop_min < 20) {
i = (100 - battery_lazyness[powermgmt_last_cycle_startstop_min]) * 30 / 100 ; /* 0..30 */
- powermgmt_est_runningtime_min = (100 - battery_level()) * BATTERY_CAPACITY / 100 * (100 + i) / 100 * 60 / CURRENT_CHARGING;
+ powermgmt_est_runningtime_min = (100 - battery_level()) * battery_capacity / 100 * (100 + i) / 100 * 60 / CURRENT_CHARGING;
} else {
- powermgmt_est_runningtime_min = (100 - battery_level()) * BATTERY_CAPACITY / 100 * 60 / CURRENT_CHARGING;
+ powermgmt_est_runningtime_min = (100 - battery_level()) * battery_capacity / 100 * 60 / CURRENT_CHARGING;
}
else {
current = CURRENT_NORMAL;
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;
+ 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;
+ powermgmt_est_runningtime_min = battery_level() * battery_capacity / 100 * 60 / current;
#endif
#ifdef HAVE_CHARGE_CTRL
@@ -479,7 +485,7 @@ static void power_thread(void)
} else {
/* calculate max charge time depending on current battery level */
/* take 35% more because battery level is not linear */
- i = CHARGE_MAX_TIME_1500 * BATTERY_CAPACITY / 1500;
+ i = CHARGE_MAX_TIME_1500 * battery_capacity / 1500;
charge_max_time_now = i * (100 + 35 - battery_level()) / 100;
if (charge_max_time_now > i) {
charge_max_time_now = i;
@@ -542,7 +548,7 @@ void power_init(void)
flickering during the first minute of execution */
power_history[POWER_HISTORY_LEN-1] = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
/* calculate the remaining time to that the info screen displays something useful */
- powermgmt_est_runningtime_min = battery_level() * BATTERY_CAPACITY / 100 * 60 / CURRENT_NORMAL;
+ powermgmt_est_runningtime_min = battery_level() * battery_capacity / 100 * 60 / CURRENT_NORMAL;
#ifdef HAVE_CHARGE_CTRL
snprintf(power_message, POWER_MESSAGE_LEN, "Powermgmt started");
diff --git a/firmware/powermgmt.h b/firmware/powermgmt.h
index dbecc12..ee2c513 100644
--- a/firmware/powermgmt.h
+++ b/firmware/powermgmt.h
@@ -59,12 +59,12 @@ extern int powermgmt_last_cycle_level; /* which level had the batteries
extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */
void enable_trickle_charge(bool on);
+void set_battery_capacity(int capacity); /* set local battery capacity value */
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 */
#endif /* HAVE_CHARGE_CTRL */
-#define BATTERY_CAPACITY 1800 /* battery capacity in mAh for runtime estimation */
#define CURRENT_NORMAL 145 /* usual current in mA when using the AJB including some disk/backlight/... activity */
#define CURRENT_BACKLIGHT 30 /* additional current when backlight is always on */
#define CURRENT_CHARGING 300 /* charging current */