ButtonHandler: Simplify button handling/customization (up to 7 buttons), detect button combos#61
ButtonHandler: Simplify button handling/customization (up to 7 buttons), detect button combos#61
Conversation
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)). Tested on a different branch, but not tested here yet.
|
Gibt es eine Beschreibung was der Code tun sollte? Und wie man es nutzen/prüfen kann? Ich suche eine Möglichkeit weitere Buttons zB an A5-A7 anzuschließen und dort entweder Shortcuts oder direkt drei Verzeichnisse/Dateien zuordnen. Danke! |
|
Moin. Ich habe die Änderungen auf einem anderen Branch getestet (hauptsächlich Abspielen, Wechsel ins Admin-Menü und zurück. Nicht getestet: Optionen im Adminmenü, Modifier-Karten, Karten anlernen). Du kannst diesen Stand als Basis nehmen.
switch (event) case Tatuetata | ShortPress: Viel Spaß! |
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