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: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 8:ccd58f78b5cb
- Parent:
- 7:af0c16ae48d7
- Child:
- 9:cb88b16a97d5
diff -r af0c16ae48d7 -r ccd58f78b5cb main.cpp --- a/main.cpp Tue Oct 01 13:31:36 2019 +0000 +++ b/main.cpp Tue Oct 01 13:56:14 2019 +0000 @@ -1,21 +1,51 @@ -//includes +//Libraries #include "mbed.h" + //objects and variables DigitalOut ledb(LED_BLUE); // ledb=true is led off!! DigitalOut ledg(LED_GREEN); DigitalOut ledr(LED_RED); + enum States {MovementIdle, CalibrationIdle, Demo, Startup, CalibrationPhysical, Move, TiltCup, FailState}; States CurrentState; + char ledcolor; //r is red, b is blue, g is green, t is bluegreen, p is purple Ticker Tick_Blinky;//used for the blinking of the leds +//Led FLicker +void FlipLED(void) +{ + switch(ledcolor) + { + case 'r': + ledr =! ledr; + ledg = true; + ledb = true; + break; + case 'b': + ledr = true; + ledg = true; + ledb =! ledb; + break; + case 'g': + ledr = true; + ledg =! ledg; + ledb = true; + case 't': + ledr = true; + ledg =! ledg; + ledb =! ledb; + break; + case 'p': + ledr =! ledr; + ledg = true; + ledb =! ledb; + break; + } +} + void Run_Demo(void) { - ledg=false; - ledr=true; - ledb=true;//only turns on the green light - - Tick_Blinky.attach() } @@ -62,6 +92,11 @@ //State Machine void StateMachine(void) { + //Turn off all LEDs + ledr = true; + ledg = true; + ledb = true; + switch(CurrentState) { case Demo: @@ -104,13 +139,20 @@ } //Main Loop +void mainloop() +{ + Statemachine(); +} + int main() -{ ledb=true; - ledr=true; - ledg=true;//turn off all leds +{ + //Initialize + + Tick_Blinky.attach(FlipLED,1); CurrentState = Startup; + while(true) { - + } } \ No newline at end of file