Play around with the xtrinsic sensors package available through Element14. Includes the MAG3110,MMA8491Q and MPL3115.

Dependencies:   MAG3110 MMA8491 MMA8491Q MPL3115 MPL3115A2 mbed

Files at this revision

API Documentation at this revision

Comitter:
seanburford
Date:
Thu Sep 14 20:39:22 2017 +1000
Parent:
1:ecfba4d67833
Commit message:
Switch to NXP library for accel.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ecfba4d67833 -r 22c3ec6319ce main.cpp
--- a/main.cpp	Thu Sep 14 06:59:30 2017 +0000
+++ b/main.cpp	Thu Sep 14 20:39:22 2017 +1000
@@ -10,12 +10,14 @@
 
 int main()
 {
-    MMA8491Q acc(PTE0, PTE1, MMA8491_I2C_ADDRESS);
+    MMA8491 acc(I2C_SDA, I2C_SCL, PTA13);
  
     while (true) {
-        rled = 1.0 - abs(acc.getAccX());
-        gled = 1.0 - abs(acc.getAccY());
-        bled = 1.0 - abs(acc.getAccZ());
+        float data[3];
+        acc.acquire_MMA8491_data_g(data);
+        rled = 1.0 - abs((long)data[0]);
+        gled = 1.0 - abs((long)data[1]);
+        bled = 1.0 - abs((long)data[2]);
         wait(0.1);
     }
 
@@ -27,4 +29,4 @@
     //        wait (0.0025f);
     //    }
     //}
-}
\ No newline at end of file
+}