default eCompass example, but with desired serial communication

Dependencies:   MAG3110 MMA8451Q SLCD eCompass_Lib mbed-rtos mbed

Fork of KL46_eCompass by Jim Carver

Revision:
5:25d98baa1ded
Parent:
4:ba1dbfb683fb
Child:
6:f68052364f92
--- a/main.cpp	Sun May 18 15:59:34 2014 +0000
+++ b/main.cpp	Tue Apr 05 05:47:58 2016 +0000
@@ -36,16 +36,17 @@
 //
 void debug_print(void)
 {
-    int h, m, s;
-    h = seconds / 3600;
-    m = (seconds % 3600) / 60;
-    s = seconds % 60;
+    pc.printf("0,%d$",axis6.yaw);
+    //int h, m, s;
+    //h = seconds / 3600;
+    //m = (seconds % 3600) / 60;
+    //s = seconds % 60;
     // Some useful printf statements for debug
-    printf("Runtime= %d:%02d:%02d\r\n", h, m, s);
-    printf("roll=%d, pitch=%d, yaw=%d\r\n", axis6.roll, axis6.pitch, axis6.yaw);
-    printf("Acc: X= %2.3f Y= %2.3f Z= %2.3f    ", axis6.fGax, axis6.fGay, axis6.fGaz);
-    printf("Mag: X= %4.1f Y= %4.1f Z= %4.1f\r\n", axis6.fUTmx, axis6.fUTmy, axis6.fUTmz);
-    printf("Quaternion: Q0= %1.4f Q1= %1.4f Q2= %1.4f Q3= %1.4f\r\n\n", axis6.q0, axis6.q1, axis6.q2, axis6.q3); 
+    //printf("Runtime= %d:%02d:%02d\r\n", h, m, s);
+    //printf("roll=%d, pitch=%d, yaw=%d\r\n", axis6.roll, axis6.pitch, axis6.yaw);
+    //printf("Acc: X= %2.3f Y= %2.3f Z= %2.3f    ", axis6.fGax, axis6.fGay, axis6.fGaz);
+    //printf("Mag: X= %4.1f Y= %4.1f Z= %4.1f\r\n", axis6.fUTmx, axis6.fUTmy, axis6.fUTmz);
+    //printf("Quaternion: Q0= %1.4f Q1= %1.4f Q2= %1.4f Q3= %1.4f\r\n\n", axis6.q0, axis6.q1, axis6.q2, axis6.q3); 
 }
 // HAL Map for KL46 Freedom board MMA8451Q & MAG3110 sensors
 //
@@ -101,8 +102,11 @@
 void print_thread(void const *argument) {
     while (true) {
         // Signal flags that are reported as event are automatically cleared.
-        Thread::signal_wait(0x1);    
-        debug_print();
+        //Thread::signal_wait(0x1); 
+        if (pc.getc())
+        {   
+            debug_print();
+        }
     }
 }
 
@@ -134,8 +138,8 @@
     acc.enable();
     // Say hello to our sensors
     // Native KL46-FRDM sensors
-    printf("\r\nMMA8451Q ID= %X\r\n", acc.whoAmI());
-    printf("MAG3110 ID= %X\r\n", mag.whoAmI());
+    //printf("\r\nMMA8451Q ID= %X\r\n", acc.whoAmI());
+    //printf("MAG3110 ID= %X\r\n", mag.whoAmI());
     mag.getAxis(mag_raw); // flush the magnetmeter
     RtosTimer compass_timer(compass_thread, osTimerPeriodic);