Repeat on hold button behavior - #9
Open
ARoese wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a repeat-on-hold feature. It is enabled by setting the new
held_repeat_intervalconfig field toSome(Duration)and is disabled otherwise. When the button is held down for thelong_pressduration, it emits aButtonEvent::LongPressas usual. Then, for the duration the button continues to be held, aButtonEvent::ShortPress{count: 1}will be emitted everyheld_repeat_intervaluntil 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 onembassy-futuresforuse embassy_futures::select::{select, Either}. Since there is already anembassy-timedependency, I figure that another well-known crate from the same ecosystem is fine.I also added a unit test for the feature.