Skip to content

Commit 3a11616

Browse files
committed
chore(examples): use USER_BTN if defined
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 40dd5bd commit 3a11616

File tree

7 files changed

+14
-27
lines changed

7 files changed

+14
-27
lines changed

examples/Central/LedControl/LedControl.ino

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
#include <STM32duinoBLE.h>
1818

19+
#ifdef USER_BTN
20+
const int buttonPin = USER_BTN; // set buttonPin to on-board user button
21+
#else
22+
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
23+
#endif
24+
1925
#if defined(ARDUINO_STEVAL_MKBOXPRO)
2026
/* STEVAL-MKBOXPRO */
2127
SPIClass SpiHCI(PA7, PA6, PA5);
@@ -24,7 +30,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2430
BLELocalDevice BLEObj(&HCISpiTransport);
2531
BLELocalDevice& BLE = BLEObj;
2632
#endif
27-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2833
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
2934
/* STEVAL-MKSBOX1V1 */
3035
SPIClass SpiHCI(PC3, PD3, PD1);
@@ -33,7 +38,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000,
3338
BLELocalDevice BLEObj(&HCISpiTransport);
3439
BLELocalDevice& BLE = BLEObj;
3540
#endif
36-
const int buttonPin = PG1; // set buttonPin to digital pin PG1
3741
#elif defined(ARDUINO_B_L475E_IOT01A) || defined(ARDUINO_B_L4S5I_IOT01A)
3842
/* B-L475E-IOT01A1 or B_L4S5I_IOT01A */
3943
SPIClass SpiHCI(PC12, PC11, PC10);
@@ -42,14 +46,12 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000,
4246
BLELocalDevice BLEObj(&HCISpiTransport);
4347
BLELocalDevice& BLE = BLEObj;
4448
#endif
45-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
4649
#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK)
4750
HCISharedMemTransportClass HCISharedMemTransport;
4851
#if !defined(FAKE_BLELOCALDEVICE)
4952
BLELocalDevice BLEObj(&HCISharedMemTransport);
5053
BLELocalDevice& BLE = BLEObj;
5154
#endif
52-
const int buttonPin = PC4; // set buttonPin to digital pin PC4
5355
#else
5456
/* Shield IDB05A2 with SPI clock on D3 */
5557
SPIClass SpiHCI(D11, D12, D3);
@@ -58,47 +60,41 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP
5860
BLELocalDevice BLEObj(&HCISpiTransport);
5961
BLELocalDevice& BLE = BLEObj;
6062
#endif
61-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
6263
/* Shield IDB05A2 with SPI clock on D13 */
6364
/*#define SpiHCI SPI
6465
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
6566
#if !defined(FAKE_BLELOCALDEVICE)
6667
BLELocalDevice BLEObj(&HCISpiTransport);
6768
BLELocalDevice& BLE = BLEObj;
6869
#endif
69-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
7070
/* Shield IDB05A1 with SPI clock on D3 */
7171
/*SPIClass SpiHCI(D11, D12, D3);
7272
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
7373
#if !defined(FAKE_BLELOCALDEVICE)
7474
BLELocalDevice BLEObj(&HCISpiTransport);
7575
BLELocalDevice& BLE = BLEObj;
7676
#endif
77-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
7877
/* Shield IDB05A1 with SPI clock on D13 */
7978
/*#define SpiHCI SPI
8079
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
8180
#if !defined(FAKE_BLELOCALDEVICE)
8281
BLELocalDevice BLEObj(&HCISpiTransport);
8382
BLELocalDevice& BLE = BLEObj;
8483
#endif
85-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
8684
/* Shield BNRG2A1 with SPI clock on D3 */
8785
/*SPIClass SpiHCI(D11, D12, D3);
8886
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
8987
#if !defined(FAKE_BLELOCALDEVICE)
9088
BLELocalDevice BLEObj(&HCISpiTransport);
9189
BLELocalDevice& BLE = BLEObj;
9290
#endif
93-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
9491
/* Shield BNRG2A1 with SPI clock on D13 */
9592
/*#define SpiHCI SPI
9693
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
9794
#if !defined(FAKE_BLELOCALDEVICE)
9895
BLELocalDevice BLEObj(&HCISpiTransport);
9996
BLELocalDevice& BLE = BLEObj;
10097
#endif
101-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
10298
#endif
10399
104100
// variables for button

examples/Central/Scan/Scan.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2020
BLELocalDevice BLEObj(&HCISpiTransport);
2121
BLELocalDevice& BLE = BLEObj;
2222
#endif
23-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2423
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
2524
/* STEVAL-MKSBOX1V1 */
2625
SPIClass SpiHCI(PC3, PD3, PD1);

examples/Central/ScanCallback/ScanCallback.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2222
BLELocalDevice BLEObj(&HCISpiTransport);
2323
BLELocalDevice& BLE = BLEObj;
2424
#endif
25-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2625
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
2726
/* STEVAL-MKSBOX1V1 */
2827
SPIClass SpiHCI(PC3, PD3, PD1);

examples/Central/SensorTagButton/SensorTagButton.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2424
BLELocalDevice BLEObj(&HCISpiTransport);
2525
BLELocalDevice& BLE = BLEObj;
2626
#endif
27-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2827
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
2928
/* STEVAL-MKSBOX1V1 */
3029
SPIClass SpiHCI(PC3, PD3, PD1);
@@ -216,7 +215,7 @@ void monitorSensorTagButtons(BLEDevice peripheral) {
216215
if (simpleKeyCharacteristic.valueUpdated()) {
217216
// yes, get the value, characteristic is 1 byte so use byte value
218217
byte value = 0;
219-
218+
220219
simpleKeyCharacteristic.readValue(value);
221220

222221
if (value & 0x01) {

examples/Peripheral/ButtonLED/ButtonLED.ino

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
#include <STM32duinoBLE.h>
1919

20+
#ifdef USER_BTN
21+
const int buttonPin = USER_BTN; // set buttonPin to on-board user button
22+
#else
23+
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
24+
#endif
25+
2026
#if defined(ARDUINO_STEVAL_MKBOXPRO)
2127
/* STEVAL-MKBOXPRO */
2228
SPIClass SpiHCI(PA7, PA6, PA5);
@@ -25,7 +31,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2531
BLELocalDevice BLEObj(&HCISpiTransport);
2632
BLELocalDevice& BLE = BLEObj;
2733
#endif
28-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2934
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
3035
/* STEVAL-MKSBOX1V1 */
3136
SPIClass SpiHCI(PC3, PD3, PD1);
@@ -34,7 +39,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000,
3439
BLELocalDevice BLEObj(&HCISpiTransport);
3540
BLELocalDevice& BLE = BLEObj;
3641
#endif
37-
const int buttonPin = PG1; // set buttonPin to digital pin PG1
3842
#elif defined(ARDUINO_B_L475E_IOT01A) || defined(ARDUINO_B_L4S5I_IOT01A)
3943
/* B-L475E-IOT01A1 or B_L4S5I_IOT01A */
4044
SPIClass SpiHCI(PC12, PC11, PC10);
@@ -43,14 +47,12 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000,
4347
BLELocalDevice BLEObj(&HCISpiTransport);
4448
BLELocalDevice& BLE = BLEObj;
4549
#endif
46-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
4750
#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK)
4851
HCISharedMemTransportClass HCISharedMemTransport;
4952
#if !defined(FAKE_BLELOCALDEVICE)
5053
BLELocalDevice BLEObj(&HCISharedMemTransport);
5154
BLELocalDevice& BLE = BLEObj;
5255
#endif
53-
const int buttonPin = PC4; // set buttonPin to digital pin PC4
5456
#else
5557
/* Shield IDB05A2 with SPI clock on D3 */
5658
SPIClass SpiHCI(D11, D12, D3);
@@ -59,47 +61,41 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP
5961
BLELocalDevice BLEObj(&HCISpiTransport);
6062
BLELocalDevice& BLE = BLEObj;
6163
#endif
62-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
6364
/* Shield IDB05A2 with SPI clock on D13 */
6465
/*#define SpiHCI SPI
6566
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
6667
#if !defined(FAKE_BLELOCALDEVICE)
6768
BLELocalDevice BLEObj(&HCISpiTransport);
6869
BLELocalDevice& BLE = BLEObj;
6970
#endif
70-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
7171
/* Shield IDB05A1 with SPI clock on D3 */
7272
/*SPIClass SpiHCI(D11, D12, D3);
7373
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
7474
#if !defined(FAKE_BLELOCALDEVICE)
7575
BLELocalDevice BLEObj(&HCISpiTransport);
7676
BLELocalDevice& BLE = BLEObj;
7777
#endif
78-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
7978
/* Shield IDB05A1 with SPI clock on D13 */
8079
/*#define SpiHCI SPI
8180
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
8281
#if !defined(FAKE_BLELOCALDEVICE)
8382
BLELocalDevice BLEObj(&HCISpiTransport);
8483
BLELocalDevice& BLE = BLEObj;
8584
#endif
86-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
8785
/* Shield BNRG2A1 with SPI clock on D3 */
8886
/*SPIClass SpiHCI(D11, D12, D3);
8987
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
9088
#if !defined(FAKE_BLELOCALDEVICE)
9189
BLELocalDevice BLEObj(&HCISpiTransport);
9290
BLELocalDevice& BLE = BLEObj;
9391
#endif
94-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
9592
/* Shield BNRG2A1 with SPI clock on D13 */
9693
/*#define SpiHCI SPI
9794
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
9895
#if !defined(FAKE_BLELOCALDEVICE)
9996
BLELocalDevice BLEObj(&HCISpiTransport);
10097
BLELocalDevice& BLE = BLEObj;
10198
#endif
102-
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
10399
#endif
104100
105101
const int ledPin = LED_BUILTIN; // set ledPin to on-board LED

examples/Peripheral/CallbackLED/CallbackLED.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2525
BLELocalDevice BLEObj(&HCISpiTransport);
2626
BLELocalDevice& BLE = BLEObj;
2727
#endif
28-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2928
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
3029
/* STEVAL-MKSBOX1V1 */
3130
SPIClass SpiHCI(PC3, PD3, PD1);
@@ -103,7 +102,7 @@ const int ledPin = LED_BUILTIN; // pin to use for the LED
103102
void setup() {
104103
Serial.begin(115200);
105104
while (!Serial);
106-
105+
107106
pinMode(ledPin, OUTPUT); // use the LED pin as an output
108107

109108
// begin initialization

examples/Peripheral/LED/LED.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
2323
BLELocalDevice BLEObj(&HCISpiTransport);
2424
BLELocalDevice& BLE = BLEObj;
2525
#endif
26-
const int buttonPin = PC13; // set buttonPin to digital pin PC13
2726
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
2827
/* STEVAL-MKSBOX1V1 */
2928
SPIClass SpiHCI(PC3, PD3, PD1);

0 commit comments

Comments
 (0)