Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope Servo mbed QEI biquadFilter
Diff: main.cpp
- Revision:
- 7:ec5add330cb3
- Parent:
- 6:f495a77c2c95
- Child:
- 8:5ad8a7892693
--- a/main.cpp Mon Oct 22 13:51:40 2018 +0000 +++ b/main.cpp Mon Oct 22 14:24:13 2018 +0000 @@ -26,10 +26,10 @@ // Extra stuff // Like LED lights, buttons etc /* -DigitalIn button_motorcal(); // button for motor calibration -DigitalIn button_emergency(); // button for emergency mode -DigitalIn button_start(); // button for start mode (from demo mode) -DigitalIn button_demo(); // button for demo mode +DigitalIn button_motorcal(SW1); // button for motor calibration +DigitalIn button_emergency(D7); // button for emergency mode +DigitalIn button_wait(SW2); // button for wait mode +DigitalIn button_demo(D6); // button for demo mode */ DigitalIn led_red(LED_RED); // red led DigitalIn led_green(LED_GREEN); // green led @@ -56,8 +56,8 @@ float time_in_state; // states -enum states (WAIT, MOTOR_CAL, EMG_CAL, START, OPERATING, FAILURE, DEMO) // states the robot can be in -states CurrentState = WAIT; // the current state to start with is the WAIT state +enum states (WAIT, MOTOR_CAL, EMG_CAL, START, OPERATING, FAILURE, DEMO); // states the robot can be in +states CurrentState = WAIT; // the CurrentState to start with is the WAIT state bool StateChanged = true; // the state must be changed to go into the next state // Functions @@ -160,11 +160,17 @@ StateChanged = false; // the state is still WAIT } - if() // condition for WAIT --> MOTOR_CAl; button press + if(button_motorcal == true) // condition for WAIT --> MOTOR_CAl; button_motorcal press { CurrentState = MOTOR_CAL; StateChanged = true; } + + if (button_emergency == true) // condition for WAIT --> FAILURE; button_emergency press + { + CurrentState = FAILURE; + StateChanged = true; + } break; @@ -186,6 +192,12 @@ StateChanged = true; } + if (button_emergency == true) // condition for MOTOR_CAL --> FAILURE; button_emergency press + { + CurrentState = FAILURE; + StateChanged = true; + } + break; case EMG_CAL: @@ -207,6 +219,12 @@ StateChanged = true; } + if (button_emergency == true) // condition for EMG_CAL --> FAILURE; button_emergency press + { + CurrentState = FAILURE; + StateChanged = true; + } + break; case START: @@ -228,6 +246,12 @@ StateChanged = true; } + if (button_emergency == true) // condition for START --> FAILURE; button_emergency press + { + CurrentState = FAILURE; + StateChanged = true; + } + break; case OPERATING: @@ -239,13 +263,13 @@ StateChanged = false; // state is still OPERATING } - if() // condition for OPERATING --> FAILURE; button press + if(button_emergency == true) // condition for OPERATING --> FAILURE; button_emergency press { CurrentState = FAILURE; StateChanged = true; } - if() // condition for OPERATING --> DEMO; button press + if(button_demo == true) // condition for OPERATING --> DEMO; button_demo press { CurrentState = DEMO; StateChanged = true; @@ -262,7 +286,7 @@ StateChanged = false; // state is still FAILURE } - if() // condition for FAILURE --> WAIT; button press + if(button_wait == true) // condition for FAILURE --> WAIT; button_wait press (IF THAT IS EVEN POSSIBLE IN THIS STATE?) { CurrentState = WAIT; StateChanged = true; @@ -279,13 +303,13 @@ StateChanged = false; // state is still DEMO } - if() // condition for DEMO --> WAIT; button press + if(button_wait == true) // condition for DEMO --> WAIT; button_wait press { CurrentState = WAIT; StateChanged = true; } - if () // condition for DEMO --> FAILURE; button press + if (button_emergency == true) // condition for DEMO --> FAILURE; button_emergency press { CurrentState = FAILURE; StateChanged = true;