State machine with EMG functions and parameters
Dependencies: biquadFilter FastPWM HIDScope MODSERIAL mbed
Fork of StateMachine by
main.cpp
- Committer:
- tverouden
- Date:
- 2018-10-31
- Revision:
- 2:d70795e4e0bf
- Parent:
- 1:d5ff787228fa
- Child:
- 3:9c63fc5f157e
File content as of revision 2:d70795e4e0bf:
// ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ PREPARATION ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ // Libraries #include "mbed.h" #include "BiQuad.h" #include "FastPWM.h" #include "HIDScope.h" #include "MODSERIAL.h" // Inputs & outputs DigitalOut redled(LED_RED,1); // red LED K64F DigitalOut greenled(LED_GREEN,1); // green LED K64F DigitalOut blueled(LED_BLUE,1); // blue LED K64F InterruptIn buttonbio1(D0); // button 1 BioRobotics shield InterruptIn buttonbio2(D1); // button 2 BioRobotics shield InterruptIn buttonK64F(SW3); // button on K64F InterruptIn emergencybutton(SW2); // emergency button on K64F // Define & initialise state machine enum states { waiting, calibratingMotors, calibratingEMGx, calibratingEMGy, homing, operating, flipping, failure, demo }; states currentState = waiting; // start in waiting mode bool changeState = true; // initialise the first state // ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ STATE MACHINE ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ // ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ MAIN LOOP ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ int main() { // ============================== PC-COMMUNICATION ============================= bool externalPC = true; if (externalPC) { MODSERIAL pc(USBTX, USBRX); // communication with pc } // ==================================== LOOP =================================== while (true) { // loop forever } }