This is an example of a tilt compensated eCompass running on a K64F Freedom Platform using the on board FXOS8700 6 axis sensor and Freescale's eCompass software library in a linkable object library compiled for a FPU enabled Cortex M4.

Dependencies:   FXOS8700Q eCompass_FPU_Lib mbed-rtos mbed

Revision:
3:d6404f10bd3b
Parent:
2:51f3303cbefd
--- a/main.cpp	Fri May 09 16:23:09 2014 +0000
+++ b/main.cpp	Fri May 09 16:30:47 2014 +0000
@@ -67,6 +67,7 @@
         seconds++;
         sflag = 1;
         compass.calibrate();
+        debug_print();
         l = 0;
         led = !led;
         }
@@ -82,7 +83,7 @@
     }
 }
  
-*/
+
   
 void print_thread(void const *argument) {
     while (true) {
@@ -91,35 +92,24 @@
         debug_print(); // re-calibrate the eCompass every second
     }
 }
-             
+ */            
 
 int main() {
 
 
-//Thread calibrate(calibrate_thread);
-Thread dprint(print_thread);
-//RtosTimer compass_timer(compass_thread, osTimerPeriodic);
+RtosTimer compass_timer(compass_thread, osTimerPeriodic);
 
 //cdebug = 1;  // uncomment to disable compass
 printf("\r\n\n\n\n\n\n\n");
+printf("Who AM I= %X\r\n", acc.whoAmI());
 acc.enable();
-printf("Who AM I= %X\r\n", acc.whoAmI());
+
 
 acc.getAxis( acc_raw);
 mag.getAxis( mag_raw);
 
-dprint.set_priority(osPriorityLow);
-//calibrate.set_priority(osPriorityBelowNormal);
-//compass_timer.set_priority(osPriorityRealtime);
-
-//compass_timer.start(20); // Run the Compass every 20ms
+compass_timer.start(20); // Run the Compass every 20ms
 while(1) {
-    //while(!sflag);
-    sflag = 0;
-    //debug_print();
-    printf("\r\nL\r\n");
-    //calibrate.signal_set(0x1);
-    dprint.signal_set(0x1);
-    wait(1000);
+    Thread::wait(osWaitForever);
     }  
 }