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
Diff: main.cpp
- Revision:
- 32:f2f8ae34aadc
- Parent:
- 31:8616e397c22d
- Child:
- 34:9b66c5188051
--- a/main.cpp Wed Dec 06 22:45:23 2017 +0000 +++ b/main.cpp Wed Dec 20 13:52:50 2017 +0000 @@ -40,19 +40,54 @@ - Successful dive and multi-dive sequences exit to FLOAT_BROADCAST state (fix was implemented in code that did not respond, reimplemented here) 1) Also made the change to the SequenceController (which loads a file that has multiple sequences) - FIND_NEUTRAL starts in NEUTRAL_SINKING with fix on sub-FSM to start with NEUTRAL_SINKING (verified via mbed on bench) + Modified 2017-12-07 revA by Troy + - Using new neutral finding sequence, dive slowly, rise slowly, then check pitch (pitch is not active at all until final state) + - Added additional print information (showing neutral parameters with "C") + Modified 2017-12-07 revB by Troy + - Momentum offsets reintroduced: + 1) CASE DIVE uses "else if (depthLoop().getPosition() > depthLoop().getCommand() - 0.5) { // including offset for low momentum approaches" + 2) CASE RISE uses "else if (depthLoop().getPosition() < depthLoop().getCommand() + 0.5) { // including offset for low momentum approaches" + - Momentum on rise command does not exit properly, removed + Modified 2017-12-11 revA by Troy + - Added a logger function the main while loop + - Added vectors (essentially resizable arrays) to hold the data in the State Machine because of memory limitations + Modified 2017-12-12 revA by Troy + - Logger directly implemented in StateMachine (records every 5 seconds) + Modified 2017-12-12 revB by Troy + - Logger fixes implemented in StateMachine, was not logging each state, fixed the reset + - Made logger into a function call + Modified 2017-12-13 revA by Troy + - Added function to print log file to screen (tested on bench with multiple dives and timers) + Modified 2017-12-18 revA by Troy + - Redo of the code to stop opening and closing files each time + - This should allow you to write to the open file, then close it once you exit the sequence back to SIT_IDLE + - Start record in dive, end when you exit float broadcast... + Modified 2017-12-19 revA by Troy + - Fixed OpenLog printing to include states and variable names. Currently logs to LOG#####.TXT files + 1) Note: The OpenLog only starts a new log when it is power-cycled (with the MBED) + Modified 2017-12-20 rev A by Troy + - Modified code to log every 1 second in current iteration */ #include "mbed.h" #include "StaticDefs.hpp" -// loop rate timer for slowing down how fast while(1) runs in main() +// loop rate used to determine how fast events trigger in the while loop Ticker loop_rate_ticker; -volatile bool loop = false; -void loop_trigger() { loop = true; }; // loop trigger - + +volatile bool loop = false; //used so the compiler does not optimize this variable (load from memory, do not assume state of variable) + +void loop_trigger() { loop = true;} // loop trigger (used in while loop) +//void log_loop_trigger() { log_loop = true;} // log loop trigger (used in while loop) + + void setup() { pc().baud(57600); - pc().printf("\n\n\rFSG POOL TEST 2017-12-01 revA\n\n\r"); + pc().printf("\n\n\rFSG POOL TEST 2017-12-20 revA (DESKTOP SAVE TEST)\n\n\r"); + + //setup data logger baud rate and write the start of the program (every time you reset) + datalogger().baud(57600); + datalogger().printf("DATA, LOGGER, START\n"); // start up the system timer systemTime().start(); @@ -108,17 +143,27 @@ // establish the main loop rate loop_rate_ticker.attach(&loop_trigger, 0.1); // fires the ticker at 10 Hz rate + + // setup the data logger rate +// loop_log_rate_ticker.attach(&loop_log_trigger, 5.0); // fires the ticker at 0.2 Hz rate (every 5 seconds) + } int main() { setup(); while(1) { - // does this stuff at the loop rate + // runs at 10 hz if(loop) { - led1() = !led1(); // blink + led1() = !led1(); // blink led 1 stateMachine().runStateMachine(); loop = false; // wait until the loop rate timer fires again } + +// if (log_loop) { +// led3() = !led3(); // blink led 3 +// datalogger().printf(""); +// log_loop = false; // wait until the loop rate timer fires again +// } } } \ No newline at end of file