ButtonHandler: Simplify button handling/customization (up to 7 buttons), detect button combos #61
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.
Allows for easier code to handle button events (by switch()ing on event codes),
and detects button combinations (Press X + Y (shortly), X + Y (hold), press and hold 3 buttons).
Tested on a different branch, but not tested here yet.
For example, see main loop (line 1080++).
// Use ButtonHandler.handle() return value to read codes.
// Valid codes (using Up, Down as sample buttons:
// Up | ShortPress "Up" was pressed and quickly released
// Up | LongPress "Up" was pressed and is still held (after first LONG_PRESS duration)
// Up | LongRepeat "Up" was pressed and is still held (after following LONG_PRESS durations)
// TwoButtons | Up | (Down << As2nd) | ShortPress "Up" was pressed and then "Down", which was quickly released
// TwoButtons | Up | (Down << As2nd) | LongPress "Up" was pressed and then also "Down",
// which is still held (after first LONG_PRESS duration)
// TwoButtons | Up | (Down << As2nd) | LongRepeat "Up" was pressed and then also "Down",
// which is still held (after following LONG_PRESS durations)
// AllThreeLong any three buttons have been pressed at the same time for one LONG_PRESS duration