summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/maemo/maemo-thread.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-01-03 23:44:38 +0000
committerThomas Martitz <kugel@rockbox.org>2012-01-03 23:44:38 +0000
commitc1bd9b0361ba92c29ceef68d74093e70a1a3e481 (patch)
tree1a42acdf2099b7f5ac06eee11e1d488b388c6d9f /firmware/target/hosted/maemo/maemo-thread.c
parent949e6398c89e3c277a4c542f67a5ee788c6f642d (diff)
downloadrockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.tar.gz
rockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.zip
Rework powermgmt to enable code re-use on appliation and sims.
* Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application) to break powermgmt.c's assumption about the ability to read battery voltage. There's now additionally percentage (android) and remaining time measure (maemo). No measure at all also works (sdl app). If voltage can't be measured, then battery_level() is king and it'll be used for power_history and runtime estimation. * Implement target's API in the simulator, i.e. _battery_voltage(), so it doesn't need to implement it's own powermgmt.c and other stubs. Now the sim behaves much more like a native target, although it still changes the simulated battery voltage quickly, * Other changes include include renaming battery_adc_voltage() to _battery_voltage(), for consistency with the new target functions and making some of the apps code aware that voltage and runtime estimation is not always available. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/maemo/maemo-thread.c')
-rw-r--r--firmware/target/hosted/maemo/maemo-thread.c30
1 files changed, 2 insertions, 28 deletions
diff --git a/firmware/target/hosted/maemo/maemo-thread.c b/firmware/target/hosted/maemo/maemo-thread.c
index a32a563459..2f1d033baa 100644
--- a/firmware/target/hosted/maemo/maemo-thread.c
+++ b/firmware/target/hosted/maemo/maemo-thread.c
@@ -163,40 +163,14 @@ int maemo_thread_func (void *wait_for_osso_startup)
163 return 0; 163 return 0;
164} 164}
165 165
166/** Rockbox battery related functions */
167void battery_status_update(void)
168{
169 battery_percent = maemo_battery_level;
170 send_battery_level_event();
171}
172
173/* Returns true if any power input is connected - charging-capable
174 * or not. */
175bool power_input_present(void)
176{
177 return false;
178}
179
180unsigned battery_voltage(void)
181{
182 return 0;
183}
184
185/* Returns battery level in percent */ 166/* Returns battery level in percent */
186int battery_level(void) 167int _battery_level(void)
187{ 168{
188 battery_status_update();
189 return maemo_battery_level; 169 return maemo_battery_level;
190} 170}
191 171
192/* Return remaining battery time in minutes */ 172/* Return remaining battery time in minutes */
193int battery_time(void) 173int _battery_time(void)
194{ 174{
195 battery_status_update();
196 return maemo_remaining_time_sec / 60; 175 return maemo_remaining_time_sec / 60;
197} 176}
198
199bool battery_level_safe(void)
200{
201 return battery_level() >= 5;
202}