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:
- 24:d0ca537913c2
- Parent:
- 23:767911637f3a
- Child:
- 27:71be6e074d0f
diff -r 767911637f3a -r d0ca537913c2 main.cpp --- a/main.cpp Tue Oct 08 13:45:30 2019 +0000 +++ b/main.cpp Wed Oct 09 07:11:45 2019 +0000 @@ -7,9 +7,6 @@ //Homebrew libraries #include "header.h" - //#include "controller.cpp" - #include "globalvariables.cpp" - //Objects //LED @@ -39,17 +36,15 @@ volatile char ledcolor; //r is red, b is blue, g is green, t is bluegreen, p is purple volatile int errorCode; - //Ticker Timings - const float mainLoopT = 2; //Main Loopt Ticker wait - const float ledFlipperT = .5; //LED Flicker wait +//Ticker Timings + const float mainLoopT = 2; //Main Loopt Ticker wait + const float ledFlipperT = .5; //LED Flicker wait - - //Tickers Ticker Main_Ticker; Ticker Tick_Blinky;//used for the blinking of the leds -//Led FLicker +//Changing LED colour depending on current state void FlipLED(void) { pc.printf("FLIPLED \r\n"); @@ -87,6 +82,7 @@ pc.printf("Color %c \r\n",ledcolor); } +// Testing Placeholder // SW2 = button1 state changing void Run_StateChangerButton1() { @@ -115,6 +111,8 @@ break; } } + +// Testing Placeholder // SW3 = button2 state changing void Run_StateChangerButton2(void) { @@ -132,7 +130,6 @@ } } - //State functions void Run_Demo(void) { @@ -159,7 +156,6 @@ pc.printf("Starting Calibration Physical ... \r\n"); wait(1); CurrentState = CalibrationIdle; - } void Run_CalibrationEMG(void) @@ -186,7 +182,6 @@ //State Machine void StateMachine(void) { - //Turn off all LEDs switch(CurrentState) { case Demo: @@ -232,43 +227,51 @@ } } -//Main Loop +//Main Loop, constantly running function void mainloop() { StateMachine(); } +//The main function int main() { - //Initialize - ledr = true; - //ledr.write(.4); - ledg = true; - //ledg.write(.4); - ledb = true; - //ledb.write(.4); - - pc.baud(115200); - CurrentState = Startup; - + //-Initialize + //--Turning LEDs off + ledr = true; + ledg = true; + ledb = true; + //--Set baud + pc.baud(115200); + //--Set first state + CurrentState = Startup; + //--Setup Buttons (Placeholder for testing) button1.mode(PullUp); button1.rise(Run_StateChangerButton1); button2.mode(PullUp); button2.rise(Run_StateChangerButton2); - //Tickers + //-Activate Tickers Main_Ticker.attach(mainloop,mainLoopT); wait(mainLoopT); Tick_Blinky.attach(FlipLED,ledFlipperT); //Placeholder function call - double PlantError = 1; - double Ts = 1; - double u = ControllerPID(PlantError, Ts); + //double PlantError = 1; + //double Ts = 1; + //double u = ControllerPID(1, 1); + //X = 1; + //double Y = ProcessEMG(X); + int x; + int a; + a = 3; + int b; + b = 8; + x = AddInt(a,b); + //-Constantly running function while(true) { - X = 1; - double Y = ProcessEMG(X); + } } \ No newline at end of file