Ian Hua / Quadcopter-mbedRTOS
Revision:
36:d95e3d6f2fc4
Parent:
34:228d87c45151
Child:
38:ef65533cca32
--- a/RTOS-Threads/src/Task2_Slave.cpp	Tue May 13 02:44:10 2014 +0000
+++ b/RTOS-Threads/src/Task2_Slave.cpp	Tue May 13 04:05:34 2014 +0000
@@ -1,8 +1,9 @@
 /* File:        Task2_Slave.cpp
  * Author:      Trung Tin Ian HUA
  * Date:        May 2014
- * Purpose:     Thread2S: Gyro sample and Slave PID control loop (rate)
- * Settings:    200Hz
+ * Purpose:     Thread2S: Slave PID control loop (rate)
+ * Functions:   Gyro sample
+ * Settings:    400Hz
  * Timing:      290us
  */
 #include "Task2_Slave.h"
@@ -26,13 +27,7 @@
 void Task2_Slave(void const *argument)
 {
 //Timer
-    imu.getRotation(&gx, &gy, &gz);
-    gyro[0] = gx + 60;
-    gyro[1] = gy - 15;
-    gyro[2] = gz + 25;
-
-    for (int i = 0; i < 3; i++)
-        gyro[i] /= (float) 32.8;
+    gyroSample();
 
 //Timer
     if (armed) {
@@ -71,17 +66,23 @@
                 break;
         }
 //Timer
-
-    /* Telemetry output: */
-        if (adjust_check)
-            BT.printf("%3.2f %3.2f %3.2f\n", adjust[0], adjust[1], adjust[2]);
     }
-
-    if (gyro_out)
-        BT.printf("%3d %3d %3d\n", (int) gyro[0], (int) gyro[1], (int) gyro[2]);
 //Timer
 }
 
+
+
+
 // ************************
 // *** Helper functions ***
 // ************************
+void gyroSample(void)
+{
+    imu.getRotation(&gx, &gy, &gz);
+    gyro[0] = gx + 60;
+    gyro[1] = gy - 15;
+    gyro[2] = gz + 25;
+
+    for (int i = 0; i < 3; i++)
+        gyro[i] /= (float) 32.8;
+}