Skip to content

Commit c76d337

Browse files
committed
variants: XIAO NRF52: Enable user button
The Xiao nRF52840 combined with the Wio-SX1262 is often used for cheap and compact DIY companion nodes. The Wio actually has an onboard pushbutton that can be used as user button. Enable support for the button. Signed-off-by: Frieder Schrempf <[email protected]>
1 parent 11f119a commit c76d337

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

variants/xiao_nrf52/XiaoNrf52Board.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ void XiaoNrf52Board::begin() {
2929
pinMode(VBAT_ENABLE, OUTPUT);
3030
digitalWrite(VBAT_ENABLE, HIGH);
3131

32+
#ifdef PIN_USER_BTN
33+
pinMode(PIN_USER_BTN, INPUT);
34+
#endif
35+
3236
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
3337
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
3438
#endif

variants/xiao_nrf52/platformio.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ build_flags = ${nrf52_base.build_flags}
2626
-D SX126X_RX_BOOSTED_GAIN=1
2727
-D PIN_WIRE_SCL=D6
2828
-D PIN_WIRE_SDA=D7
29+
-D PIN_USER_BTN=PIN_BUTTON1
30+
-D DISPLAY_CLASS=NullDisplayDriver
2931
build_src_filter = ${nrf52_base.build_src_filter}
3032
+<helpers/*.cpp>
3133
+<helpers/sensors>
3234
+<../variants/xiao_nrf52>
35+
+<helpers/ui/NullDisplayDriver.cpp>
3336
debug_tool = jlink
3437
upload_protocol = nrfutil
3538
lib_deps = ${nrf52_base.lib_deps}
@@ -41,6 +44,7 @@ board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
4144
board_upload.maximum_size = 708608
4245
build_flags =
4346
${Xiao_nrf52.build_flags}
47+
-I examples/companion_radio/ui-orig
4448
-D MAX_CONTACTS=350
4549
-D MAX_GROUP_CHANNELS=40
4650
-D BLE_PIN_CODE=123456
@@ -52,6 +56,7 @@ build_flags =
5256
build_src_filter = ${Xiao_nrf52.build_src_filter}
5357
+<helpers/nrf52/SerialBLEInterface.cpp>
5458
+<../examples/companion_radio/*.cpp>
59+
+<../examples/companion_radio/ui-orig/*.cpp>
5560
lib_deps =
5661
${Xiao_nrf52.lib_deps}
5762
densaugeo/base64 @ ~1.4.0
@@ -62,6 +67,7 @@ board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
6267
board_upload.maximum_size = 708608
6368
build_flags =
6469
${Xiao_nrf52.build_flags}
70+
-I examples/companion_radio/ui-orig
6571
-D MAX_CONTACTS=350
6672
-D MAX_GROUP_CHANNELS=40
6773
-D QSPIFLASH=1
@@ -70,6 +76,7 @@ build_flags =
7076
build_src_filter = ${Xiao_nrf52.build_src_filter}
7177
+<helpers/nrf52/SerialBLEInterface.cpp>
7278
+<../examples/companion_radio/*.cpp>
79+
+<../examples/companion_radio/ui-orig/*.cpp>
7380
lib_deps =
7481
${Xiao_nrf52.lib_deps}
7582
densaugeo/base64 @ ~1.4.0

variants/xiao_nrf52/target.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "target.h"
33
#include <helpers/ArduinoHelpers.h>
44

5+
#ifdef DISPLAY_CLASS
6+
DISPLAY_CLASS display;
7+
#endif
8+
59
XiaoNrf52Board board;
610

711
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);

variants/xiao_nrf52/target.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#include <helpers/ArduinoHelpers.h>
1010
#include <helpers/sensors/EnvironmentSensorManager.h>
1111

12+
#ifdef DISPLAY_CLASS
13+
#include <helpers/ui/NullDisplayDriver.h>
14+
extern DISPLAY_CLASS display;
15+
#endif
16+
1217
extern XiaoNrf52Board board;
1318
extern WRAPPER_CLASS radio_driver;
1419
extern AutoDiscoverRTCClock rtc_clock;

variants/xiao_nrf52/variant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extern "C"
3838
#define LED_STATE_ON (1) // State when LED is litted
3939

4040
// Buttons
41-
#define PIN_BUTTON1 (PINS_COUNT)
41+
#define PIN_BUTTON1 (0)
4242

4343
// Digital PINs
4444
static const uint8_t D0 = 0 ;

0 commit comments

Comments
 (0)