diff options
author | Heikki Hannikainen <hessuh@rockbox.org> | 2002-08-13 16:06:29 +0000 |
---|---|---|
committer | Heikki Hannikainen <hessuh@rockbox.org> | 2002-08-13 16:06:29 +0000 |
commit | 9872b66cd100dce18e2e6f4f77ee2beaa50b8075 (patch) | |
tree | 6f76e19ceb058560c956a679bc716d6a14c61939 | |
parent | 677c5cc3b585853a81f1718e603a2b5d93d5b5c8 (diff) | |
download | rockbox-9872b66cd100dce18e2e6f4f77ee2beaa50b8075.tar.gz rockbox-9872b66cd100dce18e2e6f4f77ee2beaa50b8075.zip |
Use average of two samples at both ends of the range for calculating smoother delta values.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1716 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/debug_menu.c | 8 | ||||
-rw-r--r-- | firmware/powermgmt.c | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index cc1ca2ccda..c557129f86 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -507,15 +507,19 @@ void view_battery(void) | |||
507 | lcd_puts(0, 4, buf); | 507 | lcd_puts(0, 4, buf); |
508 | #endif | 508 | #endif |
509 | y = ( power_history[POWER_HISTORY_LEN-1] * 100 | 509 | y = ( power_history[POWER_HISTORY_LEN-1] * 100 |
510 | + power_history[POWER_HISTORY_LEN-2] * 100 | ||
511 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1] * 100 | ||
510 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 ) | 512 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 ) |
511 | / CHARGE_END_NEGD; | 513 | / CHARGE_END_NEGD / 2; |
512 | 514 | ||
513 | snprintf(buf, 30, "short delta: %d", y); | 515 | snprintf(buf, 30, "short delta: %d", y); |
514 | lcd_puts(0, 5, buf); | 516 | lcd_puts(0, 5, buf); |
515 | 517 | ||
516 | y = ( power_history[POWER_HISTORY_LEN-1] * 100 | 518 | y = ( power_history[POWER_HISTORY_LEN-1] * 100 |
519 | + power_history[POWER_HISTORY_LEN-2] * 100 | ||
520 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD+1] * 100 | ||
517 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 ) | 521 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 ) |
518 | / CHARGE_END_ZEROD; | 522 | / CHARGE_END_ZEROD / 2; |
519 | 523 | ||
520 | snprintf(buf, 30, "long delta: %d", y); | 524 | snprintf(buf, 30, "long delta: %d", y); |
521 | lcd_puts(0, 6, buf); | 525 | lcd_puts(0, 6, buf); |
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 41bd1c4dec..df796f9140 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -179,8 +179,10 @@ static void power_thread(void) | |||
179 | * 0.0005 V). | 179 | * 0.0005 V). |
180 | */ | 180 | */ |
181 | delta = ( power_history[POWER_HISTORY_LEN-1] * 100 | 181 | delta = ( power_history[POWER_HISTORY_LEN-1] * 100 |
182 | + power_history[POWER_HISTORY_LEN-2] * 100 | ||
183 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1] * 100 | ||
182 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 ) | 184 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 ) |
183 | / CHARGE_END_NEGD; | 185 | / CHARGE_END_NEGD / 2; |
184 | 186 | ||
185 | if (delta < -100) { /* delta < -10 mV */ | 187 | if (delta < -100) { /* delta < -10 mV */ |
186 | DEBUGF("power: short-term negative delta, enough!\n"); | 188 | DEBUGF("power: short-term negative delta, enough!\n"); |
@@ -189,8 +191,10 @@ static void power_thread(void) | |||
189 | } else { | 191 | } else { |
190 | /* if we didn't disable the charger in the previous test, check for low positive delta */ | 192 | /* if we didn't disable the charger in the previous test, check for low positive delta */ |
191 | delta = ( power_history[POWER_HISTORY_LEN-1] * 100 | 193 | delta = ( power_history[POWER_HISTORY_LEN-1] * 100 |
194 | + power_history[POWER_HISTORY_LEN-2] * 100 | ||
195 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD+1] * 100 | ||
192 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 ) | 196 | - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 ) |
193 | / CHARGE_END_ZEROD; | 197 | / CHARGE_END_ZEROD / 2; |
194 | 198 | ||
195 | if (delta < 1) { /* delta < 0.1 mV */ | 199 | if (delta < 1) { /* delta < 0.1 mV */ |
196 | DEBUGF("power: long-term small positive delta, enough!\n"); | 200 | DEBUGF("power: long-term small positive delta, enough!\n"); |