Skip to content

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