- Edited
not sure what the difference between these two is:
- restart Bela
- restart the BBB & Bela
these should be doable:
- restart a patch
- •loop• through patches
At the moment there are two different behaviours implemented for patches running at boot:
1- single patch in a loop
2- multiple patches in a loop
In both cases the only control that is exposed to the user is Button. By pressing the button in case 1- the patch restarts, by pressing it in case 2-, it moves on to the next patch.
Another thing can be achieved with the button:
3- when hold-pressing the Button, you turn off Bela.
Now, on Pepper none of the front panel buttons are connected to the Button on the cape. However, the behaviour associated with the Button can be assigned to a different digital pin, so you could repurpose one of the buttons on the Pepper front panel to behave as the Button. This requires a few steps (assuming a recent Bela core code).
- identify the GPIO number for the pin you would like to use. This is done cross-checking the Pepper schematic, the BeagleBone pinouts in here and here and the Pepper pins from here. This gives the following numbers (if I am not wrong):
Button | GPIO_NUMBER | BELA_PD
0 | 89 | 26
1 | 87 | 25
2 | 88 | 24
3 | 86 | 23
- create a file on the board: /root/.bela/belaconfig
. In this file place the following (replacing GPIO_NUMBER
with the number above:
CL=--stop-button-pin GPIO_NUMBER
This should make it so that when you press that button the current program stops. This by itself is enough to implement behaviours 1 and 2 above.
- To move the hold -press behaviour to the same pin, you have to edit /lib/systemd/system/bela_button.service
. There, at this line
ExecStart=/usr/bin/stdbuf -oL -eL /usr/local/bin/bela-cape-btn --pin 115 --hold /opt/Bela/bela_button_hold.sh --delay 20 --monitor-click 0
you should change 115
to GPIO_NUMBER
. If you want to change the action triggered by hold-pressing the button, you can either place an executable file at /opt/Bela/local/bela_button_hold.sh
or replace /opt/Bela/bela_button_hold.sh
above with a path to your executable.
I think the above should work, though you may have to modify initialise_digitals.pd
in your projects to avoid affecting the corresponding digital input: remove the corresponding in BELA_PD
from the "Initialise the buttons" section, also avoid using the corresponding signals from the [buttons]
abstraction.
eventually even back and forth?
This could be fairly complicated. You may need two instances of bela-cape-btn
running and somehow share state, or even roll your own version of it which monitors two pins and keeps track of what is the prev/next patch and start it upon button press.