summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-01-18 16:48:54 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-01-18 16:48:54 +0000
commitccc72cc2d0de496b77aefbdf2ca62c47158e0805 (patch)
tree298f8f031aed8a603b186f911846de45808f60e1
parentb8530435ec58907aa747b423219234b003185002 (diff)
downloadrockbox-ccc72cc2d0de496b77aefbdf2ca62c47158e0805.tar.gz
rockbox-ccc72cc2d0de496b77aefbdf2ca62c47158e0805.tar.bz2
rockbox-ccc72cc2d0de496b77aefbdf2ca62c47158e0805.zip
Part of patch #1407541 to improve battery smoothing by absorbing extra precision from the battery scale factor
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8372 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/powermgmt.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index a60a35c8cb..4b3999751c 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -544,12 +544,12 @@ static void power_thread_sleep(int ticks)
*/
if (!ata_disk_is_active() || usb_inserted()) {
avgbat = avgbat - (avgbat / BATT_AVE_SAMPLES) +
- adc_read(ADC_UNREG_POWER);
+ adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR;
/*
* battery_centivolts is the centivolt-scaled filtered battery value.
*/
- battery_centivolts = ((avgbat / BATT_AVE_SAMPLES) *
- BATTERY_SCALE_FACTOR) / 10000;
+ battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000;
+
}
#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL)
/*
@@ -585,8 +585,9 @@ static void power_thread(void)
/* initialize the voltages for the exponential filter */
- avgbat = adc_read(ADC_UNREG_POWER) * BATT_AVE_SAMPLES;
- battery_centivolts = ((avgbat / BATT_AVE_SAMPLES) * BATTERY_SCALE_FACTOR) / 10000;
+ avgbat = adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR *
+ BATT_AVE_SAMPLES;
+ battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000;
#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL)
fd = -1;