From 18b857de6565be59d020b17c244b5986bf0e8aae Mon Sep 17 00:00:00 2001 From: etracer65 Date: Wed, 7 Mar 2018 15:48:22 -0500 Subject: [PATCH] Correct nested if else for USE_MAG and USE_GPS (#5414) If USE_MAG was undefined but USE_GPS was defined, then the "else if" would incorrectly apply to a condition above making the USE_GPS section unlikely to execute. --- src/main/flight/imu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/flight/imu.c b/src/main/flight/imu.c index 68f6917a6..aa71a5ba5 100644 --- a/src/main/flight/imu.c +++ b/src/main/flight/imu.c @@ -428,7 +428,7 @@ static void imuCalculateEstimatedAttitude(timeUs_t currentTimeUs) } #endif #if defined(USE_GPS) - else if (STATE(FIXED_WING) && sensors(SENSOR_GPS) && STATE(GPS_FIX) && gpsSol.numSat >= 5 && gpsSol.groundSpeed >= 300) { + if (!useMag && STATE(FIXED_WING) && sensors(SENSOR_GPS) && STATE(GPS_FIX) && gpsSol.numSat >= 5 && gpsSol.groundSpeed >= 300) { // In case of a fixed-wing aircraft we can use GPS course over ground to correct heading rawYawError = DECIDEGREES_TO_RADIANS(attitude.values.yaw - gpsSol.groundCourse); useYaw = true;