diff options
Diffstat (limited to 'firmware/export/powermgmt.h')
-rw-r--r-- | firmware/export/powermgmt.h | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 922630097a..59f9465d49 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -48,13 +48,12 @@ | |||
48 | #define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY) | 48 | #define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY) |
49 | 49 | ||
50 | #define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */ | 50 | #define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */ |
51 | #define POWER_AVG_N 4 /* how many samples to take for each measurement */ | ||
52 | #define POWER_AVG_SLEEP 9 /* how long do we sleep between each measurement */ | ||
53 | 51 | ||
54 | #define CHARGE_END_NEGD 6 /* stop when N minutes have passed with | 52 | #define CHARGE_END_NEGD 6 /* stop when N minutes have passed with |
55 | * avg delta being < -0.05 V */ | 53 | * avg delta being < -0.05 V */ |
56 | #define CHARGE_END_ZEROD 50 /* stop when N minutes have passed with | 54 | #define CHARGE_END_ZEROD 50 /* stop when N minutes have passed with |
57 | * avg delta being < 0.005 V */ | 55 | * avg delta being < 0.005 V */ |
56 | |||
58 | #ifndef SIMULATOR | 57 | #ifndef SIMULATOR |
59 | 58 | ||
60 | #ifdef HAVE_CHARGE_CTRL | 59 | #ifdef HAVE_CHARGE_CTRL |
@@ -65,27 +64,40 @@ | |||
65 | #define CHARGE_RESTART_HI 85 /* %: when to restart charging in 'charge' mode */ | 64 | #define CHARGE_RESTART_HI 85 /* %: when to restart charging in 'charge' mode */ |
66 | /* attention: if set too high, normal charging is started in trickle mode */ | 65 | /* attention: if set too high, normal charging is started in trickle mode */ |
67 | #define CHARGE_RESTART_LO 10 /* %: when to restart charging in 'discharge' mode */ | 66 | #define CHARGE_RESTART_LO 10 /* %: when to restart charging in 'discharge' mode */ |
68 | #define CHARGE_PAUSE_LEN 60 /* how many minutes to pause between charging cycles */ | ||
69 | #define TOPOFF_MAX_TIME 90 /* After charging, go to top off charge. How long should top off charge be? */ | 67 | #define TOPOFF_MAX_TIME 90 /* After charging, go to top off charge. How long should top off charge be? */ |
70 | #define TOPOFF_VOLTAGE 565 /* which voltage is best? (centivolts) */ | 68 | #define TOPOFF_VOLTAGE 565 /* which voltage is best? (centivolts) */ |
71 | #define TRICKLE_MAX_TIME 12*60 /* After top off charge, go to trickle charge. How long should trickle charge be? */ | 69 | #define TRICKLE_MAX_TIME 12*60 /* After top off charge, go to trickle charge. How long should trickle charge be? */ |
72 | #define TRICKLE_VOLTAGE 545 /* which voltage is best? (centivolts) */ | 70 | #define TRICKLE_VOLTAGE 545 /* which voltage is best? (centivolts) */ |
73 | 71 | ||
72 | #define START_TOPOFF_SEC 25 /* initial trickle_sec for topoff */ | ||
73 | #define START_TRICKLE_SEC 15 /* initial trickle_sec for trickle */ | ||
74 | |||
74 | extern char power_message[POWER_MESSAGE_LEN]; | 75 | extern char power_message[POWER_MESSAGE_LEN]; |
75 | extern char charge_restart_level; | 76 | |
77 | extern int long_delta; /* long term delta battery voltage */ | ||
78 | extern int short_delta; /* short term delta battery voltage */ | ||
76 | 79 | ||
77 | extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was the charging started or stopped? */ | 80 | extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was the charging started or stopped? */ |
78 | extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */ | 81 | extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */ |
79 | 82 | ||
80 | extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */ | 83 | void enable_deep_discharge(bool on); /* deep discharge the battery */ |
84 | |||
81 | void enable_trickle_charge(bool on); | 85 | void enable_trickle_charge(bool on); |
82 | extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */ | 86 | extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */ |
83 | 87 | ||
84 | #endif /* HAVE_CHARGE_CTRL */ | 88 | #endif /* HAVE_CHARGE_CTRL */ |
85 | 89 | ||
86 | #if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200 | 90 | #if defined(HAVE_CHARGE_CTRL) || (CONFIG_BATTERY == BATT_LIION2200) |
87 | extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ | 91 | typedef enum { |
88 | #endif | 92 | DISCHARGING, |
93 | CHARGING, | ||
94 | TOPOFF, | ||
95 | TRICKLE | ||
96 | } charge_state_type; | ||
97 | |||
98 | /* tells what the charger is doing */ | ||
99 | extern charge_state_type charge_state; | ||
100 | #endif /* defined(HAVE_CHARGE_CTRL) || (CONFIG_BATTERY == BATT_LIION2200) */ | ||
89 | 101 | ||
90 | #ifdef HAVE_MMC /* Values for Ondio */ | 102 | #ifdef HAVE_MMC /* Values for Ondio */ |
91 | #define CURRENT_NORMAL 95 /* average, nearly proportional to 1/U */ | 103 | #define CURRENT_NORMAL 95 /* average, nearly proportional to 1/U */ |
@@ -95,9 +107,14 @@ extern int charge_state; /* tells what the charger is doing (for info di | |||
95 | #define CURRENT_NORMAL 145 /* usual current in mA when using the AJB including some disk/backlight/... activity */ | 107 | #define CURRENT_NORMAL 145 /* usual current in mA when using the AJB including some disk/backlight/... activity */ |
96 | #define CURRENT_USB 500 /* usual current in mA in USB mode */ | 108 | #define CURRENT_USB 500 /* usual current in mA in USB mode */ |
97 | #define CURRENT_BACKLIGHT 30 /* additional current when backlight is always on */ | 109 | #define CURRENT_BACKLIGHT 30 /* additional current when backlight is always on */ |
98 | #define CURRENT_CHARGING 300 /* charging current */ | ||
99 | #endif | ||
100 | 110 | ||
111 | #define CURRENT_MIN_CHG 70 /* minimum charge current */ | ||
112 | #define MIN_CHG_V 8500 /* at 8.5v charger voltage get CURRENT_MIN_CHG */ | ||
113 | #define CURRENT_MAX_CHG 350 /* maximum charging current */ | ||
114 | #define MAX_CHG_V 10250 /* anything over 10.25v gives CURRENT_MAX_CHG */ | ||
115 | #endif /* HAVE_MMC */ | ||
116 | |||
117 | extern unsigned int bat; /* filtered battery voltage, centivolts */ | ||
101 | extern unsigned short power_history[POWER_HISTORY_LEN]; | 118 | extern unsigned short power_history[POWER_HISTORY_LEN]; |
102 | 119 | ||
103 | /* Start up power management thread */ | 120 | /* Start up power management thread */ |
@@ -114,7 +131,7 @@ bool battery_level_safe(void); | |||
114 | 131 | ||
115 | void set_poweroff_timeout(int timeout); | 132 | void set_poweroff_timeout(int timeout); |
116 | void set_battery_capacity(int capacity); /* set local battery capacity value */ | 133 | void set_battery_capacity(int capacity); /* set local battery capacity value */ |
117 | void set_battery_type(int type); /* set local battery type */ | 134 | void set_battery_type(int type); /* set local battery type */ |
118 | 135 | ||
119 | void set_sleep_timer(int seconds); | 136 | void set_sleep_timer(int seconds); |
120 | int get_sleep_timer(void); | 137 | int get_sleep_timer(void); |