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

pybricks.tools: Add hub_menu function. #178

Merged
merged 1 commit into from
Jun 29, 2023
Merged

pybricks.tools: Add hub_menu function. #178

merged 1 commit into from
Jun 29, 2023

Conversation

laurensvalk
Copy link
Member

This implements the first approach discussed in pybricks/support#1064.

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

This is really only applicable to systems with the light matrix, so maybe it belongs there? (Only that doesn't have buttons, so maybe not).

@coveralls
Copy link

coveralls commented Jun 28, 2023

Coverage Status

coverage: 54.837%. remained the same when pulling ee5502f on hub-menu into b5f40d8 on master.

pybricks/tools/pb_module_tools.c Show resolved Hide resolved
pybricks/tools/pb_module_tools.c Outdated Show resolved Hide resolved
pybricks/tools/pb_module_tools.c Show resolved Hide resolved
This implements the first approach discussed in pybricks/support#1064.
} else {
pbsys_program_stop_set_buttons(stop_button);
nlr_jump(nlr.ret_val);
return mp_const_none;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not reachable. We can use MP_UNREACHABLE instead if the compiler doesn't respect the noreturn attribute on nlr_jump.

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.

3 participants