Actually, you could remap SWITCH_1
(GPIO 60) to be monitored by the Bela program so that it kills it immediately when it is pressed:
diff --git a/core/PRU.cpp b/core/PRU.cpp
index f15f4f0..fabe166 100644
--- a/core/PRU.cpp
+++ b/core/PRU.cpp
@@ -234,7 +234,7 @@ short int digitalPins[NUM_DIGITALS] = {
#define USERLED3_GPIO_BASE GPIO1_ADDRESS // GPIO1(24) is user LED 3
#define USERLED3_PIN_MASK (1 << 24)
-#define BELA_CAPE_BUTTON_PIN 115
+#define BELA_CAPE_BUTTON_PIN 60
const unsigned int PRU::kPruGPIODACSyncPin = 5; // GPIO0(5); P9-17
const unsigned int PRU::kPruGPIOADCSyncPin = 48; // GPIO1(16); P9-15
This check is run from within the audio thread, so it will always work, even in cases of extremely high CPU load, where the systemd
method can potentially have some problems. However, as it is it may be easily triggered by mistake (e.g.: upon a short, brief press of the button). You can increase the timeout with:
diff --git a/core/PRU.cpp b/core/PRU.cpp
index f15f4f0..235bc45 100644
--- a/core/PRU.cpp
+++ b/core/PRU.cpp
@@ -831,7 +831,7 @@ void PRU::loop(void *userData, void(*render)(BelaContext*, void*), bool highPerf
if(belaCapeButton.enabled()){
static int belaCapeButtonCount = 0;
if(belaCapeButton.read() == 0){
- if(++belaCapeButtonCount > 10){
+ if(++belaCapeButtonCount > 1000){
printf("Button pressed, quitting\n");
gShouldStop = true;
}
or even make it block-size independent with
(++belaCapeButtonCount > durationInSeconds * context->audioSampleRate / context->audioFrames)
It would be nice to add command-line options for both the above.
Also, to unlock some extra % of CPU for the audio, once you have set up the button monitoring, you can try --high-performance-mode
π.