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

Seperate callbacks for button-down and button-up instead only PUSHP? #35

Open
vanderbreye opened this issue Sep 6, 2024 · 3 comments
Open

Comments

@vanderbreye
Copy link

The PUSHP event, which is supposed to trigger on button press in the library, is only fired when the button is released, rather than immediately when it is pressed. I need the button press event to trigger as soon as the button is physically pressed, without waiting for the release. With this function, i could implement a function for a long-press that doesn't trigger the short-click.

@Fattoresaimon
Copy link
Owner

Hello,
This can be only of problem of interrupt calling order

if (_stat & PUSHR) {
    eventCaller (&onButtonRelease);
  }
  if (_stat & PUSHP) {
    eventCaller (&onButtonPush);

First i call the release and after the push.
Did you also enable the interrupt output of the push?

@vanderbreye
Copy link
Author

vanderbreye commented Sep 11, 2024 via email

@Fattoresaimon
Copy link
Owner

There is an example here, i assume you are using the I2C encoder V2
https://github.com/Fattoresaimon/ArduinoDuPPaLib/blob/master/examples/I2CEncoderV2/README.md

Encoder.onIncrement = encoder_increment;
Encoder.onDecrement = encoder_decrement;
Encoder.onMax = encoder_max;
Encoder.onMin = encoder_min;
Encoder.onButtonPush = encoder_push;
Encoder.onButtonRelease = encoder_released;
Encoder.onButtonDoublePush = encoder_double_push;

Encoder.autoconfigInterrupt(); // Enables the I2C Encoder V2 interrupts according to the previously attached callback

Or manually with the command
void writeInterruptConfig(uint8_t interrupt)

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

No branches or pull requests

2 participants