From cfca75204f723b9c44d93e81a80a8b46fa516f9a Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Sat, 25 Nov 2017 08:37:25 +0000 Subject: [PATCH] Removed unnecessary acc calculation when no alt hold --- src/main/flight/imu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/flight/imu.c b/src/main/flight/imu.c index 851c083e0..3e8a1f952 100644 --- a/src/main/flight/imu.c +++ b/src/main/flight/imu.c @@ -178,6 +178,7 @@ void imuResetAccelerationSum(void) accTimeSum = 0; } +#if defined(USE_ALT_HOLD) static void imuTransformVectorBodyToEarth(t_fp_vector * v) { /* From body frame to earth frame */ @@ -227,6 +228,7 @@ static void imuCalculateAcceleration(uint32_t deltaT) accTimeSum += deltaT; accSumCount++; } +#endif // USE_ALT_HOLD static float invSqrt(float x) { @@ -452,7 +454,9 @@ static void imuCalculateEstimatedAttitude(timeUs_t currentTimeUs) imuUpdateEulerAngles(); #endif +#if defined(USE_ALT_HOLD) imuCalculateAcceleration(deltaT); // rotate acc vector into earth frame +#endif } void imuUpdateAttitude(timeUs_t currentTimeUs)