Duncan Parker
/
digitalInPolling_sample
Revision 4:fd867d8afe4f, committed 2019-01-24
- Comitter:
- duncangparker
- Date:
- Thu Jan 24 09:54:54 2019 +0000
- Parent:
- 3:8d87cbabe37e
- Commit message:
- Lab2 program b
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 15 09:47:06 2019 +0000 +++ b/main.cpp Thu Jan 24 09:54:54 2019 +0000 @@ -42,7 +42,7 @@ } break ; } - wait(0.03); + wait(0.03); } } @@ -53,11 +53,45 @@ led = 1 ; // Initially off pollT.start(callback(polling)); - while(true) { + int counter = 2; + int rate = 1; + + + //functions with counter + while(1){ + if(pressEvent){ + pressEvent = 0; + rate = rate + 2; + if(rate > 10){ + rate = 1; + } + } + + counter--; + if(counter == 0){ + led = !led; + counter = rate; + } + + wait(0.1); + } + + // Functions + float LED_SW = 0.2; + + while(1){ if (pressEvent) { - pressEvent = 0 ; // clear the event variable - led = !led ; + pressEvent = 0; + LED_SW = LED_SW + 0.2; + if (LED_SW > 1){ + LED_SW = 0.2; + } } - Thread::wait(0.1) ; + + led = !led; + wait(LED_SW); } + + + } \ No newline at end of file