51 52 with same code

Dependencies:   MtSense07

Fork of MtConnect04S_MtSense07 by MtM+

Revision:
1:40c18f027e6c
Parent:
0:418880413158
Child:
2:87f1b98c0d09
--- a/main.cpp	Thu Jan 26 03:54:58 2017 +0000
+++ b/main.cpp	Fri Feb 03 06:51:09 2017 +0000
@@ -19,7 +19,8 @@
 #include "AK9750.h"
 #include "AK09912.h"
 #include "AK09970.h"
- 
+#include "config.h"
+
 Serial pc(p15, p16);
 
 DigitalOut reset_sensor(p4, 1);   // Reset pin for AK09970 (Low active)
@@ -30,7 +31,8 @@
 
 int main() {
     /* Disable the hardware flow control of Serial, then show the mbed version */
-    pc.set_flow_control(SerialBase::Disabled);    
+    pc.set_flow_control(SerialBase::Disabled);
+    pc.baud(CONFIG_BAUDRATE);
     pc.printf("\n");
     pc.printf("mbed version(%d.%d.%d)\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
     pc.printf("\n");
@@ -71,11 +73,11 @@
     }
 
     /* Main loop */
+#if (CONFIG_RUN_MODE == RUN_ALL_SENSOR_COM)
     AK9750::Data ak9750_data;
     AK09912::Data ak09912_data;
     AK09970::Data ak09970_data;
     int32_t triggered_area;
-
     while (1) {
         ak9750.GetData(&ak9750_data);
         triggered_area = ak9750.GetTriggeredAreaNum(&ak9750_data);
@@ -93,4 +95,34 @@
         pc.printf("\n");
         wait(1);
     }
+#elif (CONFIG_RUN_MODE == RUN_IR_AK9750_APP)
+    AK9750::Data ak9750_data;
+    int32_t count = 0;
+    while (1) {
+        ak9750.GetData(&ak9750_data);
+        pc.printf(" 3:%d,%d,%d,%d,%d,\r", count, (int32_t)ak9750_data.ir1, (int32_t)ak9750_data.ir2, (int32_t)ak9750_data.ir3, (int32_t)ak9750_data.ir4);
+        count++;
+        wait(1);
+    }
+#elif (CONFIG_RUN_MODE == RUN_COMPASS_AK09912_APP)
+    AK09912::Data ak09912_data;
+    int32_t count = 0;
+    while (1) {
+        ak09912.GetData(&ak09912_data);
+        pc.printf("C:%d,%d,%d,%d\r", count, (int32_t)ak09912_data.x, (int32_t)ak09912_data.y, (int32_t)ak09912_data.z);
+        count++;
+        wait(1);
+    }
+#elif (CONFIG_RUN_MODE == RUN_MAGNETIC_AK09970_APP)
+    AK09970::Data ak09970_data;
+    int32_t count = 0;
+    while (1) {
+        ak09970.GetData(&ak09970_data);
+        pc.printf("C:%d,%d,%d,%d\r", count, (int32_t)ak09970_data.x, (int32_t)ak09970_data.y, (int32_t)ak09970_data.z);
+        count++;
+        wait(1);
+    }
+#else
+    #errror "Config run mode ...FAIL"
+#endif
 }