Fixed red build
[kugel-rb.git] / firmware / powermgmt.h
blob329bf6005fb2389a2f1a035d0f2621ce8f4d737f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Heikki Hannikainen
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #ifndef _POWERMGMT_H_
20 #define _POWERMGMT_H_
22 #ifndef SIMULATOR
24 #define BATTERY_LEVEL_SHUTDOWN 450 /* 4.5V */
25 #define BATTERY_LEVEL_EMPTY 465 /* 4.65V */
26 #define BATTERY_LEVEL_DANGEROUS 475 /* 4.75V */
27 #define BATTERY_LEVEL_FULL 520 /* 5.2V */
29 #define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
31 #define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
32 #define POWER_AVG_N 4 /* how many samples to take for each measurement */
33 #define POWER_AVG_SLEEP 10 /* how long do we sleep between each measurement */
35 #define CHARGE_END_NEGD 6 /* stop when N minutes have passed with
36 * avg delta being < -0.05 V */
37 #define CHARGE_END_ZEROD 50 /* stop when N minutes have passed with
38 * avg delta being < 0.005 V */
40 #ifdef HAVE_CHARGE_CTRL
41 #define POWER_MESSAGE_LEN 32 /* power thread status message */
42 #define CHARGE_MAX_TIME 6*60 /* minutes: maximum charging time */
43 #define CHARGE_MIN_TIME 10 /* minutes: minimum charging time */
44 #define CHARGE_RESTART_HI 95 /* %: when to restart charging in 'charge' mode */
45 #define CHARGE_RESTART_LO 10 /* %: when to restart charging in 'discharge' mode */
47 extern char power_message[POWER_MESSAGE_LEN];
48 extern char charge_restart_level;
49 #endif /* HAVE_CHARGE_CTRL */
51 extern unsigned short power_history[POWER_HISTORY_LEN];
53 /* Start up power management thread */
54 void power_init(void);
56 #endif /* SIMULATOR */
58 /* Returns battery level in percent */
59 int battery_level(void);
61 /* Tells if the battery level is safe for disk writes */
62 bool battery_level_safe(void);
64 void set_poweroff_timeout(int timeout);
66 #endif