mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Add magnetic heading as debug and magnetic declination for the Mahony filter (#13073)
* Add mag heading to GPS Rescue heading debug * Roll and pitch compensated magnetic yaw * Changes according to PR comments * Encapsulate yawMag calculations * Corrected naming * Changes according to PR comments * Changes so that Checks don't fail * Added PARAM_NAME list * Changes so that Checks don't fail * Changes according to PR comments * Update src/main/fc/parameter_names.h Co-authored-by: Mark Haslinghuis <mark@numloq.nl> * Changes according to PR comments * 200Hz compass task * fix wait status flag * increase default ODR of HMC5883L to 75Hz * fix spikes in MagYaw debug by re-calc only on new data --------- Co-authored-by: ctzsnooze <chris.thompson@sydney.edu.au> Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
This commit is contained in:
parent
1856d6f7ef
commit
9ada5638a3
10 changed files with 96 additions and 32 deletions
|
@ -117,6 +117,7 @@ void pgResetFn_compassConfig(compassConfig_t *compassConfig)
|
|||
}
|
||||
|
||||
static int16_t magADCRaw[XYZ_AXIS_COUNT];
|
||||
static int16_t magADCRawPrevious[XYZ_AXIS_COUNT];
|
||||
static uint8_t magInit = 0;
|
||||
|
||||
void compassPreInit(void)
|
||||
|
@ -375,12 +376,17 @@ uint32_t compassUpdate(timeUs_t currentTimeUs)
|
|||
if (busBusy(&magDev.dev, NULL) || !magDev.read(&magDev, magADCRaw)) {
|
||||
// No action was taken as the read has not completed
|
||||
schedulerIgnoreTaskExecRate();
|
||||
return 1000; // Wait 1ms between states
|
||||
return 500; // Wait 500us between states
|
||||
}
|
||||
|
||||
for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) {
|
||||
if (magADCRaw[axis] != magADCRawPrevious[axis]) {
|
||||
// this test, and the isNewMagADCFlag itself, is only needed if we calculate magYaw in imu.c
|
||||
mag.isNewMagADCFlag = true;
|
||||
}
|
||||
mag.magADC[axis] = magADCRaw[axis];
|
||||
}
|
||||
|
||||
if (magDev.magAlignment == ALIGN_CUSTOM) {
|
||||
alignSensorViaMatrix(mag.magADC, &magDev.rotationMatrix);
|
||||
} else {
|
||||
|
@ -413,6 +419,6 @@ uint32_t compassUpdate(timeUs_t currentTimeUs)
|
|||
}
|
||||
}
|
||||
|
||||
return TASK_PERIOD_HZ(10);
|
||||
return TASK_PERIOD_HZ(TASK_COMPASS_RATE_HZ);
|
||||
}
|
||||
#endif // USE_MAG
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue