Skip to content

Per-button opaque handles, individual timers, interrupt mode#5

Merged
UncleRus merged 1 commit intoesp-idf-lib:mainfrom
cleishm:refactor/button-v2
Mar 14, 2026
Merged

Per-button opaque handles, individual timers, interrupt mode#5
UncleRus merged 1 commit intoesp-idf-lib:mainfrom
cleishm:refactor/button-v2

Conversation

@cleishm
Copy link
Contributor

@cleishm cleishm commented Mar 13, 2026

Summary

  • Replace the shared global timer and fixed-size static array with per-button opaque handles (button_create/button_delete), each with its own esp_timer and mutex
  • Add interrupt-based triggering mode (BUTTON_MODE_INTERRUPT) using GPIO ISR + one-shot debounce timer, as an alternative to periodic polling
  • Fix spurious final CLICKED event when releasing a button with autorepeat enabled
  • Adopt BUTTON_DEFAULT_CONFIG() macro for zero-boilerplate configuration
  • Bump version to 2.0.0: The API has changed from button_init/button_done with user-allocated button_t structs to button_create/button_delete with opaque button_handle_t handles. The callback signature has also changed to receive a button_event_t struct.

Resolves #3, resolves #4.

@cleishm cleishm changed the title refactor!: per-button opaque handles, individual timers, interrupt mode Per-button opaque handles, individual timers, interrupt mode Mar 13, 2026
@cleishm cleishm force-pushed the refactor/button-v2 branch 2 times, most recently from 65198c6 to f86ecf7 Compare March 14, 2026 01:49
API changed from static array + shared timer to per-button opaque
handles (button_create/button_delete). Adds interrupt mode with GPIO ISR
and debounce timer.

Bumps version to 2.0.0.
@cleishm cleishm force-pushed the refactor/button-v2 branch from f86ecf7 to 25de2de Compare March 14, 2026 01:54
@UncleRus
Copy link
Member

Thank you!

@UncleRus UncleRus merged commit 89885bc into esp-idf-lib:main Mar 14, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support interrupt-based button triggering Replace shared polling timer with per-button esp_timer and opaque handles

2 participants