Skip to content

Commit a9de5bf

Browse files
authored
Merge pull request #1612 from weebl2000/default-button-low
Default button polarity to active-LOW across all firmware types
2 parents 612aa66 + 0575426 commit a9de5bf

10 files changed

Lines changed: 26 additions & 9 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class T1000eBoard : public NRF52BoardDCDC {
4343
uint8_t v = digitalRead(BUTTON_PIN);
4444
if (v != btn_prev_state) {
4545
btn_prev_state = v;
46-
return (v == LOW) ? 1 : -1;
46+
return (v == USER_BTN_PRESSED) ? 1 : -1;
4747
}
4848
#endif
4949
return 0;

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>

variants/xiao_nrf52/XiaoNrf52Board.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <Arduino.h>
55
#include <helpers/NRF52Board.h>
66

7+
#ifndef USER_BTN_PRESSED
8+
#define USER_BTN_PRESSED LOW
9+
#endif
10+
711
#ifdef XIAO_NRF52
812

913
class XiaoNrf52Board : public NRF52BoardDCDC {
@@ -35,7 +39,7 @@ class XiaoNrf52Board : public NRF52BoardDCDC {
3539
// set led on and wait for button release before poweroff
3640
digitalWrite(PIN_LED, LOW);
3741
#ifdef PIN_USER_BTN
38-
while(digitalRead(PIN_USER_BTN) == LOW);
42+
while(digitalRead(PIN_USER_BTN) == USER_BTN_PRESSED);
3943
#endif
4044
digitalWrite(LED_GREEN, HIGH);
4145
digitalWrite(LED_BLUE, HIGH);

0 commit comments

Comments
 (0)