|
Rockbox mail archiveSubject: [Patch] non-jumping battery level indicator[Patch] non-jumping battery level indicator
From: Uwe Freese <mail_at_uwe-freese.de>
Date: Wed, 31 Jul 2002 21:20:14 +0200 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 _at__at_ -24,6 +24,8 _at__at_ #ifndef SIMULATOR +int battery_level_last = 0; + bool charger_inserted(void) { #ifdef ARCHOS_RECORDER _at__at_ -48,7 +50,10 _at__at_ 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) Received on 2002-07-31 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |