mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Fixed magAlign, reconfigureAlignment was being called before mag
detection. Closes #101.
This commit is contained in:
parent
a65a937313
commit
3d7455d557
1 changed files with 10 additions and 8 deletions
|
@ -393,6 +393,16 @@ bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t
|
|||
detectAcc(accHardwareToUse);
|
||||
detectBaro();
|
||||
|
||||
#ifdef MAG
|
||||
if (hmc5883lDetect()) {
|
||||
#ifdef NAZE
|
||||
magAlign = CW180_DEG;
|
||||
#endif
|
||||
} else {
|
||||
sensorsClear(SENSOR_MAG);
|
||||
}
|
||||
#endif
|
||||
|
||||
reconfigureAlignment(sensorAlignmentConfig);
|
||||
|
||||
// Now time to init things, acc first
|
||||
|
@ -401,14 +411,6 @@ bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t
|
|||
// this is safe because either mpu6050 or mpu3050 or lg3d20 sets it, and in case of fail, we never get here.
|
||||
gyro.init();
|
||||
|
||||
#ifdef MAG
|
||||
if (hmc5883lDetect()) {
|
||||
magAlign = CW180_DEG; // default NAZE alignment
|
||||
} else {
|
||||
sensorsClear(SENSOR_MAG);
|
||||
}
|
||||
#endif
|
||||
|
||||
// FIXME extract to a method to reduce dependencies, maybe move to sensors_compass.c
|
||||
if (sensors(SENSOR_MAG)) {
|
||||
// calculate magnetic declination
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue