| Crates.io | unflappable |
| lib.rs | unflappable |
| version | 0.2.0 |
| created_at | 2020-08-12 05:42:44.935859+00 |
| updated_at | 2023-04-18 04:25:20.244048+00 |
| description | A batteries-included embedded-hal InputPin debouncer. |
| homepage | |
| repository | https://git.sr.ht/~couch/unflappable |
| max_upload_size | |
| id | 275703 |
| size | 40,277 |
A batteries-included embedded-hal InputPin debouncer.
Add the following to your Cargo.toml:
[dependencies]
unflappable = "0.2"
Create an uninitialized Debouncer in static storage.
use unflappable::{debouncer_uninit, Debouncer, default::ActiveLow};
static DEBOUNCER: Debouncer<PinType, ActiveLow> = debouncer_uninit!();
Initialize the Debouncer with your input pin, returning the
Debounced pin. Use this pin just as you would any other
InputPin, such as passing ownership to another abstraction.
let debounced_pin = unsafe { DEBOUNCER.init(input_pin) }?;
Regularly poll the Debouncer, perhaps in an interrupt service routine.
unsafe {
DEBOUNCER.poll()?;
}
API docs are hosted on docs.rs:
This crate makes use of trait bounds on a const fn, which
requires Rust 1.61.
There are at least three debouncing crates targeting embedded Rust development. How does this one compare to the others?
unflappable
InputPin: Yesu8debounced-pin
InputPin: Yesu8 + enumdebouncr
InputPin: Nou8debouncing
InputPin: Nou8 + dynamically-allocated VecI'm happy to see any and all contributions, including bug reports, usability suggestions, patches, or angry yet well-intentioned rants. You are encouraged to report issues to the official issue tracker and send any questions or patches to the mailing list. Pull requests to the GitHub mirror are also acceptable.