Added fusionGetOrientation function to Adafruit 9-dof imu in imu.ino

This commit is contained in:
Patrick Goebel 2016-09-12 05:40:22 -07:00
parent 9bcf7fff88
commit b8931b271d

View File

@ -43,21 +43,30 @@
data.gx = event.gyro.x;
data.gy = event.gyro.y;
data.gz = event.gyro.z;
/*
if (dof.accelGetOrientation(&accel_event, &orientation))
{
/* 'orientation' should have valid .roll and .pitch fields */
data.roll = orientation.roll;
data.pitch = orientation.pitch;
}
*/
/* Calculate the heading using the magnetometer */
mag.getEvent(&mag_event);
/*
if (dof.magGetOrientation(SENSOR_AXIS_Z, &mag_event, &orientation))
{
/* 'orientation' should have valid .heading data now */
data.mz = orientation.heading;
}
*/
if (dof.fusionGetOrientation(&accel_event, &mag_event, &orientation))
{
data.roll = orientation.roll;
data.pitch = orientation.pitch;
data.ch = orientation.heading;
}
return data;
}