1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 03:50:02 +03:00

corrected magnetometer alignment bug found by CrashPilot1000 - during mag calibration, axes must be swapped per sensor alignment, which didn't happen.

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@336 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop@gmail.com 2013-06-12 02:45:56 +00:00
parent 5de9dc47e0
commit 58d362d33e
3 changed files with 22 additions and 14 deletions

View file

@ -107,7 +107,7 @@ retry:
gyro.init();
#ifdef MAG
if (!hmc5883lDetect())
if (!hmc5883lDetect(mcfg.align[ALIGN_MAG]))
sensorsClear(SENSOR_MAG);
#endif
@ -402,19 +402,13 @@ void Gyro_getADC(void)
}
#ifdef MAG
static float magCal[3] = { 1.0, 1.0, 1.0 }; // gain for each axis, populated at sensor init
static float magCal[3] = { 1.0f, 1.0f, 1.0f }; // gain for each axis, populated at sensor init
static uint8_t magInit = 0;
static void Mag_getRawADC(void)
{
// MAG driver will align itself, so no need to alignSensors()
hmc5883lRead(magADC);
// Default mag orientation is -2, -3, 1 or
// no way? is THIS finally the proper orientation?? (by GrootWitBaas)
// magADC[ROLL] = rawADC[2]; // X
// magADC[PITCH] = -rawADC[0]; // Y
// magADC[YAW] = -rawADC[1]; // Z
alignSensors(ALIGN_MAG, magADC);
}
void Mag_init(void)