LSM303DLH sample program

Dependencies:   mbed LSM303DLH

Files at this revision

API Documentation at this revision

Comitter:
yamaguch
Date:
Thu Oct 06 08:39:39 2011 +0000
Commit message:
0.1

Changed in this revision

LSM303DLH.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM303DLH.lib	Thu Oct 06 08:39:39 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yamaguch/code/LSM303DLH/#9b2a0b783bfc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 06 08:39:39 2011 +0000
@@ -0,0 +1,32 @@
+#include "LSM303DLH.h"
+
+LSM303DLH lsm(p28, p27, p23, p22);
+
+void int1Detected() {
+    printf("INT1 detected\n");
+}
+
+void int2Detected() {
+    printf("INT2 detected\n");
+}
+/*
+* AOI AND 1 0
+* 6D  6D  0 0
+* ZH      0 1
+* ZL      1 0
+* YH      0 1
+* YL      1 0
+* XH      0 1
+* XL      1 0
+*/
+int main() {
+    lsm.attach(INT1, 0x95, 31, 3, int1Detected);
+    lsm.attach(INT2, 0x2A, 127, 3, int2Detected);
+    while (true) {
+        if (lsm.read()) {
+            printf("acc: (%f, %f, %f), mag: (%f, %f, %f)\n", lsm.ax, lsm.ay, lsm.az, lsm.mx, lsm.my, lsm.mz);
+            printf("direction = %.0f\n", lsm.getHeading() * 180 / 3.14159265358979);
+        }
+        wait(5);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 06 08:39:39 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912