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.
Fork of OneButton by
Revision 3:48a593e2d4cf, committed 2016-09-22
- Comitter:
- JojoS
- Date:
- Thu Sep 22 21:46:37 2016 +0000
- Parent:
- 2:26960fb1d783
- Commit message:
- reverted to original state machine behaviour by mh. This works better for detecting click / double click events.
Changed in this revision
OneButton.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/OneButton.cpp Thu Sep 22 20:36:52 2016 +0000 +++ b/OneButton.cpp Thu Sep 22 21:46:37 2016 +0000 @@ -143,7 +143,6 @@ switch (_state) { case 0: if(button_level == active) { //start press - if(clickFn) clickFn(); timer->reset(); _state = 1; } @@ -154,6 +153,7 @@ _state = 2; } else if(ticks > _pressTicks) { + if(pressFn) pressFn(); //press event if(longPressStartFn) longPressStartFn(); _isLongPressed = 1; _state = 5; @@ -162,12 +162,10 @@ case 2: if(ticks > _clickTicks) { //released - //press event - if(pressFn) pressFn(); //press event + if (clickFn) clickFn(); _state = 0; //reset } else if(button_level == active) { //press again - if(clickFn) clickFn(); _state = 3; } break;