diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-30 01:26:59 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-12-05 15:11:34 -0500 |
commit | f02cd18ad027cdb4992a19a16cfbd336ffb63124 (patch) | |
tree | a412532ad38baac5390015d89696a5f67eaabe57 /firmware/export | |
parent | 8a8dfa0e52d0d7001d52ff29a2da60986b3e5101 (diff) | |
download | rockbox-f02cd18ad027cdb4992a19a16cfbd336ffb63124.tar.gz rockbox-f02cd18ad027cdb4992a19a16cfbd336ffb63124.zip |
powermgmt: Refactor battery current estimation
Create a new battery_current() function to report the
the battery's charging/discharging current. Move the
old runcurrent() implementation into it and clean up
some of the related defines.
Change-Id: I7dbe5b6532d291fa72add1cb23b30e3cbac8c3ca
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/config/iaudiox5.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipod6g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/mrobe500.h | 2 | ||||
-rw-r--r-- | firmware/export/config/samsungypr0.h | 1 | ||||
-rw-r--r-- | firmware/export/config/samsungypr1.h | 1 | ||||
-rw-r--r-- | firmware/export/powermgmt.h | 19 |
6 files changed, 8 insertions, 17 deletions
diff --git a/firmware/export/config/iaudiox5.h b/firmware/export/config/iaudiox5.h index 0164cd20fa..cae83dd952 100644 --- a/firmware/export/config/iaudiox5.h +++ b/firmware/export/config/iaudiox5.h | |||
@@ -151,6 +151,7 @@ | |||
151 | #define CURRENT_NORMAL 65 /*2250mah/35h = 65 ma*/ | 151 | #define CURRENT_NORMAL 65 /*2250mah/35h = 65 ma*/ |
152 | #define CURRENT_BACKLIGHT 25 | 152 | #define CURRENT_BACKLIGHT 25 |
153 | #define CURRENT_REMOTE 8 /* additional current when remote connected */ | 153 | #define CURRENT_REMOTE 8 /* additional current when remote connected */ |
154 | #define CURRENT_RECORD 2 /* FIXME: placeholder value */ | ||
154 | 155 | ||
155 | /* Define this if your LCD can set contrast */ | 156 | /* Define this if your LCD can set contrast */ |
156 | #define HAVE_LCD_CONTRAST | 157 | #define HAVE_LCD_CONTRAST |
diff --git a/firmware/export/config/ipod6g.h b/firmware/export/config/ipod6g.h index fdf7e8e516..2e4afbdf63 100644 --- a/firmware/export/config/ipod6g.h +++ b/firmware/export/config/ipod6g.h | |||
@@ -158,6 +158,7 @@ | |||
158 | /* define current usage levels */ | 158 | /* define current usage levels */ |
159 | #define CURRENT_NORMAL 18 /* playback @48MHz clock, backlight off */ | 159 | #define CURRENT_NORMAL 18 /* playback @48MHz clock, backlight off */ |
160 | #define CURRENT_BACKLIGHT 23 /* maximum brightness */ | 160 | #define CURRENT_BACKLIGHT 23 /* maximum brightness */ |
161 | #define CURRENT_RECORD 2 /* FIXME: placeholder value */ | ||
161 | 162 | ||
162 | /* define this if the unit can be powered or charged via USB */ | 163 | /* define this if the unit can be powered or charged via USB */ |
163 | #define HAVE_USB_POWER | 164 | #define HAVE_USB_POWER |
diff --git a/firmware/export/config/mrobe500.h b/firmware/export/config/mrobe500.h index a7d72f76ac..ffc8a6bfb8 100644 --- a/firmware/export/config/mrobe500.h +++ b/firmware/export/config/mrobe500.h | |||
@@ -198,7 +198,7 @@ | |||
198 | /* define current usage levels */ | 198 | /* define current usage levels */ |
199 | #define CURRENT_NORMAL 85 /* Measured */ | 199 | #define CURRENT_NORMAL 85 /* Measured */ |
200 | #define CURRENT_BACKLIGHT 200 /* Over 200 mA total measured when on */ | 200 | #define CURRENT_BACKLIGHT 200 /* Over 200 mA total measured when on */ |
201 | #define CURRENT_RECORD 0 /* no recording */ | 201 | #define CURRENT_REMOTE 2 /* FIXME: placeholder value */ |
202 | 202 | ||
203 | /* Hardware controlled charging with monitoring */ | 203 | /* Hardware controlled charging with monitoring */ |
204 | #define CONFIG_CHARGING CHARGING_MONITOR | 204 | #define CONFIG_CHARGING CHARGING_MONITOR |
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h index 520eb08d01..88ba96504d 100644 --- a/firmware/export/config/samsungypr0.h +++ b/firmware/export/config/samsungypr0.h | |||
@@ -121,6 +121,7 @@ | |||
121 | /* Define current usage levels. */ | 121 | /* Define current usage levels. */ |
122 | #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ | 122 | #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ |
123 | #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ | 123 | #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ |
124 | #define CURRENT_RECORD 2 /* FIXME: placeholder value */ | ||
124 | 125 | ||
125 | #endif /* SIMULATOR */ | 126 | #endif /* SIMULATOR */ |
126 | 127 | ||
diff --git a/firmware/export/config/samsungypr1.h b/firmware/export/config/samsungypr1.h index 50abfa323e..8ef76d60af 100644 --- a/firmware/export/config/samsungypr1.h +++ b/firmware/export/config/samsungypr1.h | |||
@@ -163,5 +163,6 @@ | |||
163 | /* Define current usage levels. */ | 163 | /* Define current usage levels. */ |
164 | #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ | 164 | #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ |
165 | #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ | 165 | #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ |
166 | #define CURRENT_RECORD 2 /* FIXME: placeholder value */ | ||
166 | 167 | ||
167 | #endif /* SIMULATOR */ | 168 | #endif /* SIMULATOR */ |
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index a4b924915c..c6fc3d5bdf 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -81,28 +81,13 @@ void powermgmt_init(void) INIT_ATTR; | |||
81 | /* Generic current values that are intentionally meaningless - config header | 81 | /* Generic current values that are intentionally meaningless - config header |
82 | * should define proper numbers.*/ | 82 | * should define proper numbers.*/ |
83 | 83 | ||
84 | |||
85 | #ifndef CURRENT_BACKLIGHT | ||
86 | #define CURRENT_BACKLIGHT 5 /* additional current when backlight always on */ | ||
87 | #endif | ||
88 | |||
89 | #if defined(HAVE_RECORDING) && !defined(CURRENT_RECORD) | ||
90 | #define CURRENT_RECORD 2 /* additional recording current */ | ||
91 | #endif /* HAVE_RECORDING && !CURRENT_RECORD*/ | ||
92 | |||
93 | #ifndef CURRENT_USB | 84 | #ifndef CURRENT_USB |
94 | #define CURRENT_USB 2 /* usual current in mA in USB mode */ | 85 | #define CURRENT_USB 2 /* usual current in mA in USB mode */ |
95 | #endif | 86 | #endif |
96 | 87 | ||
97 | #if defined(HAVE_REMOTE_LCD) && !defined(CURRENT_REMOTE) | 88 | #if CONFIG_CHARGING && !defined(CURRENT_MAX_CHG) |
98 | #define CURRENT_REMOTE 2 /* additional current when remote connected */ | ||
99 | #endif /* CURRENT_REMOTE && !HAVE_REMOTE_LCD */ | ||
100 | |||
101 | #if CONFIG_CHARGING | ||
102 | #ifndef CURRENT_MAX_CHG | ||
103 | #define CURRENT_MAX_CHG 350 /* maximum charging current */ | 89 | #define CURRENT_MAX_CHG 350 /* maximum charging current */ |
104 | #endif | 90 | #endif |
105 | #endif /* CONFIG_CHARGING */ | ||
106 | 91 | ||
107 | #ifndef BATT_AVE_SAMPLES | 92 | #ifndef BATT_AVE_SAMPLES |
108 | /* slw filter constant unless otherwise specified */ | 93 | /* slw filter constant unless otherwise specified */ |
@@ -126,6 +111,8 @@ extern const unsigned short percent_to_volt_charge[11]; | |||
126 | int battery_level(void); /* percent */ | 111 | int battery_level(void); /* percent */ |
127 | int battery_time(void); /* minutes */ | 112 | int battery_time(void); /* minutes */ |
128 | int battery_voltage(void); /* filtered batt. voltage in millivolts */ | 113 | int battery_voltage(void); /* filtered batt. voltage in millivolts */ |
114 | int battery_current(void); /* battery current in milliamps | ||
115 | * (may just be a rough estimate) */ | ||
129 | 116 | ||
130 | /* Implemented by the target, unfiltered */ | 117 | /* Implemented by the target, unfiltered */ |
131 | int _battery_level(void); /* percent */ | 118 | int _battery_level(void); /* percent */ |