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: THE.cpp
- Revision:
- 29:344d11928bf5
- Parent:
- 28:1481896462ee
- Child:
- 30:ec9e7116f1b0
--- a/THE.cpp Fri Nov 02 10:03:01 2018 +0000 +++ b/THE.cpp Fri Nov 02 10:13:57 2018 +0000 @@ -786,39 +786,44 @@ pwmpin_2 = fabs (pwm1); } +// DEMO +// Executing demo mode, drawing a square void demo_mode() { - - - while(true){ - demo_control(-pi/4.0,-pi/4.0); - if ((Counts1(counts1) > -26267-1000 )&& (Counts1(counts1) < -26267+1000)&& (Counts2(counts2) > 13369-1000)&& (Counts2(counts2) < 13369+1000)){ - translation_stop() - rotation_stop() - break; + while(true) + { + demo_control(-pi/4.0,-pi/4.0); + if ((Counts1(counts1) > -26267-1000 )&& (Counts1(counts1) < -26267+1000)&& (Counts2(counts2) > 13369-1000)&& (Counts2(counts2) < 13369+1000)) + { + translation_stop(); + rotation_stop(); + break; + } + } + + while(true) + { + demo_control(pi,pi); + if ((Counts1(counts1) > -78802-1000 )&& (Counts1(counts1) < -78802+1000)&& (Counts2(counts2) > 13369-1000)&& (Counts2(counts2) < 13369+1000)) + { + translation_stop(); + rotation_stop(); + break; + } + } + + while(true) + { + demo_control(pi/4.0,pi/4.0); + if ((Counts1(counts1) > -105069-1000 )&& (Counts1(counts1) < -105069+1000)&& (Counts2(counts2) > 24732-1000)&& (Counts2(counts2) < 24732+1000)) + { + translation_stop(); + rotation_stop(); + break; + } } } - - while(true){ - demo_control(pi,pi); - if ((Counts1(counts1) > -78802-1000 )&& (Counts1(counts1) < -78802+1000)&& (Counts2(counts2) > 13369-1000)&& (Counts2(counts2) < 13369+1000)){ - translation_stop() - rotation_stop() - break; - } - } - - while(true){ - demo_control(pi/4.0,pi/4.0); - if ((Counts1(counts1) > -105069-1000 )&& (Counts1(counts1) < -105069+1000)&& (Counts2(counts2) > 24732-1000)&& (Counts2(counts2) < 24732+1000)){ - translation_stop() - rotation_stop() - break; - } - } -} - // code here - } + // FAILURE // To shut down the robot after an error etc @@ -998,7 +1003,7 @@ { CurrentState = WAIT; pc.printf("\r\nState is WAIT\r\n"); - Statechanged = false; + StateChanged = false; } break;