Skip to content

Commit

Permalink
chore(examples): use USER_BTN if defined
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Jan 9, 2023
1 parent 40dd5bd commit 3a11616
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 27 deletions.
16 changes: 6 additions & 10 deletions examples/Central/LedControl/LedControl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

#include <STM32duinoBLE.h>

#ifdef USER_BTN
const int buttonPin = USER_BTN; // set buttonPin to on-board user button
#else
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
#endif

#if defined(ARDUINO_STEVAL_MKBOXPRO)
/* STEVAL-MKBOXPRO */
SPIClass SpiHCI(PA7, PA6, PA5);
Expand All @@ -24,7 +30,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand All @@ -33,7 +38,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000,
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PG1; // set buttonPin to digital pin PG1
#elif defined(ARDUINO_B_L475E_IOT01A) || defined(ARDUINO_B_L4S5I_IOT01A)
/* B-L475E-IOT01A1 or B_L4S5I_IOT01A */
SPIClass SpiHCI(PC12, PC11, PC10);
Expand All @@ -42,14 +46,12 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000,
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK)
HCISharedMemTransportClass HCISharedMemTransport;
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISharedMemTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC4; // set buttonPin to digital pin PC4
#else
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
Expand All @@ -58,47 +60,41 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield BNRG2A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield BNRG2A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
#endif
// variables for button
Expand Down
1 change: 0 additions & 1 deletion examples/Central/Scan/Scan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand Down
1 change: 0 additions & 1 deletion examples/Central/ScanCallback/ScanCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand Down
3 changes: 1 addition & 2 deletions examples/Central/SensorTagButton/SensorTagButton.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand Down Expand Up @@ -216,7 +215,7 @@ void monitorSensorTagButtons(BLEDevice peripheral) {
if (simpleKeyCharacteristic.valueUpdated()) {
// yes, get the value, characteristic is 1 byte so use byte value
byte value = 0;

simpleKeyCharacteristic.readValue(value);

if (value & 0x01) {
Expand Down
16 changes: 6 additions & 10 deletions examples/Peripheral/ButtonLED/ButtonLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

#include <STM32duinoBLE.h>

#ifdef USER_BTN
const int buttonPin = USER_BTN; // set buttonPin to on-board user button
#else
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
#endif

#if defined(ARDUINO_STEVAL_MKBOXPRO)
/* STEVAL-MKBOXPRO */
SPIClass SpiHCI(PA7, PA6, PA5);
Expand All @@ -25,7 +31,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand All @@ -34,7 +39,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000,
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PG1; // set buttonPin to digital pin PG1
#elif defined(ARDUINO_B_L475E_IOT01A) || defined(ARDUINO_B_L4S5I_IOT01A)
/* B-L475E-IOT01A1 or B_L4S5I_IOT01A */
SPIClass SpiHCI(PC12, PC11, PC10);
Expand All @@ -43,14 +47,12 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000,
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK)
HCISharedMemTransportClass HCISharedMemTransport;
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISharedMemTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC4; // set buttonPin to digital pin PC4
#else
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
Expand All @@ -59,47 +61,41 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield BNRG2A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield BNRG2A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
#endif
const int ledPin = LED_BUILTIN; // set ledPin to on-board LED
Expand Down
3 changes: 1 addition & 2 deletions examples/Peripheral/CallbackLED/CallbackLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand Down Expand Up @@ -103,7 +102,7 @@ const int ledPin = LED_BUILTIN; // pin to use for the LED
void setup() {
Serial.begin(115200);
while (!Serial);

pinMode(ledPin, OUTPUT); // use the LED pin as an output

// begin initialization
Expand Down
1 change: 0 additions & 1 deletion examples/Peripheral/LED/LED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000
BLELocalDevice BLEObj(&HCISpiTransport);
BLELocalDevice& BLE = BLEObj;
#endif
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#elif defined(ARDUINO_STEVAL_MKSBOX1V1)
/* STEVAL-MKSBOX1V1 */
SPIClass SpiHCI(PC3, PD3, PD1);
Expand Down

0 comments on commit 3a11616

Please sign in to comment.