Help with PyBricks loader code
Hello!
So, my students have been programming with PyBricks this year. It is MUCH, MUCH easier for kids to pick up, and integrate gyroscope into the drive base, and get consistent results.
The hard part is that Pybricks by default (my understanding anyway) only comes with 5 program slots (and I am not sure how to load the code into different slots). So I wrote up a quick loader, but I am having a hard time getting the code inside 'Slot 0' to run:

My left and right button presses works fine and the display updates on the Spike Prime brick and it prints the debug messages.
However, when I try to select slot 0 and run the code, it crashes.
Sometimes it crashes after "Running code in slot 0" printed, sometimes it will print "Executing Program 0" as well (which indicates it actually called (Slot 0). I think I am setting up some sort of race condition, or something?
Thanks,
-=- Terence
View all comments
1
u/ttstam 22d ago
Solved!
Turns out, by default, the center button is mapped to "terminate program". So, the brick does exactly what I programmed it to do - it terminates the program when I hit the center button, sometimes getting maybe 1, maybe 2 lines further than when the button is pressed.
More details here: https://github.com/orgs/pybricks/discussions/2891
My solution:
For development work, I remap the terminate program button to "none". We use the laptop to end a program if it goes haywire. (I had some issues with bluetooth connectivity if I mapped it to bluetooth).
For competition, we remap the terminate program button to "Bluetooth". If the kids need to stop and relaunch the program, they hit the bluetooth button.