Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: [Patch] non-jumping battery level indicator
From: Uwe Freese (mail_at_uwe-freese.de)
Date: 2002-07-31


Hello,

I changed the battery level procedure so that an average of the battery
level is made. It works very well here. Now the level indicator doesn't
jump up and down so quickly.

Note: Now the function does not return the actual voltage level anymore.
So it shouldn't be used for a recharging algorithm, i think. Maybe the
average calculation should be somewhere else?? Or there should be
another function battery_level_avg instead?

Bye, Uwe.

--- power.c.old Mon Jul 29 14:54:57 2002
+++ power.c Wed Jul 31 21:02:06 2002
@@ -24,6 +24,8 @@

 #ifndef SIMULATOR

+int battery_level_last = 0;
+
 bool charger_inserted(void)
 {
 #ifdef ARCHOS_RECORDER
@@ -48,7 +50,10 @@
     if(level < BATTERY_LEVEL_EMPTY)
         level = BATTERY_LEVEL_EMPTY;

- return ((level-BATTERY_LEVEL_EMPTY) * 100) / BATTERY_RANGE;
+ /* make average out of actual and last level */
+ battery_level_last = battery_level_last == 0 ? level : (level * 1 + battery_level_last * 19) / 20;
+
+ return ((battery_level_last-BATTERY_LEVEL_EMPTY) * 100) / BATTERY_RANGE;
 }

 bool battery_level_safe(void)



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa