forked from len0rd/rockbox
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
This commit is contained in:
parent
f64b52ae38
commit
116e4646b0
2 changed files with 14 additions and 19 deletions
|
|
@ -20,41 +20,23 @@
|
||||||
#define _POWERMGMT_H_
|
#define _POWERMGMT_H_
|
||||||
|
|
||||||
#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */
|
#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_MIN 2200
|
||||||
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
|
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
|
||||||
#define BATTERY_TYPES_COUNT 1
|
#define BATTERY_TYPES_COUNT 1
|
||||||
#elif CONFIG_BATTERY == BATT_3AAA /* Ondio */
|
#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_MIN 500
|
||||||
#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */
|
#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */
|
||||||
#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
|
#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
|
||||||
#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */
|
#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_MIN 1300
|
||||||
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
|
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
|
||||||
#define BATTERY_TYPES_COUNT 1
|
#define BATTERY_TYPES_COUNT 1
|
||||||
#else /* Recorder, NiMH */
|
#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_MIN 1500
|
||||||
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
|
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
|
||||||
#define BATTERY_TYPES_COUNT 1
|
#define BATTERY_TYPES_COUNT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
|
|
||||||
|
|
||||||
#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
|
#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
|
#define CHARGE_END_NEGD 6 /* stop when N minutes have passed with
|
||||||
|
|
|
||||||
|
|
@ -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
|
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] =
|
static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||||
/* voltages (centivolt) of 0%, 10%, ... 100% when charging disabled */
|
/* 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 */
|
/* Tells if the battery level is safe for disk writes */
|
||||||
bool battery_level_safe(void)
|
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)
|
void set_poweroff_timeout(int timeout)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue