Eva Krolis / Mbed 2 deprecated StateMachine

Dependencies:   biquadFilter FastPWM HIDScope MODSERIAL mbed

Fork of StateMachine by Tommie Verouden

Revision:
0:c0c35b95765f
Child:
2:d70795e4e0bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test.cpp	Wed Oct 31 10:30:41 2018 +0000
@@ -0,0 +1,47 @@
+void StateMachine(){
+    switch(CurrentState){                                       //Determine in which state you are
+        
+        case Calibration:                                       //Calibration mode
+            if(StateBool){                                      //If you go into this state
+                pc.printf("You can start calibrating. \n\r");   //Print that you are in this state
+                StateBool = false;                              //Set the bool for the start of a state to false
+                EMGCalibration_timer.attach(&CalibrateEMG,0.005);   //Start EMG calibration every 0.005 seconds
+                FindMax_timer.attach(&FindMax,15);                  //Find the maximum value after 15 seconds
+                SwitchState_timer.attach(&SwitchState,16);          //Switch to the next state after 16 seconds
+                blueled = 0;
+            }
+            
+            if (SwitchStateBool){                           //If the bool is changed
+                CurrentState = WorkingMode;                 //Change the state to the working mode
+                StateBool = true;                           //Set the start of a state bool to true
+                SwitchStateBool = false;                    //Set the switch bool to false
+            }
+            break;        
+        
+        case WorkingMode:                                       //Mode to get the robot working
+            if (StateBool){                                      //If you start to go in this state
+                pc.printf("You are know in the working mode. \r\n");    //Print in which mode you are
+                StateBool = false;                          //Set the start of state bool to true
+                EMGCalibration_timer.detach();              //Detach the the calibration
+                ReadUseEMG_timer.attach(&ReadUseEMG, 0.005);     //Start the use of EMG
+            }
+            blueled = 1;                                        //Set the blue led off
+            pc.printf("%f \n\r",EMG0Average);
+            break;
+    }
+}
+
+
+void SwitchState(){
+    SwitchStateBool = true;                                 //Set the bool for the start of a state to true
+    SwitchState_timer.detach();                             //Use this function once
+}
+
+
+
+
+// PC-communication
+bool externalPC = true;             // toggle communication with external PC
+
+if externalPC {
+MODSERIAL pc(USBTX, USBRX);
\ No newline at end of file