ESE350 project, Spring 2016, University of Pennsylvania

Dependencies:   Adafruit9-DOf Receiver mbed-rtos mbed

Revision:
15:90e07946186f
Parent:
14:64b06476d943
Child:
16:2be2aab63198
diff -r 64b06476d943 -r 90e07946186f main.cpp
--- a/main.cpp	Thu Apr 07 02:07:33 2016 +0000
+++ b/main.cpp	Thu Apr 07 21:14:27 2016 +0000
@@ -6,30 +6,35 @@
 #include "quadcopter.h"
 
 Serial pc(USBTX, USBRX);
-Quadcopter myQuadcopter(&pc); // instantiate Quadcopter object
+MRF24J40 mrf(p11, p12, p13, p14, p21);
+Quadcopter myQuadcopter(&pc, &mrf); // instantiate Quadcopter object
 
 // pwm outputs for the 4 motors (motor 1 points into x direction, 2 into y direction, 3 -x direction, -y direction
-PwmOut motor_1(p21);
-PwmOut motor_2(p22);
-PwmOut motor_3(p23);
-PwmOut motor_4(p24);
+PwmOut motor_1(p23);
+PwmOut motor_2(p24);
+PwmOut motor_3(p25);
+PwmOut motor_4(p26);
+
 
-void controller_thread(void const *args) {
-  while(true){
-  myQuadcopter.controller();
-  Thread::wait(10);
-  }
+void controller_thread(void const *args)
+{
+    while(true) {
+        myQuadcopter.controller();
+        Thread::wait(10);
+    }
 }
 
-void rc_thread(void const *args) {
-  while(true){
-      myQuadcopter.readRc();
-      Thread::wait(100);
-  }
+void rc_thread(void const *args)
+{
+    while(true) {
+        myQuadcopter.readRc();
+        Thread::wait(100);  // rather than having wait in the code, should synch here
+    }
 }
 
 
-int main() {
+int main()
+{
     //Thread thread(controller_thread);
 
     // get desired values from joystick (to be implemented)
@@ -61,20 +66,18 @@
         pc.printf("Aborting");
         return 0;
     };
-    
-    //
+
     Thread threadR(rc_thread);
 
     //check if remote controll is working with if statement
-    
-    Thread threadC(controller_thread);
 
+    //Thread threadC(controller_thread);
     pc.printf("Entering control loop\n\r");
 
     while (1) {
         myQuadcopter.readSensorValues();
 
-//        myQuadcopter.controller();
+        // myQuadcopter.controller();
 
 
         wait(0.01);
@@ -84,9 +87,9 @@
 
         motor_2=motorsPwm.m2;
         motor_4=motorsPwm.m4;
+
         //pc.printf("F: %f M_x: %f M_y: %f M_z: %f\n\r",  F, M_x, M_y, M_z);
-
-        pc.printf("m1: %f m2: %f \n\r",  motorsPwm.m2, motorsPwm.m4);
+        // pc.printf("m1: %f m2: %f \n\r",  motorsPwm.m2, motorsPwm.m4);
         //pc.printf("M_x: %f\tM_y: %f\tM_z: %f\tF: %f\n\r", result.M_x, result.M_y, result.M_z, result.F);
     }
 }