From 33cc7bc45f1e30ef77d2ed6c4aaf9822baca7c86 Mon Sep 17 00:00:00 2001 From: "Konstantin Sharlaimov (DigitalEntity)" Date: Mon, 9 May 2016 21:28:42 +1000 Subject: [PATCH] Remove useless code in compass.c --- src/main/sensors/compass.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index c03068086..860398c9b 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -68,24 +68,17 @@ bool isCompassReady(void) static sensorCalibrationState_t calState; -#define COMPASS_UPDATE_FREQUENCY_10HZ (1000 * 100) - void updateCompass(flightDynamicsTrims_t *magZero) { - static uint32_t nextUpdateAt, calStartedAt = 0; + static uint32_t calStartedAt = 0; static int16_t magPrev[XYZ_AXIS_COUNT]; uint32_t axis; - if ((int32_t)(currentTime - nextUpdateAt) < 0) - return; - - nextUpdateAt = currentTime + COMPASS_UPDATE_FREQUENCY_10HZ; - mag.read(magADCRaw); for (axis = 0; axis < XYZ_AXIS_COUNT; axis++) magADC[axis] = magADCRaw[axis]; // int32_t copy to work with if (STATE(CALIBRATE_MAG)) { - calStartedAt = nextUpdateAt; + calStartedAt = currentTime; for (axis = 0; axis < 3; axis++) { magZero->raw[axis] = 0; @@ -103,7 +96,7 @@ void updateCompass(flightDynamicsTrims_t *magZero) } if (calStartedAt != 0) { - if ((nextUpdateAt - calStartedAt) < 30000000) { // 30s: you have 30s to turn the multi in all directions + if ((currentTime - calStartedAt) < 30000000) { // 30s: you have 30s to turn the multi in all directions LED0_TOGGLE; float diffMag = 0; -- 2.11.4.GIT