forked from len0rd/rockbox
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
This commit is contained in:
parent
677c5cc3b5
commit
9872b66cd1
2 changed files with 12 additions and 4 deletions
|
@ -507,15 +507,19 @@ void view_battery(void)
|
||||||
lcd_puts(0, 4, buf);
|
lcd_puts(0, 4, buf);
|
||||||
#endif
|
#endif
|
||||||
y = ( power_history[POWER_HISTORY_LEN-1] * 100
|
y = ( power_history[POWER_HISTORY_LEN-1] * 100
|
||||||
|
+ power_history[POWER_HISTORY_LEN-2] * 100
|
||||||
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1] * 100
|
||||||
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 )
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 )
|
||||||
/ CHARGE_END_NEGD;
|
/ CHARGE_END_NEGD / 2;
|
||||||
|
|
||||||
snprintf(buf, 30, "short delta: %d", y);
|
snprintf(buf, 30, "short delta: %d", y);
|
||||||
lcd_puts(0, 5, buf);
|
lcd_puts(0, 5, buf);
|
||||||
|
|
||||||
y = ( power_history[POWER_HISTORY_LEN-1] * 100
|
y = ( power_history[POWER_HISTORY_LEN-1] * 100
|
||||||
|
+ power_history[POWER_HISTORY_LEN-2] * 100
|
||||||
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD+1] * 100
|
||||||
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 )
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 )
|
||||||
/ CHARGE_END_ZEROD;
|
/ CHARGE_END_ZEROD / 2;
|
||||||
|
|
||||||
snprintf(buf, 30, "long delta: %d", y);
|
snprintf(buf, 30, "long delta: %d", y);
|
||||||
lcd_puts(0, 6, buf);
|
lcd_puts(0, 6, buf);
|
||||||
|
|
|
@ -179,8 +179,10 @@ static void power_thread(void)
|
||||||
* 0.0005 V).
|
* 0.0005 V).
|
||||||
*/
|
*/
|
||||||
delta = ( power_history[POWER_HISTORY_LEN-1] * 100
|
delta = ( power_history[POWER_HISTORY_LEN-1] * 100
|
||||||
|
+ power_history[POWER_HISTORY_LEN-2] * 100
|
||||||
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1] * 100
|
||||||
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 )
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 )
|
||||||
/ CHARGE_END_NEGD;
|
/ CHARGE_END_NEGD / 2;
|
||||||
|
|
||||||
if (delta < -100) { /* delta < -10 mV */
|
if (delta < -100) { /* delta < -10 mV */
|
||||||
DEBUGF("power: short-term negative delta, enough!\n");
|
DEBUGF("power: short-term negative delta, enough!\n");
|
||||||
|
@ -189,8 +191,10 @@ static void power_thread(void)
|
||||||
} else {
|
} else {
|
||||||
/* if we didn't disable the charger in the previous test, check for low positive delta */
|
/* if we didn't disable the charger in the previous test, check for low positive delta */
|
||||||
delta = ( power_history[POWER_HISTORY_LEN-1] * 100
|
delta = ( power_history[POWER_HISTORY_LEN-1] * 100
|
||||||
|
+ power_history[POWER_HISTORY_LEN-2] * 100
|
||||||
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD+1] * 100
|
||||||
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 )
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 )
|
||||||
/ CHARGE_END_ZEROD;
|
/ CHARGE_END_ZEROD / 2;
|
||||||
|
|
||||||
if (delta < 1) { /* delta < 0.1 mV */
|
if (delta < 1) { /* delta < 0.1 mV */
|
||||||
DEBUGF("power: long-term small positive delta, enough!\n");
|
DEBUGF("power: long-term small positive delta, enough!\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue