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

Buttons: Trigger on button press (instead of release) if all configured presets are the same #3226

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

Sebbb
Copy link
Contributor

@Sebbb Sebbb commented May 31, 2023

Hello,

this addresses #3189. It works well for me, but I'm not sure if it doesn't maybe need additional debouncing code with some switches.

@blazoncek
Copy link
Collaborator

Thank you.
Would you be so kind and also add the info (PR) about same presets causing such behaviour to WLED docs?

@softhack007
Copy link
Collaborator

softhack007 commented May 31, 2023

maybe need additional debouncing code with some switches.

I think you're right here, a new debounce logic must be added in case that "button activation" is used as a trigger.

The current "trigger on release" logic applies debouncing before the release event. However with "trigger on activation", the problem will be that a single press is followed by several "ghost" activations and deactivations (typically within 100-300 milliseconds). It does not depend on the button type - both switches and momentary buttons do bounce before they settle in the final position.

So it seems that your optimization also requires a new debouncing logic, to be usefull in the general case.

https://en.m.wikipedia.org/wiki/Switch#Contact_bounce

Bouncy_Switch

@Sebbb
Copy link
Contributor Author

Sebbb commented May 31, 2023

Hi,

I never experienced issues with that, for me it works perfectly reliable. Maybe because that button check routine is only executed every few milliseconds (?) to check the button state and does not trigger an interrupt.

However, I'm definitely not a good programmer and probably wouldn't be able to add that, if it's needed :(

Sebastian

@Aircoookie
Copy link
Owner

Added a slightly hacky debounce logic, should work fine though.
On release it only reset buttonPressedBefore after 50 ms of uninterrupted released, and thus block further presses until the button has been released properly.

@softhack007
Copy link
Collaborator

Added a slightly hacky debounce logic,

Thanks @Aircoookie, I think this will do the trick 👍

@Sebbb
Copy link
Contributor Author

Sebbb commented May 31, 2023

@Aircoookie I just compiled and tried your changes, works well :)

Aircoookie added a commit to Aircoookie/WLED-Docs that referenced this pull request Jun 2, 2023
…ed presets are the same - Docu (#132)

* Update macros.md

Added docu for momentary button change. Belongs to Aircoookie/WLED#3226

* Added version for button change

---------

Co-authored-by: Christian Schwinne <cschwinne@gmail.com>
@Aircoookie Aircoookie merged commit af88c68 into Aircoookie:main Jun 2, 2023
@Sebbb Sebbb deleted the topic-trigger-on-button-press branch June 2, 2023 15:59
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.

4 participants