IMU and knee angle. No servo yet

Dependencies:   mbed

Fork of FYDP_Final2 by Dave Lu

Revision:
11:425dff6a4af9
Parent:
10:22c44650c7c1
--- a/main.cpp	Wed Mar 25 16:36:11 2015 +0000
+++ b/main.cpp	Wed Mar 25 18:11:09 2015 +0000
@@ -9,34 +9,29 @@
 Sensor sensor;
 DigitalOut btSwitch(PTE30);
 
-void IMU2_thread(void const *args)
-{
-    test_dmp2();
-    start_dmp2(mpu2);
-    while(1) {
-        update_dmp2();
-        Thread::yield();
-    }
-}
+
 void IMU_thread(void const *args)
 {
     test_dmp();
     start_dmp(mpu);
+    while(true) {
+        LED_ON
+        update_dmp();
+        Thread::yield();
+    }
+}
+void IMU2_thread(void const *args)
+{
     test_dmp2();
     start_dmp2(mpu2);
-    while(1) {
-        update_dmp();
+    while(true) {
+        LED_OFF
         update_dmp2();
         Thread::yield();
     }
 }
-
 void io_thread(void const *args)
 {
-    btSwitch = 1;
-    pc.baud(115200);
-    setup(sensor);
-
     while(true) {
         if(pc.readable() && pc.getc() == 'c') {
             sensor.calibrate();
@@ -45,11 +40,11 @@
         
         process();
         
-//        pc.printf(
-//            "%.3f;%.3f;%.3f;%i;%.3f;%.3f;%.3f;\r\n", 
-//            sensor.time(), sensor.thigh(), sensor.shin(), getState(), getPace(), 0, 0
-//        );
-        pc.printf("crap\r\n", 0);
+        pc.printf(
+            "%.3f;%.3f;%.3f;%i;%.3f;%.3f;%.3f;\r\n",
+            sensor.time(), sensor.thigh(), sensor.shin(), getState(), getPace(), getHip(), getKneeDiff()
+        );
+
         Thread::wait(10);
     }
 }
@@ -65,10 +60,15 @@
 int main()
 {
     t.start();
+    
+    btSwitch = 1;
+    pc.baud(115200);
+    
+    setup(&sensor);
 
-    Thread bt_shell_th(io_thread, NULL, osPriorityNormal, 2048, NULL);
-    Thread IMU_th(IMU_thread, NULL, osPriorityNormal, 2048, NULL);
-    Thread IMU2_th(IMU2_thread, NULL, osPriorityNormal, 2048, NULL);
+    Thread bt_shell_th(io_thread, NULL, osPriorityNormal, 1024, NULL);
+    Thread IMU_th(IMU_thread, NULL, osPriorityNormal, 768, NULL);
+    Thread IMU2_th(IMU2_thread, NULL, osPriorityNormal, 768, NULL);
 //    Thread control_th(control_thread, NULL, osPriorityNormal, 2548, NULL);
 
     Thread::wait(osWaitForever);