Skip to content
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

[Feature] Ideas to support user configurable menu on Spike Prime Hub #1064

Closed
laurensvalk opened this issue May 8, 2023 · 4 comments
Closed
Labels
enhancement New feature or request hub: primehub/inventorhub Issues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub

Comments

@laurensvalk
Copy link
Member

laurensvalk commented May 8, 2023

Is your feature request related to a problem? Please describe.
FLL teams would like to have an easy way to have an on-screen menu.

Here are some ideas.

1. Document how to make a Python program that does this

Something like #861.

This could get especially easy if we had a basic hub_menu function as part of pybricks.tools:

from pybricks.tools import hub_menu

# Choose a letter.
selected = hub_menu("F", "D", "Z")

# Based on the selection, run a program.
if selected == "F":
    import fly_mission
elif selected == "D":
    import drive_mission
elif selected == "Z":
    import zigzag

We could also make a (separate) variant that uses colors instead of letters, so that it could work on the small hubs too.

2. Pybricks Code UI script template

Generates a script just like #1 as one part of the "Create a new file" dialog, with dropdowns like this:


[F ▼]   [   fly_mission.py    ▼  ]
[D ▼]   [   drive_mission.py  ▼  ]
[Z ▼]   [   zigzag.py         ▼  ]

Single uppercase letters like this seems practical and easy to remember at competition day too, but any other number/visual could work.

3. Like #2, but download it right away

Instead of generating a template script, it just downloads the "menu" program. Same dropdown UI as above except:

  • the button would say "download" instead of "create"
  • Not part of new file dialog. Instead opened somewhere from the Pybricks menu, e.g. here:

image

4. Firmware side solution

See #139. You select a slot on the hub, and Pybricks Code downloads it there.

It is not entirely clear how this should work since there is no file system.

image

Additional notes.

  • With option 1, 2, and 3, it is still just a program, so you need to press the start button to start it, then select a program.
  • Making it like a boot.py could solve that, but then it not clear how to exit to allow downloading a new program. And one extra click shouldn't be too bad.
@laurensvalk laurensvalk added enhancement New feature or request hub: primehub/inventorhub Issues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub labels May 8, 2023
@laurensvalk
Copy link
Member Author

laurensvalk commented May 8, 2023

I updated "option 1" with the idea of having a hub_menu function available.

This would make it the simplest of all the options, and still quite easy to use and powerful. No changes to Pybricks Code or firmware required.

This has the additional advantage that the hub does not need to be explicitly initialized, so there are no side effects prior to running the selected programs.

@MonongahelaCryptidCooperative

Here is how we did it:

https://github.com/MonongahelaCryptidCooperative/FLL/

@laurensvalk
Copy link
Member Author

Thanks for sharing!

laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Jun 28, 2023
This implements the first approach discussed in pybricks/support#1064.
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Jun 28, 2023
This implements the first approach discussed in pybricks/support#1064.
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Jun 29, 2023
This implements the first approach discussed in pybricks/support#1064.
@laurensvalk
Copy link
Member Author

We've selected option 1 for now. Other solutions may be considered in the future, but this should provide the key functionality for most use cases.

Now we just need to add documentation and/or a tutorial, see pybricks/pybricks-api#144.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hub: primehub/inventorhub Issues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub
Projects
None yet
Development

No branches or pull requests

2 participants