How 0x1abin/multibutton works
MultiButton is a compact embedded C library that turns sampled GPIO levels into debounced button events. The main workflow is application setup and callback registration, periodic timer-driven scanning, state-machine event detection, then callback handling or polling. The implementation confirms the scan, debounce, state transitions, linked-list management, and polling APIs; other documented capabilities such as configurable thresholds and optional RTOS locks are defined in the header.
Main entry points: multi_button.h Button state · multi_button.c Debounce and state machine
Components 12
Application Setup
- Initialize button
multi_button.c - Attach callbacks
multi_button.c - Start button
multi_button.c
Button Runtime
- Button state
multi_button.h - Tick dispatcher
multi_button.c - Debounce and state machine
multi_button.c
Event Consumption
- Callback dispatch
multi_button.c - Polling accessors
multi_button.c
Other components
- Embedded application
- Periodic timer
- GPIO reader
- Event consumer
Connections 15
- Embedded application → Initialize button: initializes
- Initialize button → Button state: sets state
- Embedded application → Attach callbacks: registers callbacks
- Attach callbacks → Button state: stores callbacks
- Embedded application → Start button: starts scanning
- Start button → Button state: links handle
- Periodic timer → Tick dispatcher: invokes periodically
- Tick dispatcher → Debounce and state machine: scans handles
- Debounce and state machine → GPIO reader: reads pin level
- Debounce and state machine → Button state: updates state
- Debounce and state machine → Callback dispatch: dispatches events
- Callback dispatch → Event consumer: invokes callback
- Embedded application → Polling accessors: requests event state
- Polling accessors → Button state: reads state
- Polling accessors → Event consumer: returns event data