-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Using the buttons #233
Comments
On Prime/Inventor hubs, the center button is treated the same as the green button on other hubs. So if you really want to use it, you can catch the We can make an example, but we don't really want to widely encourage using it. |
Makes sense... still think that something needs to be done to clarify this in Button documentation. |
We could enable something like this. What do you think @ZPhilo? hub = PrimeHub()
hub.buttons.set_keyboard_interrupt(False)
# Now you can read the Button.CENTER too like the others!
# But of course now you have to take care of stopping yourself, or use a long press to shut down entirely.
hub.buttons.set_keyboard_interrupt(True)
# Now it works as usual again. Until now, we had something more complicated in mind (e.g. a double click) that stopped us from doing it so far, but this would be quite simple. For now, this would mean that the stop button in Pybricks Code would not work either, but we're fixing that in other ways. |
On the one hand, I would rather not add anything to keep things super simple. On the other hand, it would be cool if it took a button (or |
The simple scheme as proposed by Laurens seems fine to me. I was indeed a bit worried by the potential problem of lack of stop, but if a long press allows to take back control anyway, it's fine! |
We could put this functionality in ‘’pybricks.tools.enable_keyboard_interrupt()’’ to keep the button interface simple. Or better yet, check which micropython module already has this function and enable that. |
Guess what, it is already enabled 😄 from pybricks.tools import wait
from micropython import kbd_intr
kbd_intr(-1)
print("Can't cancel program in the next 5 seconds!")
wait(5000)
print("Now you can stop again")
kbd_intr(3)
wait(5000) So we just need to make sure we return |
@JanderII is probably interested in this as well. Would this suit your application? |
Thank you! I think now you just need to go to your branch and click on the pull request button. |
You're right, thanks! It would be great if you want to to change that also! |
Done for both (hopefully right ;) ) |
This has been added so we can close it. Thanks @ZPhilo! |
Describe the issue
On prime/inventor hub, Button.CENTER is listed, but pressing it aborts the program
Suggested improvement
Link to a program snippet that allows usage of Button.CENTER in custom user interface.
The text was updated successfully, but these errors were encountered: