most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown

Dependencies:   mbed MODSERIAL FATFileSystem

Revision:
45:16b8162188ca
Parent:
43:891baf306e0a
Child:
47:fb3c7929d3f3
--- a/main.cpp	Wed Feb 14 21:58:44 2018 +0000
+++ b/main.cpp	Thu Feb 15 02:39:13 2018 +0000
@@ -96,6 +96,21 @@
 
     //create the MBED log file (current log file)
     //mbedLogger().openFile();
+    
+    pc().printf("Size of ConfigFile: %d\n\r", sizeof(ConfigFile));
+    pc().printf("Size of ConfigFileIO: %d\n\r", sizeof(ConfigFileIO));
+    pc().printf("Size of IMU: %d\n\r", sizeof(IMU));
+    pc().printf("Size of LinearActuator: %d\n\r", sizeof(LinearActuator));
+    pc().printf("Size of LTC1298 (SpiADC): %d\n\r", sizeof(SpiADC));
+    pc().printf("Size of MbedLogger: %d\n\r", sizeof(MbedLogger));
+    pc().printf("Size of omegaPX209: %d\n\r", sizeof(omegaPX209));
+    pc().printf("Size of OuterLoop: %d\n\r", sizeof(OuterLoop));
+    pc().printf("Size of PIDController: %d\n\r", sizeof(PIDController));
+    pc().printf("Size of PololuHBridge: %d\n\r", sizeof(PololuHBridge));        //fix this class
+    pc().printf("Size of PosVelFilter: %d\n\r", sizeof(PosVelFilter));
+    pc().printf("Size of SequenceController: %d\n\r", sizeof(SequenceController));
+    pc().printf("Size of ServoDriver: %d\n\r", sizeof(ServoDriver));
+    pc().printf("Size of StateMachine: %d\n\r", sizeof(StateMachine));
 } 
  
 int main() {
@@ -109,41 +124,42 @@
         // FSM loop runs at 10 hz
         if(loop) {
             led1() = !led1(); // blink led 1
-            
-            //running State Machine. Returns 0 if sitting idle or keyboard press (SIT_IDLE state).
-            current_state = stateMachine().runStateMachine();
-            
+            current_state = stateMachine().runStateMachine();       //running State Machine. Returns 0 if sitting idle or keyboard press (SIT_IDLE state).
             loop = false; // wait until the loop rate timer fires again
         }
         
         // log loop runs at 1 hz
         if (log_loop) {
-            led3() = !led3(); // blink led 3
+            //when the state machine is not in SIT_IDLE state (or a random keyboard press)
+            if (current_state == TRANSMIT_LOG or current_state == RECEIVE_SEQUENCE) {
+                //main_loop_rate_ticker.detach();
+                //log_loop_rate_ticker.detach();
+                
+                ;   //pass
+            }
             
-            //when the state machine is not in SIT_IDLE state (or a random keyboard press)
-            if(current_state != 0) {
-                //pc().printf("\n\rDEBUG: trying to record data \n\r");    
-
-               //if the log file is not open, open it
-                if (!file_opened) { 
-                    mbedLogger().openFile();    //open MBED file once                    
-                    file_opened = true;         //stops it from continuing to open it
+            else if(current_state != 0) {
+                if (!file_opened) {                                 //if the log file is not open, open it
+                    mbedLogger().appendLogFile(current_state, 0);   //open MBED file once
+                    //sdLogger().appendLogFile(current_state, 0);     //open SD file once
+                               
+                    file_opened = true;                             //stops it from continuing to open it
 
                     pc().printf(">>>>>>>> Recording. Log file opened. <<<<<<<<\n\r");
                 }
                 
-                //record to OpenLog hardware
-               OpenLog().recordData(current_state);   //start recording   
-                
-                //record to Mbed file system
-                mbedLogger().saveDataToFile(current_state,stateMachine().dataArray());                
+                //record to Mbed file system     
+                mbedLogger().appendLogFile(current_state, 1);    //writing data
+                //sdLogger().appendLogFile(current_state, 1);    //writing data
             }
             
             //when the current FSM state is zero, reset the file
             else {
                 //this can only happen once
                 if (file_opened) {
-                    mbedLogger().closeFile();
+                    mbedLogger().appendLogFile(current_state, 0);    //close log file
+                    //sdLogger().appendLogFile(current_state, 0);    //close log file
+                    
                     file_opened = false;
                     
                     pc().printf(">>>>>>>> Stopped recording. Log file closed. <<<<<<<<\n\r");
@@ -151,6 +167,6 @@
             }
             
             log_loop = false;   // wait until the loop rate timer fires again
-        }
+        }   //END OF LOG LOOP
     }
 }
\ No newline at end of file