From 565df5ec94450511d60299fa425dbfaa48a37119 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 28 Sep 2018 11:08:52 -0700 Subject: [PATCH] AP_Compass: AK09916: use common method to accumulate samples --- libraries/AP_Compass/AP_Compass_AK09916.cpp | 32 ++------------------- libraries/AP_Compass/AP_Compass_AK09916.h | 2 -- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass_AK09916.cpp b/libraries/AP_Compass/AP_Compass_AK09916.cpp index 7efe4ddb17..5b6f82fd85 100644 --- a/libraries/AP_Compass/AP_Compass_AK09916.cpp +++ b/libraries/AP_Compass/AP_Compass_AK09916.cpp @@ -228,20 +228,7 @@ void AP_Compass_AK09916::timer() field(data.magx * range_scale, data.magy * range_scale, data.magz * range_scale); - /* rotate raw_field from sensor frame to body frame */ - rotate_field(field, compass_instance); - - /* publish raw_field (uncorrected point sample) for calibration use */ - publish_raw_field(field, compass_instance); - - /* correct raw_field for known errors */ - correct_field(field, compass_instance); - - if (_sem->take(HAL_SEMAPHORE_BLOCK_FOREVER)) { - accum += field; - accum_count++; - _sem->give(); - } + accumulate_sample(field, compass_instance); check_registers: dev->check_next_register(); @@ -249,20 +236,5 @@ check_registers: void AP_Compass_AK09916::read() { - if (!_sem->take_nonblocking()) { - return; - } - if (accum_count == 0) { - _sem->give(); - return; - } - - accum /= accum_count; - - publish_filtered_field(accum, compass_instance); - - accum.zero(); - accum_count = 0; - - _sem->give(); + drain_accumulated_samples(compass_instance); } diff --git a/libraries/AP_Compass/AP_Compass_AK09916.h b/libraries/AP_Compass/AP_Compass_AK09916.h index 0656949582..8dc63f4f25 100644 --- a/libraries/AP_Compass/AP_Compass_AK09916.h +++ b/libraries/AP_Compass/AP_Compass_AK09916.h @@ -70,8 +70,6 @@ private: void timer(); uint8_t compass_instance; - Vector3f accum; - uint16_t accum_count; bool force_external; enum Rotation rotation; };