From 8e0128a2b206c2d7a49e28a8b730e90611fe2405 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Mon, 1 Oct 2018 10:27:48 -0400 Subject: [PATCH] Fix ordering of gyro filtering and overflow/yaw-spin logic Since the gyro overflow and yaw-spin logic uses filtered gyro data they need to be after the filter application. Currently the logic is before causing it to operate on one sample old data. This won't prevent the logic from working and it's not a critical fix, but it's better to have the checks after the filtering. --- src/main/sensors/gyro.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 8275368e51..bf396e58a0 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -949,6 +949,12 @@ static FAST_CODE FAST_CODE_NOINLINE void gyroUpdateSensor(gyroSensor_t *gyroSens return; } + if (gyroDebugMode == DEBUG_NONE) { + filterGyro(gyroSensor); + } else { + filterGyroDebug(gyroSensor); + } + #ifdef USE_GYRO_OVERFLOW_CHECK if (gyroConfig()->checkOverflow && !gyroHasOverflowProtection) { checkForOverflow(gyroSensor, currentTimeUs); @@ -961,12 +967,6 @@ static FAST_CODE FAST_CODE_NOINLINE void gyroUpdateSensor(gyroSensor_t *gyroSens } #endif - if (gyroDebugMode == DEBUG_NONE) { - filterGyro(gyroSensor); - } else { - filterGyroDebug(gyroSensor); - } - #ifdef USE_GYRO_DATA_ANALYSE if (isDynamicFilterActive()) { gyroDataAnalyse(&gyroSensor->gyroAnalyseState, gyroSensor->notchFilterDyn);