diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2005-05-04 16:18:09 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2005-05-04 16:18:09 +0000 |
| commit | 116e4646b0eed98bec965145698ee89c05f400e7 (patch) | |
| tree | 46993efce692ce49c6181b0473757483d860623d | |
| parent | f64b52ae380edf76220b3fc53998e14af8e55c4a (diff) | |
| download | rockbox-116e4646b0eed98bec965145698ee89c05f400e7.zip rockbox-116e4646b0eed98bec965145698ee89c05f400e7.tar.gz rockbox-116e4646b0eed98bec965145698ee89c05f400e7.tar.bz2 rockbox-116e4646b0eed98bec965145698ee89c05f400e7.tar.xz | |
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.h | 18 | ||||
| -rw-r--r-- | firmware/powermgmt.c | 15 |
2 files changed, 14 insertions, 19 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 97daf7c..29ef9eb 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -20,41 +20,23 @@ #define _POWERMGMT_H_ #if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */ -#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */ -#define BATTERY_LEVEL_EMPTY 265 /* 2.65V */ -#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */ -#define BATTERY_LEVEL_FULL 400 /* 4.00V */ #define BATTERY_CAPACITY_MIN 2200 #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ #define BATTERY_TYPES_COUNT 1 #elif CONFIG_BATTERY == BATT_3AAA /* Ondio */ -#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */ -#define BATTERY_LEVEL_EMPTY 270 /* 2.70V */ -#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */ -#define BATTERY_LEVEL_FULL 475 /* 4.75V */ #define BATTERY_CAPACITY_MIN 500 #define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */ #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ #elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */ -#define BATTERY_LEVEL_SHUTDOWN 306 /* 3.06V */ -#define BATTERY_LEVEL_EMPTY 330 /* 3.30V */ -#define BATTERY_LEVEL_DANGEROUS 339 /* 3.39V */ -#define BATTERY_LEVEL_FULL 400 /* 4.00V */ #define BATTERY_CAPACITY_MIN 1300 #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ #define BATTERY_TYPES_COUNT 1 #else /* Recorder, NiMH */ -#define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */ -#define BATTERY_LEVEL_EMPTY 465 /* 4.65V */ -#define BATTERY_LEVEL_DANGEROUS 475 /* 4.75V */ -#define BATTERY_LEVEL_FULL 585 /* 5.85V */ #define BATTERY_CAPACITY_MIN 1500 #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ #define BATTERY_TYPES_COUNT 1 #endif -#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY) - #define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */ #define CHARGE_END_NEGD 6 /* stop when N minutes have passed with diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 35838f2..2d7e5df 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -101,6 +101,19 @@ static const int poweroff_idle_timeout_value[15] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 45, 60 }; +static const unsigned int battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ +#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */ + 280 +#elif CONFIG_BATTERY == BATT_3AAA /* Ondio */ + 310, 345 /* alkaline, NiHM */ +#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */ + 339 +#else /* Player/recorder, NiMH */ + 475 +#endif +}; + static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = /* voltages (centivolt) of 0%, 10%, ... 100% when charging disabled */ { @@ -239,7 +252,7 @@ int battery_level(void) /* Tells if the battery level is safe for disk writes */ bool battery_level_safe(void) { - return battery_centivolts > BATTERY_LEVEL_DANGEROUS; + return battery_centivolts > battery_level_dangerous[battery_type]; } void set_poweroff_timeout(int timeout) |