Mark Schwarzer / Mbed 2 deprecated Project_OCE360

Dependencies:   mbed

Revision:
15:6cb9a9ede7fe
Parent:
12:2f1e8b205d0f
--- a/main.cpp	Tue Dec 08 02:34:01 2020 +0000
+++ b/main.cpp	Tue Dec 08 14:25:55 2020 +0000
@@ -32,7 +32,7 @@
 FILE *fp;
 char fname[100];
 float PI = 3.14159265358979323846f;
-
+float pw;
 //float operation parameters
 float target_depth=0;   //global target depth default 0
 int yo_num=0;           //global yo_num default 0
@@ -76,9 +76,9 @@
     imu_ticker.attach(&IMU_update,0.1);  //10Hz
     log_ticker.attach(&log_data,0.5);
     wait(1);
+    ttt.start();
     while(1)
     { 
-        ttt.start();
         p_sensor.Barometer_MS5837();
         //Depth Holding
         if (p_sensor.depth()>2.0) {
@@ -93,8 +93,8 @@
             thruster.pulsewidth(1.3/1000.00);
             thruster2.pulsewidth(1.3/1000.00);
         }
-    }
-    while(ttt.read()>=180)
+    
+    if(ttt.read()>=180)
     {   
     
             //stop the timer
@@ -122,7 +122,7 @@
 */       
         myled=!myled;
         wait(1);
-    }
+    }}
 
     
 
@@ -175,7 +175,7 @@
 void log_data()
 {
     fp= fopen(fname, "a");
-    fprintf(fp, "$IMU,3,15, %f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3.f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f;\r\n",t.read(),p_sensor.depth(),p_sensor.MS5837_Temperature(),thruster.pulsewidth(7),accel[0],accel[1],accel[2],gyro[0],gyro[1],gyro[2],euler[0],euler[1],euler[2],t_sensor.temp(),photo.light());
+    fprintf(fp, "$NMEA, 3,15, %f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f;\r\n",t.read(),p_sensor.depth(),p_sensor.MS5837_Temperature(),pw,accel[0],accel[1],accel[2],gyro[0],gyro[1],gyro[2],euler[0],euler[1],euler[2],t_sensor.temp(),photo.light());
     fclose(fp);
     
     // log pulse width
@@ -244,7 +244,7 @@
 ////Thruster on control, pw->pulse width in milli-second//
 ////                        pw range between 1 to 1.5//
 ////                       on_time-> thruster on time.
-void thrust_on(float pw, float on_time)  //input is pulse width
+void thrust_on(float on_time)  //input is pulse width
 {
     float pw_max=2.0;
     if(pw>pw_max)