-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button hold delay + hold repeat rate #1095
Comments
So I guess you're asking for e.g. a As a "temporary hack" what happens if you directly modify the Button's |
Yes. Ideally it could be represented with only two parameters,
Thanks, it works, it will do for the time being. from gpiozero import Button
from signal import pause
button = Button(16, pull_up=True, hold_repeat=True)
def when_pressed():
print("pressed")
def when_held():
print("held")
button.hold_time = 0.1
def when_released():
print("released")
button.hold_time = 1
print("starting")
button.when_pressed = when_pressed
button.when_held = when_held
button.when_released = when_released
pause() |
I don't think we should break backwards-compatibility (especially for such a small tweak as this), as we don't want to suddenly break all of the existing user-code that's making use of GpioZero! I've not given it much thought, but perhaps an "API" something like this works in a backwards-compatible manner? def __init__(self, pin=None, *, pull_up=True, active_state=None,
bounce_time=None, hold_time=1, hold_repeat=False,
hold_repeat_time=None, pin_factory=None):
if hold_repeat and hold_repeat_time is None:
hold_repeat_time = hold_time
# ...and now do everything else...
Awesome! I guess for consistency, since you're setting |
I would like to set a different hold delay and a hold repeat rate for a Button, like when you hold a key on the keyboard on PC.
Currently it is not possible because the Button waits
hold_time
first, then fires everyhold_time
.The text was updated successfully, but these errors were encountered: