summaryrefslogtreecommitdiff
path: root/firmware/export/powermgmt.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/powermgmt.h')
-rw-r--r--firmware/export/powermgmt.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
new file mode 100644
index 0000000000..a3e212b63a
--- /dev/null
+++ b/firmware/export/powermgmt.h
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef _POWERMGMT_H_
20#define _POWERMGMT_H_
21
22#ifndef SIMULATOR
23
24#ifdef HAVE_LIION /* FM Recorder, LiIon */
25#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */
26#define BATTERY_LEVEL_EMPTY 265 /* 2.65V */
27#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */
28#define BATTERY_LEVEL_FULL 400 /* 4.00V */
29
30#else /* Recorder, NiMH */
31#define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */
32#define BATTERY_LEVEL_EMPTY 465 /* 4.65V */
33#define BATTERY_LEVEL_DANGEROUS 475 /* 4.75V */
34#define BATTERY_LEVEL_FULL 585 /* 5.85V */
35#endif
36
37#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
38#define BATTERY_CAPACITY_MAX 2400 /* max. capacity that can be selected in settings menu, min. is always 1500 */
39
40#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
41#define POWER_AVG_N 4 /* how many samples to take for each measurement */
42#define POWER_AVG_SLEEP 9 /* how long do we sleep between each measurement */
43
44#define CHARGE_END_NEGD 6 /* stop when N minutes have passed with
45 * avg delta being < -0.05 V */
46#define CHARGE_END_ZEROD 50 /* stop when N minutes have passed with
47 * avg delta being < 0.005 V */
48
49#ifdef HAVE_CHARGE_CTRL
50#define POWER_MESSAGE_LEN 32 /* power thread status message */
51#define CHARGE_MAX_TIME_1500 450 /* minutes: maximum charging time for 1500 mAh batteries */
52 /* actual max time depends also on BATTERY_CAPACITY! */
53#define CHARGE_MIN_TIME 10 /* minutes: minimum charging time */
54#define CHARGE_RESTART_HI 85 /* %: when to restart charging in 'charge' mode */
55 /* attention: if set too high, normal charging is started in trickle mode */
56#define CHARGE_RESTART_LO 10 /* %: when to restart charging in 'discharge' mode */
57#define CHARGE_PAUSE_LEN 60 /* how many minutes to pause between charging cycles */
58#define TOPOFF_MAX_TIME 90 /* After charging, go to top off charge. How long should top off charge be? */
59#define TOPOFF_VOLTAGE 565 /* which voltage is best? (centivolts) */
60#define TRICKLE_MAX_TIME 12*60 /* After top off charge, go to trickle charge. How long should trickle charge be? */
61#define TRICKLE_VOLTAGE 545 /* which voltage is best? (centivolts) */
62
63extern char power_message[POWER_MESSAGE_LEN];
64extern char charge_restart_level;
65
66extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was the charging started or stopped? */
67extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */
68
69extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */
70void enable_trickle_charge(bool on);
71extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */
72extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
73
74#endif /* HAVE_CHARGE_CTRL */
75
76#define CURRENT_NORMAL 145 /* usual current in mA when using the AJB including some disk/backlight/... activity */
77#define CURRENT_USB 500 /* usual current in mA in USB mode */
78#define CURRENT_BACKLIGHT 30 /* additional current when backlight is always on */
79#define CURRENT_CHARGING 300 /* charging current */
80
81extern unsigned short power_history[POWER_HISTORY_LEN];
82
83/* Start up power management thread */
84void power_init(void);
85
86#endif /* SIMULATOR */
87
88/* Returns battery level in percent */
89int battery_level(void);
90int battery_time(void); /* minutes */
91
92/* Tells if the battery level is safe for disk writes */
93bool battery_level_safe(void);
94
95void set_poweroff_timeout(int timeout);
96void set_battery_capacity(int capacity); /* set local battery capacity value */
97
98void set_sleep_timer(int seconds);
99int get_sleep_timer(void);
100
101#endif