megan gimple / Mbed 2 deprecated OCE360_Final_Project

Dependencies:   mbed MMA8452Q MS5837 SDFileSystem SCI_SENSOR

Revision:
36:93a04bd48152
Parent:
35:414778105560
Child:
37:7bb14ad22d78
diff -r 414778105560 -r 93a04bd48152 main.cpp
--- a/main.cpp	Wed Dec 08 21:55:38 2021 +0000
+++ b/main.cpp	Wed Dec 08 22:06:40 2021 +0000
@@ -96,54 +96,55 @@
     //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.5);  //10Hz
+    accel_ticker.attach(&accel_update,0.1);  //10Hz
     log_ticker.attach(&log_data,0.5);
     led2=0;
     led1=0;
 
-
-    //Part One
-    int count=0;
-    while(count<3) {
-        led3=1;
-        count=count+1;
-        float pw=percent;
-        float on_time=tim;
-        thrust_on(pw, on_time); //turn thruster on for 5 seconds
-        wait(1);
-    }
+    while(1) {
+        //Part One
+        int count=0;
+        while(count<3) {
+            led3=1;
+            count=count+1;
+            float pw=percent;
+            float on_time=tim;
+            thrust_on(pw, on_time); //turn thruster on for 5 seconds
+            wait(1);
+        }
 
-    //Part Two
-    timer2.start();
-    while(1) {
-        led3=0;
-        float current_depth=p_sensor.depth();
-        float pw=percent;
-        float on_time=5;
+        //Part Two
+        timer2.start();
+        while(1) {
+            led3=0;
+            float current_depth=p_sensor.depth();
+            float pw=percent;
+            float on_time=5;
 
-        if (current_depth-vessel_length<2) {
-            thrust_on(pw,on_time);
+            if (current_depth-vessel_length<2) {
+                thrust_on(pw,on_time);
+            }
+            if (timer2.read()>10) { //60 because counting in seconds?
+                return 0;
+            }
         }
-        if (timer2.read()>10) { //60 because counting in seconds?
-            return 0;
-        }
-    }
 
 
-    /*Part Three
-    while(1) {
-        error_deep = 2.5;    //deep end of error band 2.5m ?
-        error_shallow = 1.5; //shallow end of error band 1.5m?
+        /*Part Three
+        while(1) {
+            error_deep = 2.5;    //deep end of error band 2.5m ?
+            error_shallow = 1.5; //shallow end of error band 1.5m?
 
-        if (current_depth <= error_shallow) { //if float is less than 1.5meters deep
-            thrust_on(pw,on_time);               // turn on thruster at set pw and ontime
-            else if (current_depth >= error_deep) //if float is more than 2.5 meters deep
-                wait(1);                          // do nothing for 1 sec.. float will go up for 1 sec
-                else
-                    pw = ; //very low thruster percentage
-                    thrust_on(pw,on_time); //run thruster at very low percentage to maintain depth
-        }
-    */
+            if (current_depth <= error_shallow) { //if float is less than 1.5meters deep
+                thrust_on(pw,on_time);               // turn on thruster at set pw and ontime
+                else if (current_depth >= error_deep) //if float is more than 2.5 meters deep
+                    wait(1);                          // do nothing for 1 sec.. float will go up for 1 sec
+                    else
+                        pw = ; //very low thruster percentage
+                        thrust_on(pw,on_time); //run thruster at very low percentage to maintain depth
+            }
+        */
+    }
 }
 
 //-------------Customized functions---------------------------------------------//----------------------------------------
@@ -206,9 +207,7 @@
     //end of code from Licht
 
     fp = fopen(fname, "a");
-    fprintf(fp, "$DATA \r\n");
-    //fprintf(fp, "Time:%f \r\n", t.read());
-    //fprintf(fp, "Pressure:%f \r\n", p_sensor.MS5837_Pressure());
+    fprintf(fp, "$DATA");
     // Time:%f, Pressure:%f, Depth:%f, Acceleration:%f, %f, %f, Temp:%f, Light:%f, Percent:%f\r\n", t.read(),p_sensor.MS5837_Pressure(),p_sensor.depth(),accelData[0],accelData[1],accelData[2],temp.temp(),light.light(),percent);
     fclose(fp);