$npx -y skills add easyzoom/aix-skills --skill embedded-input-libsUse when integrating, porting, configuring, or debugging embedded button/input libraries such as MultiButton or FlexibleButton
| 1 | # Embedded Input Libs |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use this skill for button and simple input libraries such as MultiButton and FlexibleButton. The key is to align scan period, debounce time, electrical polarity, event semantics, and callback context. |
| 6 | |
| 7 | ## When To Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - The user wants to add or debug MultiButton, FlexibleButton, key scanning, long press, double click, or button event callbacks. |
| 12 | - Inputs bounce, trigger twice, miss long presses, fire in the wrong order, or behave differently across boards. |
| 13 | |
| 14 | Do not use this skill for complex UI frameworks or touch/display systems. Use LVGL-related skills when UI event routing dominates. |
| 15 | |
| 16 | ## First Questions |
| 17 | |
| 18 | Ask for: |
| 19 | |
| 20 | - Library: MultiButton, FlexibleButton, or custom button helper. |
| 21 | - Button circuit: pull-up/pull-down, active level, GPIO mode, external RC, matrix, or direct GPIO. |
| 22 | - Scan period and where scanning runs: timer, main loop, RTOS task, or interrupt. |
| 23 | - Desired events: press, release, click, double click, long press, repeat, hold. |
| 24 | - Current symptom and logic analyzer or GPIO trace if available. |
| 25 | |
| 26 | ## Integration Checklist |
| 27 | |
| 28 | 1. Confirm electrical polarity. |
| 29 | Active-low buttons with pull-ups are common; software level must match hardware. |
| 30 | |
| 31 | 1. Choose a stable scan period. |
| 32 | Debounce and click timing depend on the scan tick being regular. |
| 33 | |
| 34 | 1. Keep callbacks lightweight. |
| 35 | Button callbacks should post events or set flags, not block or write flash. |
| 36 | |
| 37 | 1. Define event semantics. |
| 38 | Decide whether long press also emits click, whether double click suppresses single click, and when release fires. |
| 39 | |
| 40 | 1. Test with measured input. |
| 41 | Compare software events with a logic analyzer or GPIO trace when behavior is unclear. |
| 42 | |
| 43 | ## Common Failures |
| 44 | |
| 45 | - Wrong active level makes pressed and released inverted. |
| 46 | - Scan period jitter breaks double-click detection. |
| 47 | - Long press also triggers unwanted single click. |
| 48 | - Callback runs in timer/ISR context and blocks. |
| 49 | - Shared button state is accessed from multiple tasks without protection. |
| 50 | |
| 51 | ## Verification |
| 52 | |
| 53 | Before claiming input handling works: |
| 54 | |
| 55 | - State active level, scan period, debounce time, and callback context. |
| 56 | - Test press, release, click, long press, repeated press, and bounce. |
| 57 | - Confirm event order matches product expectations. |
| 58 | - Confirm no flash writes or blocking operations occur in unsafe context. |
| 59 | |
| 60 | ## Example |
| 61 | |
| 62 | User: |
| 63 | |
| 64 | ```text |
| 65 | MultiButton 长按会同时触发单击。 |
| 66 | ``` |
| 67 | |
| 68 | Agent: |
| 69 | |
| 70 | 1. Asks for scan period, event configuration, active level, and expected semantics. |
| 71 | 1. Checks whether single click is delayed until double/long decision is known. |
| 72 | 1. Verifies event order with a controlled press-duration test. |