Leonardo Iandiorio
/
BlinkButton2Sec
In class exercise
Revision 1:bc20d07886cc, committed 2018-11-29
- Comitter:
- iandil
- Date:
- Thu Nov 29 17:24:07 2018 +0000
- Parent:
- 0:03a01dc34973
- Commit message:
- modified interval time;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 16 13:45:52 2018 +0000 +++ b/main.cpp Thu Nov 29 17:24:07 2018 +0000 @@ -9,17 +9,15 @@ void rise_handler_thread_context(void) { counter++; - if((time(NULL) - seconds_now) < 2000) { - if(counter == 2) { - led3 = !led3; - wait(0.8); - led3 = !led3; - counter = 0; - seconds_now = time(NULL); - } + if(counter == 2) { + counter = 0; + if((time(NULL) - seconds_now) < 2) { + led3 = !led3; + wait(0.8); + led3 = !led3; + } } else { seconds_now = time(NULL); - counter = 0; } } @@ -39,7 +37,6 @@ t.start(callback(&queue, &EventQueue::dispatch_forever)); printf("Starting in context %p\r\n", Thread::gettid()); // The 'rise' handler will execute in IRQ context - seconds_now = time(NULL); button.rise(rise_handler_iterrupt_context); // The 'fall' handler will execute in the context of thread 't' button.fall(queue.event(fall_handler));