summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-05-04 16:18:09 +0000
committerJens Arnold <amiconn@rockbox.org>2005-05-04 16:18:09 +0000
commit116e4646b0eed98bec965145698ee89c05f400e7 (patch)
tree46993efce692ce49c6181b0473757483d860623d
parentf64b52ae380edf76220b3fc53998e14af8e55c4a (diff)
downloadrockbox-116e4646b0eed98bec965145698ee89c05f400e7.tar.gz
rockbox-116e4646b0eed98bec965145698ee89c05f400e7.zip
Proper 'battery level dangerous' handling for Ondio. Moved this info into an array, and removed unused #defines.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6403 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/powermgmt.h18
-rw-r--r--firmware/powermgmt.c15
2 files changed, 14 insertions, 19 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 97daf7ce59..29ef9eba95 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -20,41 +20,23 @@
20#define _POWERMGMT_H_ 20#define _POWERMGMT_H_
21 21
22#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */ 22#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */
23#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */
24#define BATTERY_LEVEL_EMPTY 265 /* 2.65V */
25#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */
26#define BATTERY_LEVEL_FULL 400 /* 4.00V */
27#define BATTERY_CAPACITY_MIN 2200 23#define BATTERY_CAPACITY_MIN 2200
28#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ 24#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
29#define BATTERY_TYPES_COUNT 1 25#define BATTERY_TYPES_COUNT 1
30#elif CONFIG_BATTERY == BATT_3AAA /* Ondio */ 26#elif CONFIG_BATTERY == BATT_3AAA /* Ondio */
31#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */
32#define BATTERY_LEVEL_EMPTY 270 /* 2.70V */
33#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */
34#define BATTERY_LEVEL_FULL 475 /* 4.75V */
35#define BATTERY_CAPACITY_MIN 500 27#define BATTERY_CAPACITY_MIN 500
36#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */ 28#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */
37#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ 29#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
38#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */ 30#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */
39#define BATTERY_LEVEL_SHUTDOWN 306 /* 3.06V */
40#define BATTERY_LEVEL_EMPTY 330 /* 3.30V */
41#define BATTERY_LEVEL_DANGEROUS 339 /* 3.39V */
42#define BATTERY_LEVEL_FULL 400 /* 4.00V */
43#define BATTERY_CAPACITY_MIN 1300 31#define BATTERY_CAPACITY_MIN 1300
44#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ 32#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
45#define BATTERY_TYPES_COUNT 1 33#define BATTERY_TYPES_COUNT 1
46#else /* Recorder, NiMH */ 34#else /* Recorder, NiMH */
47#define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */
48#define BATTERY_LEVEL_EMPTY 465 /* 4.65V */
49#define BATTERY_LEVEL_DANGEROUS 475 /* 4.75V */
50#define BATTERY_LEVEL_FULL 585 /* 5.85V */
51#define BATTERY_CAPACITY_MIN 1500 35#define BATTERY_CAPACITY_MIN 1500
52#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ 36#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
53#define BATTERY_TYPES_COUNT 1 37#define BATTERY_TYPES_COUNT 1
54#endif 38#endif
55 39
56#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
57
58#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */ 40#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
59 41
60#define CHARGE_END_NEGD 6 /* stop when N minutes have passed with 42#define CHARGE_END_NEGD 6 /* stop when N minutes have passed with
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 35838f2a49..2d7e5dfe6e 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -101,6 +101,19 @@ static const int poweroff_idle_timeout_value[15] =
101 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 45, 60 101 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 45, 60
102}; 102};
103 103
104static const unsigned int battery_level_dangerous[BATTERY_TYPES_COUNT] =
105{
106#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */
107 280
108#elif CONFIG_BATTERY == BATT_3AAA /* Ondio */
109 310, 345 /* alkaline, NiHM */
110#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */
111 339
112#else /* Player/recorder, NiMH */
113 475
114#endif
115};
116
104static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 117static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
105/* voltages (centivolt) of 0%, 10%, ... 100% when charging disabled */ 118/* voltages (centivolt) of 0%, 10%, ... 100% when charging disabled */
106{ 119{
@@ -239,7 +252,7 @@ int battery_level(void)
239/* Tells if the battery level is safe for disk writes */ 252/* Tells if the battery level is safe for disk writes */
240bool battery_level_safe(void) 253bool battery_level_safe(void)
241{ 254{
242 return battery_centivolts > BATTERY_LEVEL_DANGEROUS; 255 return battery_centivolts > battery_level_dangerous[battery_type];
243} 256}
244 257
245void set_poweroff_timeout(int timeout) 258void set_poweroff_timeout(int timeout)