Skip to content

Add support for button.pressed_for(ms) - #21

Open
madleech wants to merge 2 commits into
masterfrom
add_pressed_for
Open

Add support for button.pressed_for(ms)#21
madleech wants to merge 2 commits into
masterfrom
add_pressed_for

Conversation

@madleech

Copy link
Copy Markdown
Owner

Long requested (see #8) is support for determining how long the button has been pressed for. When writting some child-proof code recently I ran into this limitation and realised how useful this feature would be.

This adds button.pressed_for(ms) and button.held_for(). The two are basically identical, just different ways of calling it. if (button.pressed_for(1000)) would be the normal interface, but if you want to calculate the number of repeats you can use button.held_time() % 1000 and get the repeat count, which can also be useful.

Note: includes a slight rejiggle of the variable ordering to save a few bytes on 32 bit platforms.

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.

1 participant