summaryrefslogtreecommitdiff
path: root/firmware/powermgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r--firmware/powermgmt.c15
1 files changed, 14 insertions, 1 deletions
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)