Skip to content

Async button handling crate for no_std environments. Built around embedded-hal traits and embassy-time.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

avsaase/async-button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7f21072 · Jan 24, 2025

History

25 Commits
Jan 24, 2025
Dec 1, 2023
Jan 24, 2025
Oct 28, 2024
Nov 29, 2023
Jan 24, 2025
Jan 24, 2025
Dec 1, 2023
Dec 1, 2023
Dec 2, 2023
Jan 24, 2025
Dec 1, 2023
Nov 29, 2023

Repository files navigation

Async Button

Async button handling crate for no_std environments. Built around embedded-hal 1.0 traits and embassy-time.

  • Detect button presses without blocking execution of other tasks or unnecessary polling.
  • Debouncing
  • Detect single and multiple short presses
  • Detect long presses
  • Detect sequences of short and long presses or multiple long presses. Open an issue if this would be useful to you, or submit a PR!

Example

let pin = /* Input pin */;
let mut button = Button::new(pin, ButtonConfig::default());

// In a separate task:
loop {
    match button.update().await {
        ButtonEvent::ShortPress { count } => {/* Do something with short presses */},
        ButtonEvent::LongPress => {/* Do something with long press */},
    }
}

Features

  • defmt: derives defmt::Format on public types (except Button).
  • std: uses tokio instead of embassy-time. Mainly useful for tests.

License

Licensed under either of

at your option.

About

Async button handling crate for no_std environments. Built around embedded-hal traits and embassy-time.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages