ESE350 project, Spring 2016, University of Pennsylvania

Dependencies:   Adafruit9-DOf Receiver mbed-rtos mbed

Revision:
34:eaea0ae92dfa
Parent:
31:d473eacfc271
Child:
36:40b134328376
--- a/main.cpp	Sat Apr 23 20:52:10 2016 +0000
+++ b/main.cpp	Sun Apr 24 17:15:20 2016 +0000
@@ -7,7 +7,8 @@
 
 Serial pc(USBTX, USBRX);
 MRF24J40 mrf(p11, p12, p13, p14, p21);
-Quadcopter myQuadcopter(&pc, &mrf); // instantiate Quadcopter object
+Timer timer; // timer ;) 
+Quadcopter myQuadcopter(&pc, &mrf, &timer); // 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(p23);
@@ -20,8 +21,6 @@
 DigitalOut batteryLed(LED1);
 DigitalOut shutDownLed(LED2);
 
-Timer timer; // timer ;) 
-
 int emergencyOff = 0;
 //int lowThrust= {0,0,0};
 int nLowThrust = 0;
@@ -55,7 +54,7 @@
     while(emergencyOff != 1) {
        // printf(" thrust: %f\r\n",myQuadcopter.getForce());
 
-        int shutdown=  getLowThrust(-0.3);
+        int shutdown = getLowThrust(-0.3);
         if (shutdown==1) {
             emergencyShutdown();
             printf("too long negative thrust! %f\r\n",myQuadcopter.getForce());
@@ -65,7 +64,7 @@
 
         myQuadcopter.readSensorValues();
 
-        myQuadcopter.controller(timer.read());
+        myQuadcopter.controller();
         motors motorsPwm = myQuadcopter.getPwm();
 
         motor_1 = motorsPwm.m1;
@@ -107,8 +106,6 @@
     }
 }
 
-
-
 int main()
 {
     // ESCs requires a 100Hz frequency
@@ -119,11 +116,10 @@
 
     Thread threadR(rc_thread);
 
-
-    int startLoop= 0;
+    int startLoop = 0;
 
     while (!startLoop) { // wait until Joystick is in starting position
-        startLoop=  getLowThrust(-0.3);
+        startLoop = getLowThrust(-0.3);
     }
     nLowThrust = 0; // reset for later use in controller.
 
@@ -133,8 +129,6 @@
     motor_4 = 0.1;
 
     wait(3); // hold startup duty cycle for 2 seconds
-    
-    timer.start();
 
     // TODO assign priorities to threads, test if it really works as we expect
     Thread battery(battery_thread);