Jim Carver
/
Hello_FXOS8700Q
A Simple Hello World for the FXAS8700Q combination accelerometer / magnetometer
Revision 6:02bfeec82bc1, committed 2014-04-25
- Comitter:
- JimCarver
- Date:
- Fri Apr 25 16:47:00 2014 +0000
- Parent:
- 5:061ab9f2c002
- Commit message:
- Version 2.0, this version uses the FXOS8700Q library which implements the MotionSensor virtual class
Changed in this revision
FXOS8700Q.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 061ab9f2c002 -r 02bfeec82bc1 FXOS8700Q.lib --- a/FXOS8700Q.lib Thu Apr 24 16:31:17 2014 +0000 +++ b/FXOS8700Q.lib Fri Apr 25 16:47:00 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/JimCarver/code/FXOS8700Q/#cdc362f08339 +http://mbed.org/users/JimCarver/code/FXOS8700Q/#c53dda05b8cf
diff -r 061ab9f2c002 -r 02bfeec82bc1 main.cpp --- a/main.cpp Thu Apr 24 16:31:17 2014 +0000 +++ b/main.cpp Fri Apr 25 16:47:00 2014 +0000 @@ -2,7 +2,8 @@ #include "FXOS8700Q.h" -//FXOS8700Q combo( A4, A5, FXOS8700CQ_SLAVE_ADDR0); // Proper Ports and I2C address for FReescale Multi Axis shield +//FXOS8700Q acc( A4, A5, FXOS8700CQ_SLAVE_ADDR0); // Proper Ports and I2C address for Freescale Multi Axis shield +//FXOS8700Q mag( A4, A5, FXOS8700CQ_SLAVE_ADDR0); // Proper Ports and I2C address for Freescale Multi Axis shield FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // Proper Ports and I2C Address for K64F Freedom board FXOS8700Q_mag mag( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // Proper Ports and I2C Address for K64F Freedom board @@ -14,51 +15,39 @@ MotionSensorDataCounts mag_raw; MotionSensorDataCounts acc_raw; -/* -int main(void) { - MotionSensor sensor; - - sensor.sampleRate(50); - sensor.enable(); - while(1) - { - if(sensor.dataReady()) - { - SensorDataUnits formatted_data; - sensor.getAxis(&formatted_data); - printf(asdfadsf); - } - if(sensor.dataReady()) - { - SensorDataCounts raw_data; - sensor.getAxis(&raw_data); - printf(asdfasdf); - } - if(sensor.dataReady()) - { - printf x(),y(),x()); - } - if(sensor.dataReady()) - { - printf(x(),y(),z()); - } - } -} - -*/ - - - int main() { - +float faX, faY, faZ; +float fmX, fmY, fmZ; +int16_t raX, raY, raZ; +int16_t rmX, rmY, rmZ; acc.enable(); printf("\r\n\nFXOS8700Q Who Am I= %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\n", mag_data.x, mag_data.y, mag_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); + acc.getAxis(acc_raw); + mag.getAxis(mag_raw); + printf("FXOS8700Q ACC: X=%d Y=%d Z=%d ", acc_raw.x, acc_raw.y, acc_raw.z); + printf(" MAG: X=%d Y=%d Z=%d\r\n", mag_raw.x, mag_raw.y, mag_raw.z); + acc.getX(&raX); + acc.getY(&raY); + acc.getZ(&raZ); + mag.getX(&rmX); + mag.getY(&rmY); + mag.getZ(&rmZ); + printf("FXOS8700Q ACC: X=%d Y=%d Z=%d ", raX, raY, raZ); + printf(" MAG: X=%d Y=%d Z=%d\r\n\n", rmX, rmY, rmZ); wait(1.0); } } \ No newline at end of file