![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rev 1.0
Fork of FRDM-K64_AccelMag by
Diff: main.cpp
- Revision:
- 1:744ec0ebf949
- Parent:
- 0:90ba5c73bcfb
--- a/main.cpp Wed Jul 09 19:28:51 2014 +0000 +++ b/main.cpp Wed Dec 06 13:29:49 2017 +0000 @@ -1,40 +1,45 @@ #include "mbed.h" #include "FXOS8700Q.h" -//I2C lines for FXOS8700Q accelerometer/magnetometer +//I2C line for FXOS8700Q accelerometer FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); +//I2C line for FXOS8700Q magnetometer FXOS8700Q_mag mag( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); -//Temrinal enable +//Terminal communication init. Serial pc(USBTX, USBRX); -MotionSensorDataUnits mag_data; -MotionSensorDataUnits acc_data; +//Accelerometer data variables +//MotionSensorDataUnits mag_data; +//MotionSensorDataUnits acc_data; int main() { - float faX, faY, faZ; - float fmX, fmY, fmZ; - + float accelX, accelY, accelZ; + float magnetoX, magnetoY, magnetoZ; + + //Enable Accelerometer acc.enable(); - printf("\r\n\nFXOS8700Q Who Am I= %X\r\n", acc.whoAmI()); + printf("\r\n\nFXOS8700Q Address on I2C bus = %X\r\n", acc.whoAmI()); while (true) - { - acc.getAxis(acc_data); - mag.getAxis(mag_data); - printf("FXOS8700Q ACC: X=%1.4f Y=%1.4f Z=%1.4f ", acc_data.x, acc_data.y, acc_data.z); - printf(" MAG: X=%4.1f Y=%4.1f Z=%4.1f\r\n", mag_data.x, mag_data.y, mag_data.z); - acc.getX(&faX); - acc.getY(&faY); - acc.getZ(&faZ); - mag.getX(&fmX); - mag.getY(&fmY); - mag.getZ(&fmZ); - printf("FXOS8700Q ACC: X=%1.4f Y=%1.4f Z=%1.4f ", faX, faY, faZ); - printf(" MAG: X=%4.1f Y=%4.1f Z=%4.1f\r\n", fmX, fmY, fmZ); - - wait(1.0); + { + /* GET AXIS VALUES FROM ACCELEROMETER AND MAGNETOMETER*/ + acc.getX(&accelX); + //acc.getY(&accelY); + //acc.getZ(&accelZ); + //mag.getX(&magnetoX); + //mag.getY(&magnetoY); + //mag.getZ(&magnetoZ); + /* SCALE AXIS VALUES TO DEGREES*/ + accelX *= 90; + //accelY *= 180; + //accelZ *= 180; + /* PRINT THOSE VALUES */ + //printf("FXOS8700Q ACC: X=%1.2f' Y=%1.2f' Z=%1.2f' ", accelX, accelY, accelZ); + //printf(" MAG: X=%4.1f Y=%4.1f Z=%4.1f\r\n", magnetoX, magnetoY, magnetoZ); + printf("AccelX: %1.2f\n\r",accelX); + wait(1.0); //delay } } \ No newline at end of file