Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for an immediate "press" event callback #141

Merged
merged 5 commits into from
May 27, 2024

Conversation

mattallen37
Copy link
Contributor

No description provided.

Debounce the button state, not just the pin state. This way debounce() will know if it's pressed or not pressed.

Also, enable a negative ms value so it will only debounce the state on inactive. This way a button press will be recognized instantly. Deactivating the button press will still be subject to the debounce time, preventing switch "noise" from propagating through to the _fsm.
These should be boolean values, since they are passed into _fsm() which expects bool. Otherwise the (previous) default value of -1 will be interpreted by the _fsm() as being 'true' (not 0).
Add support for a callback immediately when detecting a press, rather than the alternatives of waiting for a release or a long press.
Tidy up a single-line if-statement.
@mattallen37
Copy link
Contributor Author

Each commit is commented.

This should solve Issue #139.

Copy link
Owner

@mathertel mathertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the commit comments to readme.md especially the possibility and changed behavior around _debounce_ms.

Update readme to reflect the changes.
@mathertel mathertel merged commit 05242ac into mathertel:master May 27, 2024
4 checks passed
@mathertel
Copy link
Owner

Thanks Matthew @mattallen37.
I will run my tests and publish a new version soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants