Skip to content

Commit 0a13ac7

Browse files
committed
Default button polarity to active-LOW across all firmware types
Nearly all LoRa boards use a boot button that pulls to ground when pressed.
1 parent fb726e4 commit 0a13ac7

11 files changed

Lines changed: 27 additions & 11 deletions

File tree

examples/simple_repeater/UITask.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include <Arduino.h>
33
#include <helpers/CommonCLI.h>
44

5+
#ifndef USER_BTN_PRESSED
6+
#define USER_BTN_PRESSED LOW
7+
#endif
8+
59
#define AUTO_OFF_MILLIS 20000 // 20 seconds
610
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
711

@@ -85,7 +89,7 @@ void UITask::loop() {
8589
if (millis() >= _next_read) {
8690
int btnState = digitalRead(PIN_USER_BTN);
8791
if (btnState != _prevBtnState) {
88-
if (btnState == LOW) { // pressed?
92+
if (btnState == USER_BTN_PRESSED) { // pressed?
8993
if (_display->isOn()) {
9094
// TODO: any action ?
9195
} else {

examples/simple_room_server/UITask.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include <Arduino.h>
33
#include <helpers/CommonCLI.h>
44

5+
#ifndef USER_BTN_PRESSED
6+
#define USER_BTN_PRESSED LOW
7+
#endif
8+
59
#define AUTO_OFF_MILLIS 20000 // 20 seconds
610
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
711

@@ -85,7 +89,7 @@ void UITask::loop() {
8589
if (millis() >= _next_read) {
8690
int btnState = digitalRead(PIN_USER_BTN);
8791
if (btnState != _prevBtnState) {
88-
if (btnState == LOW) { // pressed?
92+
if (btnState == USER_BTN_PRESSED) { // pressed?
8993
if (_display->isOn()) {
9094
// TODO: any action ?
9195
} else {

examples/simple_sensor/UITask.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include <Arduino.h>
33
#include <helpers/CommonCLI.h>
44

5+
#ifndef USER_BTN_PRESSED
6+
#define USER_BTN_PRESSED LOW
7+
#endif
8+
59
#define AUTO_OFF_MILLIS 20000 // 20 seconds
610
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
711

@@ -85,7 +89,7 @@ void UITask::loop() {
8589
if (millis() >= _next_read) {
8690
int btnState = digitalRead(PIN_USER_BTN);
8791
if (btnState != _prevBtnState) {
88-
if (btnState == LOW) { // pressed?
92+
if (btnState == USER_BTN_PRESSED) { // pressed?
8993
if (_display->isOn()) {
9094
// TODO: any action ?
9195
} else {

src/helpers/ESP32Board.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#include <MeshCore.h>
44
#include <Arduino.h>
55

6+
#ifndef USER_BTN_PRESSED
7+
#define USER_BTN_PRESSED LOW
8+
#endif
9+
610
#if defined(ESP_PLATFORM)
711

812
#include <rom/rtc.h>

variants/minewsemi_me25ls01/MinewsemiME25LS01Board.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class MinewsemiME25LS01Board : public NRF52BoardDCDC {
6363
digitalWrite(LED_PIN, LOW);
6464
#endif
6565
#ifdef BUTTON_PIN
66-
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH);
66+
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
6767
#endif
6868
sd_power_system_off();
6969
}

variants/minewsemi_me25ls01/platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ build_flags = ${nrf52840_me25ls01.build_flags}
2121
-I variants/minewsemi_me25ls01
2222
-D me25ls01
2323
-D PIN_USER_BTN=27
24-
-D USER_BTN_PRESSED=HIGH
2524
-D PIN_STATUS_LED=39
2625
-D P_LORA_TX_LED=22
2726
-D RADIO_CLASS=CustomLR1110

variants/t1000-e/T1000eBoard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class T1000eBoard : public NRF52BoardDCDC {
7878
digitalWrite(LED_PIN, HIGH);
7979
#endif
8080
#ifdef BUTTON_PIN
81-
while(digitalRead(BUTTON_PIN));
81+
while(digitalRead(BUTTON_PIN) == LOW);
8282
#endif
8383
#ifdef LED_PIN
8484
digitalWrite(LED_PIN, LOW);
8585
#endif
8686

8787
#ifdef BUTTON_PIN
88-
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
88+
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
8989
#endif
9090

9191
sd_power_system_off();

variants/t1000-e/platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ build_flags = ${nrf52_base.build_flags}
1010
-I src/helpers/ui
1111
-D T1000_E
1212
-D PIN_USER_BTN=6
13-
-D USER_BTN_PRESSED=HIGH
1413
-D PIN_STATUS_LED=24
1514
-D RADIO_CLASS=CustomLR1110
1615
-D WRAPPER_CLASS=CustomLR1110Wrapper

variants/thinknode_m3/platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ build_flags = ${nrf52_base.build_flags}
1010
-I src/helpers/ui
1111
-D THINKNODE_M3
1212
-D PIN_USER_BTN=12
13-
-D USER_BTN_PRESSED=LOW
1413
-D PIN_STATUS_LED=35
1514
-D RADIO_CLASS=CustomLR1110
1615
-D WRAPPER_CLASS=CustomLR1110Wrapper

variants/wio-e5-mini/platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ build_flags = ${stm32_base.build_flags}
99
-D RX_BOOSTED_GAIN=true
1010
-D P_LORA_TX_LED=LED_RED
1111
-D PIN_USER_BTN=USER_BTN
12-
-D USER_BTN_PRESSED=LOW
1312
-I variants/wio-e5-mini
1413
build_src_filter = ${stm32_base.build_src_filter}
1514
+<../variants/wio-e5-mini>

0 commit comments

Comments
 (0)