-
Notifications
You must be signed in to change notification settings - Fork 35
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
release callack #57
Comments
Hello, the behavior you describe is by design. Currently there is no callback for a button being pressed. Only after a button is released we can determine if it was a click, a double click or a long click. The main goal for having a release callback is for fast actions when no click or double click needs to be detected while allowing checking if other buttons are still being pressed (think of a shift key). The normal usage of what I think you intend to do is only have a click callback, which is indeed called right after the button was released. FYI: in case of a double-click the sequence is like this:
If you still want to act before the release is done (e.g. to give visual indication of a button being pressed), you could use the return value of |
Thanks you very much for your rapid response and explanation. |
I think in your mind you need to distinguish press from click. A click is press+release. A long click has long duration between press and release. A double click is two clicks within a short time. Normally you call the tick() method numerous times at the top of your running loop(). The tick() method implements a state engine to determine the state of each possible button. Only once released tick() can tell if a button was clicked once, twice or long. If you print millis() in the callbacks you can see the time between the various events. Each time you call tick, it returns a 32-bit value containing the on/off value of 32 buttons maximum. Before returning it sets timers, updates the state engine and does callbacks. However when just pressing, tick() currently returns without doing a callback. Whether and when a specific button is pressed is stored in the state engine. Eventually tick() returns the current on/off value of all possible buttons. Does this clarify things? |
Thank for your support |
Hi, firstly I thank for your library.
I want to simulate tm1638 buttons as push puttons.
I coded and worked.
I attached release and click callback functions.
However, release fn is called before click fn.
And this makes some awkward behaviour in my scenerio.
Could you please guide me how to call release callback fn after click fn?
Thanks
example monitor output when I pressed and released button 1:
relased button: 1
pressed button: 1
The text was updated successfully, but these errors were encountered: