Skip to content

unit: Add SimpleDualButtonUnit for callback-free polling - #103

Open
amin45mh wants to merge 2 commits into
m5stack:masterfrom
amin45mh:feature/simpledualbutton
Open

unit: Add SimpleDualButtonUnit for callback-free polling#103
amin45mh wants to merge 2 commits into
m5stack:masterfrom
amin45mh:feature/simpledualbutton

Conversation

@amin45mh

@amin45mh amin45mh commented Jul 7, 2026

Copy link
Copy Markdown

Add SimpleButton class and SimpleDualButtonUnit factory that wrap machine.Pin directly, providing simple polling methods (value, is_active, was_pressed, was_released) without requiring tick() or callbacks. The existing DualButtonUnit is unchanged.

amin45mh and others added 2 commits July 7, 2026 11:41
Add SimpleButton class and SimpleDualButtonUnit factory that wrap machine.Pin directly, providing simple polling methods (value, is_active, was_pressed, was_released) without requiring tick() or callbacks. The existing DualButtonUnit is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@imliubo
imliubo requested a review from hlym123 July 21, 2026 06:19
@hlym123

hlym123 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution. We adopted this idea and merged a revised
implementation into the develop branch in f44294d.

The merged version keeps the existing DualButtonUnit API unchanged and adds
SimpleButton and SimpleDualButtonUnit for callback-free polling. value() and
is_active() read machine.Pin directly, while update() is only required once
per loop for debounced was_pressed() and was_released() edge detection.

The revised implementation also adds configurable debounce_ms, correct
pull-up/pull-down handling for active_low, initialization from the current
input level, a MicroPython example, and English/Chinese documentation.

Since this functionality is now available in develop, we will close this PR.
Thanks again for the contribution.

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.

2 participants