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

input debounce? #10

Closed
mhelmarc opened this issue Jan 25, 2023 · 6 comments
Closed

input debounce? #10

mhelmarc opened this issue Jan 25, 2023 · 6 comments

Comments

@mhelmarc
Copy link

Hi, first off, I'm trying to learn nodejs and gpio, and your module is the most platform independent I could find.
Almost all of gpio module for nodejs is geared toward raspberry pi, I'm on an Alwinner (nanopi neo) SOC.
The module works as demoed, but I'm using buttons and sometimes I'm getting more than one result on a single press,
Do you know of a workaround for it?

@noctarius
Copy link
Collaborator

This has nothing to do with the library but is a very common occurrence with push buttons where the electrical signal is picked up multiple times due to mechanical reasons (commonly referred to as bouncing). You can either fix this in hardware (https://www.digikey.de/en/articles/how-to-implement-hardware-debounce-for-switches-and-relays) or software (https://docs.arduino.cc/built-in-examples/digital/Debounce).

@mhelmarc
Copy link
Author

Thanks, I was hoping for something similar with the 'onoff' module.

@noctarius
Copy link
Collaborator

This library only wraps the libgpiod with a nodejs api. Debouncing isn't built in but it is easy enough to do. Feel free to provide a PR to add it as an additional module. Something like passing in a Line instance into a PushButton instance (or something like it) and have it available for all people in the future :)

@mhelmarc
Copy link
Author

mhelmarc commented Jan 26, 2023 via email

@adminy
Copy link

adminy commented Jul 28, 2023

I'm guessing another solution to this would be the monitoring callbacks but that's not yet implemented, but the idea is that it monitors any changes on the input pins selected and logs an event of raise or fall of an edge.

@sombriks
Copy link
Owner

closing but hopefully will get solved when monitoring finally gets implemented. see #23

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

4 participants