Martin Allen
/
Task324SolutionWORKING
Toggle 2 Leds with two switches
Fork of Task324Solution by
Revision 2:1874cdaec623, committed 2018-03-10
- Comitter:
- martinjamesallen1991
- Date:
- Sat Mar 10 00:38:49 2018 +0000
- Parent:
- 1:b7cc6bbb077d
- Commit message:
- new
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b7cc6bbb077d -r 1874cdaec623 main.cpp --- a/main.cpp Thu Mar 08 03:25:49 2018 +0000 +++ b/main.cpp Sat Mar 10 00:38:49 2018 +0000 @@ -12,17 +12,8 @@ #define WAITING4RELEASE 2 #define WAITING4BOUNCE_FALLING 4 -// Update the state for a given switch and LED pair -// Parameters: -// sw is the switch input, 0 for released and 1 for pressed, passed by value -// swState is an integer that keeps a record of state, passed by reference (updated by the function) -// led is of type DigitalOut, connected to a LED -// tmr is of type Timer, a reference to unique instance of a timer -// This function cannot be called by an ISR - void updateState(int sw, int &swState, DigitalOut &led, Timer &tmr) { - //LED switch (swState) { //Waiting for switch to be pressed @@ -35,7 +26,6 @@ //Next state swState = WAITING4BOUNCE_RISING; - puts("Entering state: WAITING4BOUNCE_RISING"); } break; @@ -45,8 +35,7 @@ //Outputs: Stop timer tmr.stop(); //Next state - swState = WAITING4RELEASE; - puts("Entering state: WAITING4RELEASE"); + swState = WAITING4RELEASE; } break; @@ -59,7 +48,6 @@ tmr.start(); //Next state swState = WAITING4BOUNCE_FALLING; - puts("Entering state: WAITING4BOUNCE_FALLING"); } break; @@ -72,7 +60,6 @@ //Next state: swState = WAITING4PRESS; - puts("Entering state: WAITING4PRESS"); } break; @@ -82,7 +69,6 @@ tmr.reset(); led = 0; swState = WAITING4PRESS; - puts("ERROR"); break; } //end switch @@ -91,8 +77,6 @@ int main() { - //Initial logging message - puts("START"); //Initial state red_led = 0; //Set RED LED to OFF @@ -108,8 +92,6 @@ tmr2.stop(); tmr2.reset(); - //Initial logging message - puts("Entering state WAITING4PRESS"); //Main Polling Loop while (true) {