Is there a way to access the Bela cape's button from libpd (if its default click behaviour is disabled)?

Is there a way to access any of the Beaglebone's blue LEDs from libpd?

Is there a way to do similar with minor edits to the render.cpp?

I'd like to have a very basic interface for testing sound/status on untethered Belas---one button and one LED would be fine---but don't have time to solder something together.

Thx!

for all these things you will need a custom render.cpp.
The big picture is here: https://github.com/BelaPlatform/Bela/wiki/Puredata-and-C--

In practice you need to:

  • start from the base default render file: cp core/default_libpd_render.cpp project/yourpdproject/render.cpp
  • make your edits in there. This involves:
    • access the pins. You can use our Gpio class : the button is pin 115, the LED is pin 56. So, probably you want to create two global variables of type Gpio, you call open() in setup() and close() in cleanup(). In render() you can then safely call write() and read().
    • if you want to send a message to Pd (e.g.: when the button state changes), use libpd_float() (see here)
    • if you want to receive a message from Pd (e.g.: to set the LED), you need to handle that appropriately by adding a strcmp case in Bela_messagehook the code already in there should serve as a good starting point.

Additional notes:

  • in order to have full control over one of the USR LEDs, you need to make sure that they are not managed by Linux. This can be done from C++, calling led_set_trigger(USRNUMBER, "none") (this is declared in include/GPIOcontrol.h, or from the terminal :
    echo none > ls /sys/class/leds/beaglebone\:green\:usr3/trigger
  • a separate program is monitoring long presses (>2seconds) on the Bela button. If you want to disable that, run systemctl disable bela_button, or if you want to use this longer monitoring for your own purposes, then edit the file that is executed upon hold-press (/opt/Bela/bela_button_hold.sh).