Skip to content

Repeat on hold button behavior - #9

Open
ARoese wants to merge 2 commits into
avsaase:masterfrom
ARoese:master
Open

Repeat on hold button behavior#9
ARoese wants to merge 2 commits into
avsaase:masterfrom
ARoese:master

Conversation

@ARoese

@ARoese ARoese commented Jul 18, 2026

Copy link
Copy Markdown

This PR adds a repeat-on-hold feature. It is enabled by setting the new held_repeat_interval config field to Some(Duration) and is disabled otherwise. When the button is held down for the long_press duration, it emits a ButtonEvent::LongPress as usual. Then, for the duration the button continues to be held, a ButtonEvent::ShortPress{count: 1} will be emitted every held_repeat_interval until it is released.

This functionality is useful for settings buttons, as it allows a user to press and hold an up or down button instead of needing to rapidly mash and wear it out. Surely, there are also other applications.

This is an API-breaking change, since a field is added to ButtonConfig. It also adds a dependency on embassy-futures for use embassy_futures::select::{select, Either}. Since there is already an embassy-time dependency, I figure that another well-known crate from the same ecosystem is fine.

I also added a unit test for the feature.

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