-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I would like to be able to detect long presses without releasing the button.
I tried this:
loop {
button.tick();
if let Some(dur) = button.current_holding_time() {
if dur >= Duration::from_secs(2) {
info!("Long press");
}
}
button.reset();
Timer::after_millis(2).await;
}This works but after the initial delay it repeatedly prints "Long press" until the button is released. I would like it to ignore the button position until it is released so that the "event" is only fired once.
Looking at the code I think the easiest way to enable this behavior is to add a new State:PendingRelease that can be set by the user and a match pattern in tick() like this:
State::PendingRelease if self.is_pin_released() => self.state = State::Released,WDTY? Does it make sense to add this to your library? I can make a PR with this change or another solution if you want.
Metadata
Metadata
Assignees
Labels
No labels