summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Freese <thebreaker@rockbox.org>2002-12-14 22:05:01 +0000
committerUwe Freese <thebreaker@rockbox.org>2002-12-14 22:05:01 +0000
commit207f4d20f279467efb49e35dbd1c003a6464568b (patch)
treeeafa5d6b47ba5080c9729c34e64a8911bff13731
parent86ddabf75d4461161506925641b16f3a7dc7463b (diff)
downloadrockbox-207f4d20f279467efb49e35dbd1c003a6464568b.tar.gz
rockbox-207f4d20f279467efb49e35dbd1c003a6464568b.zip
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
-rw-r--r--apps/settings_menu.c1
-rw-r--r--firmware/powermgmt.c44
-rw-r--r--firmware/powermgmt.h1
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)
441{ 441{
442 bool result; 442 bool result;
443 result = set_bool( str(LANG_TRICKLE_CHARGE), &global_settings.trickle_charge ); 443 result = set_bool( str(LANG_TRICKLE_CHARGE), &global_settings.trickle_charge );
444 enable_trickle_charge(result);
444 return result; 445 return result;
445} 446}
446#endif 447#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 @@
33#include "mpeg.h" 33#include "mpeg.h"
34#include "usb.h" 34#include "usb.h"
35#include "powermgmt.h" 35#include "powermgmt.h"
36#include "../apps/settings.h" 36#include "backlight.h"
37 37
38#ifdef SIMULATOR 38#ifdef SIMULATOR
39 39
@@ -70,11 +70,26 @@ static int percent_to_volt_nocharge[11] = /* voltages (centivolt) of 0%, 10%, ..
70}; 70};
71 71
72#ifdef HAVE_CHARGE_CTRL 72#ifdef HAVE_CHARGE_CTRL
73
74char power_message[POWER_MESSAGE_LEN] = "";
75char charge_restart_level = CHARGE_RESTART_HI;
76
77int powermgmt_last_cycle_startstop_min = 20; /* how many minutes ago was the charging started or stopped? */
78int powermgmt_last_cycle_level = 0; /* which level had the batteries at this time? */
79bool trickle_charge_enabled = true;
80int trickle_sec = 0; /* how many seconds should the charger be enabled per minute for trickle charging? */
81int charge_state = 0; /* at the beginning, the charger does nothing */
82
73static int percent_to_volt_charge[11] = /* voltages (centivolt) of 0%, 10%, ... 100% when charging enabled */ 83static int percent_to_volt_charge[11] = /* voltages (centivolt) of 0%, 10%, ... 100% when charging enabled */
74{ 84{
75 476, 544, 551, 556, 561, 564, 566, 576, 582, 584, 585 85 476, 544, 551, 556, 561, 564, 566, 576, 582, 584, 585
76}; 86};
77#endif 87
88void enable_trickle_charge(bool on)
89{
90 trickle_charge_enabled = on;
91}
92#endif /* HAVE_CHARGE_CTRL */
78 93
79int battery_lazyness[20] = /* how does the battery react when plugging in/out the charger */ 94int battery_lazyness[20] = /* how does the battery react when plugging in/out the charger */
80{ 95{
@@ -92,15 +107,6 @@ static bool sleeptimer_active = false;
92static unsigned long sleeptimer_endtick; 107static unsigned long sleeptimer_endtick;
93 108
94unsigned short power_history[POWER_HISTORY_LEN]; 109unsigned short power_history[POWER_HISTORY_LEN];
95#ifdef HAVE_CHARGE_CTRL
96char power_message[POWER_MESSAGE_LEN] = "";
97char charge_restart_level = CHARGE_RESTART_HI;
98
99int powermgmt_last_cycle_startstop_min = 20; /* how many minutes ago was the charging started or stopped? */
100int powermgmt_last_cycle_level = 0; /* which level had the batteries at this time? */
101int trickle_sec = 0; /* how many seconds should the charger be enabled per minute for trickle charging? */
102int charge_state = 0; /* at the beginning, the charger does nothing */
103#endif
104 110
105 111
106int battery_time(void) 112int battery_time(void)
@@ -344,14 +350,20 @@ static void power_thread(void)
344 powermgmt_est_runningtime_min = (100 - battery_level()) * BATTERY_CAPACITY / 100 * 60 / CURRENT_CHARGING; 350 powermgmt_est_runningtime_min = (100 - battery_level()) * BATTERY_CAPACITY / 100 * 60 / CURRENT_CHARGING;
345 } 351 }
346 else { 352 else {
347#endif
348 current = CURRENT_NORMAL; 353 current = CURRENT_NORMAL;
349 if (global_settings.backlight_timeout == 1) /* LED always on */ 354 if ((backlight_get_timeout() == 1) || (charger_inserted() && backlight_get_on_when_charging()))
355 /* LED always on or LED on when charger connected */
350 current += CURRENT_BACKLIGHT; 356 current += CURRENT_BACKLIGHT;
351 powermgmt_est_runningtime_min = battery_level() * BATTERY_CAPACITY / 100 * 60 / current; 357 powermgmt_est_runningtime_min = battery_level() * BATTERY_CAPACITY / 100 * 60 / current;
358 }
359#else
360 current = CURRENT_NORMAL;
361 if (backlight_get_timeout() == 1) /* LED always on */
362 current += CURRENT_BACKLIGHT;
363 powermgmt_est_runningtime_min = battery_level() * BATTERY_CAPACITY / 100 * 60 / current;
364#endif
352 365
353#ifdef HAVE_CHARGE_CTRL 366#ifdef HAVE_CHARGE_CTRL
354 }
355 367
356 if (charge_pause > 0) 368 if (charge_pause > 0)
357 charge_pause--; 369 charge_pause--;
@@ -397,7 +409,7 @@ static void power_thread(void)
397 /* disable charging for several hours from this point, just to be sure */ 409 /* disable charging for several hours from this point, just to be sure */
398 charge_pause = CHARGE_PAUSE_LEN; 410 charge_pause = CHARGE_PAUSE_LEN;
399 /* enable trickle charging */ 411 /* enable trickle charging */
400 if (global_settings.trickle_charge) { 412 if (trickle_charge_enabled) {
401 trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */ 413 trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */
402 trickle_time = 0; 414 trickle_time = 0;
403 charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ 415 charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
@@ -419,7 +431,7 @@ static void power_thread(void)
419 /* disable charging for several hours from this point, just to be sure */ 431 /* disable charging for several hours from this point, just to be sure */
420 charge_pause = CHARGE_PAUSE_LEN; 432 charge_pause = CHARGE_PAUSE_LEN;
421 /* enable trickle charging */ 433 /* enable trickle charging */
422 if (global_settings.trickle_charge) { 434 if (trickle_charge_enabled) {
423 trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */ 435 trickle_sec = CURRENT_NORMAL * 60 / CURRENT_CHARGING; /* first guess, maybe consider if LED backlight is on, disk is active,... */
424 trickle_time = 0; 436 trickle_time = 0;
425 charge_state = 2; /* 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ 437 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
58extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */ 58extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */
59 59
60extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */ 60extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */
61void enable_trickle_charge(bool on);
61extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */ 62extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */
62extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ 63extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
63 64