From 116e4646b0eed98bec965145698ee89c05f400e7 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 4 May 2005 16:18:09 +0000 Subject: 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 --- firmware/export/powermgmt.h | 18 ------------------ firmware/powermgmt.c | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 19 deletions(-) (limited to 'firmware') 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 @@ #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 35838f2a49..2d7e5dfe6e 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) -- cgit v1.2.3