1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Moved compass health check into compass.c

This commit is contained in:
Martin Budden 2018-01-20 11:59:20 +00:00
parent ded85bfce1
commit 3116ef4008
4 changed files with 13 additions and 9 deletions

View file

@ -402,11 +402,6 @@ static bool imuIsAccelerometerHealthy(void)
return (81 < accMagnitude) && (accMagnitude < 121);
}
static bool isMagnetometerHealthy(void)
{
return (mag.magADC[X] != 0) && (mag.magADC[Y] != 0) && (mag.magADC[Z] != 0);
}
static void imuCalculateEstimatedAttitude(timeUs_t currentTimeUs)
{
static uint32_t previousIMUUpdateTime;
@ -422,9 +417,11 @@ static void imuCalculateEstimatedAttitude(timeUs_t currentTimeUs)
useAcc = true;
}
if (sensors(SENSOR_MAG) && isMagnetometerHealthy()) {
#ifdef USE_MAG
if (sensors(SENSOR_MAG) && compassIsHealthy()) {
useMag = true;
}
#endif
#if defined(USE_GPS)
else if (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