Skip to content

Add support for debouncing non-GPIO inputs. #1

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

infovore
Copy link

@infovore infovore commented Feb 5, 2024

Buttons can be connected via interfaces other than GPIO; for instance, using IO expanders over I2C or SPI, or via multiplexers.

This patch adds the option to instantiate a debouncer without a pin specified; it also adds the option to pass an explicit value into update().

This means that you could make debouncers for buttons connected via, eg, an I2C expander; every update loop, read the values over I2C, and pass that value into the update method for the appropriate object.

Buttons can be connected via interfaces other than GPIO; for instance,
using IO expanders over I2C or SPI, or via multiplexers.

This patch adds the option to instantiate a debouncer without a pin
specified; it also adds the option to pass an explicit value into
`update()`.

This means that you could make debouncers for buttons connected via, eg,
an I2C expander; every update loop, read the values over I2C, and pass
that value into the `update` method for the appropriate object.
@infovore
Copy link
Author

infovore commented Feb 5, 2024

Downsides to this: my implementation requires using the 'full' constructor every time, because of parameter detection. I wonder if there is a better way of approaching that. Alternatively: don't use a different constructor, just pass in a GPIO that never gets read, and instead use the 'forced' update method. Open to suggestions.

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.

1 participant