megan gimple / Mbed 2 deprecated OCE360_Final_Project

Dependencies:   mbed MMA8452Q MS5837 SDFileSystem SCI_SENSOR

Revision:
31:f62d09120c6a
Parent:
30:c54217fc9314
Child:
32:ffe14e791fa9
--- a/main.cpp	Wed Dec 08 20:40:25 2021 +0000
+++ b/main.cpp	Wed Dec 08 20:57:53 2021 +0000
@@ -50,6 +50,9 @@
 //IMU related
 void accel_update(); //update accelerometer related variables. we use imu_ticker to call this function
 
+//IMU related
+void accel_update(); //update accelerometer related variables. we use imu_ticker to call this function
+
 //Control Parameters
 float tim =5;           //define thruster on time
 float percent = 1.5;    //user defined percent of thrust power
@@ -69,7 +72,6 @@
     //inital set the thruster esc to 1ms duty cycle
     thruster.period(0.002);      // 2 ms period
     thruster.pulsewidth(1.0/1000.000);
-    
     thruster2.period(0.002);      // 2 ms period
     thruster2.pulsewidth(1.0/1000.000);
 
@@ -84,17 +86,23 @@
     pc.printf("setting the tickers\r\n");
     t.start();
     led2=1;
-    welcome();
+    //*****************************************************
+    //waits until it gets an answer over the Bluetooth link!
+    welcome();  //prompts user for the logfile name
+    //********************************************************
+
 
     //-----setup ticker-------//
     //setup ticker to separate log and IMU data update.
     //so we could have all our control code in the while loop
     //   //log at 2 Hz
-    //accel_ticker.attach(&accel_update,0.1);  //10Hz
-    //log_ticker.attach(&log_data,0.5);
+    accel_ticker.attach(&accel_update,0.1);  //10Hz
+    log_ticker.attach(&log_data,0.5);
+    led2=0;
     led1=0;
-    led2=0;
+    thrust_on(1.2,2);  //Runs the thrusters at 20% for 2 seconds, just to test them.
 
+while(1){
     //Part One
     int count=0;
     while(count<3) {
@@ -121,7 +129,7 @@
             return 0;
         }
     }
-
+}
 
     /*Part Three
     while(1) {
@@ -148,6 +156,7 @@
         while(BLE.readable()) {
             BLE.getc();
         }
+        led1=1;
         while(flag) {
             BLE.printf("### I am alive\r\n");
             BLE.printf("### Please enter the log file name you want\r\n");
@@ -159,6 +168,7 @@
             }
             wait(1);
         }
+        led2=1;
         //print name
         BLE.printf("### name received\r\n");
         BLE.printf("### file name and directory is: \r\n %s\r\n",fname); //file name and location