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

Problem with longpress behavior #72

Closed
juiplus opened this issue May 28, 2024 · 3 comments · Fixed by #73
Closed

Problem with longpress behavior #72

juiplus opened this issue May 28, 2024 · 3 comments · Fixed by #73

Comments

@juiplus
Copy link

juiplus commented May 28, 2024

I have tested the MultiHandler.ino example on an ESP8266.
In principle it works, only the behavior with a long click does not work as expected. If a long click (handler setLongClickDetectedHandler() used) is executed after a single click or double click, the old state is always output first, e.g. click(1) or click(2). Only when a long click is executed again is it recognized as longclick correctly.

Serial output:
Multi Handler Demo
click (1)
click (1) <-click loong, but click(1) will be recognized wrongly!?
longclick (1) <- that is correct

Please try to reproduce it, maybe there is a simple workaround.

@juiplus
Copy link
Author

juiplus commented May 29, 2024

I have now been able to fix the problem. Before calling the callback routine longclick_detected_cb(), the last_click_type must also be set to long_click. Then everything works as expected:

void Button2::_checkForLongClick(long now){
..
  last_click_type = long_click; // <- added
  longclick_detected_cb(*this);
  longclick_detected = true;
}

Would be nice if you could adopt this.
Thanks and greetings
Jui

@LennartHennigs
Copy link
Owner

LennartHennigs commented May 29, 2024

Hey Jui,
Thanks for reaching out.
I will definitely check it out.

LennartHennigs added a commit that referenced this issue May 30, 2024
@LennartHennigs LennartHennigs linked a pull request May 30, 2024 that will close this issue
LennartHennigs added a commit that referenced this issue May 30, 2024
@LennartHennigs
Copy link
Owner

Hey @juiplus,
you were right. Click count was also off. Updated the library.
Thanks again!

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 a pull request may close this issue.

2 participants