Anastasios Barlas
/
digitalInPolling_sample
Lab2 part 1
Fork of digitalInPolling_sample by
Revision 3:2975e7b89642, committed 2018-02-01
- Comitter:
- AnastasiosBarlas
- Date:
- Thu Feb 01 17:59:41 2018 +0000
- Parent:
- 2:cd1fe8c29793
- Commit message:
- Version1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 16 18:02:44 2018 +0000 +++ b/main.cpp Thu Feb 01 17:59:41 2018 +0000 @@ -13,7 +13,7 @@ Thread pollT ; // thread to poll volatile int pressEvent = 0 ; // Variabe set by the polling thread - +int ncycles =0; enum buttonPos { up, down, bounce }; // Button positions void polling() { buttonPos pos = up ; @@ -50,14 +50,20 @@ Note that if this thread completes, nothing else works */ int main() { - led = 1 ; // Initially off + led = 0 ; // Initially off pollT.start(callback(polling)); - + ncycles = 0 ; while(true) { if (pressEvent) { - pressEvent = 0 ; // clear the event variable - led = !led ; + if (ncycles == 800){ + ncycles = 0; + } + else { + ncycles = ncycles + 200 ;} + + pressEvent = 0 ; // clear the event variable } - Thread::wait(100) ; - } + led = !led ; + Thread::wait(200+ncycles) ; + } } \ No newline at end of file