Merge pull request #1612 from weebl2000/default-button-low
Default button polarity to active-LOW across all firmware types
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/CommonCLI.h>
|
#include <helpers/CommonCLI.h>
|
||||||
|
|
||||||
|
#ifndef USER_BTN_PRESSED
|
||||||
|
#define USER_BTN_PRESSED LOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
||||||
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ void UITask::loop() {
|
|||||||
if (millis() >= _next_read) {
|
if (millis() >= _next_read) {
|
||||||
int btnState = digitalRead(PIN_USER_BTN);
|
int btnState = digitalRead(PIN_USER_BTN);
|
||||||
if (btnState != _prevBtnState) {
|
if (btnState != _prevBtnState) {
|
||||||
if (btnState == LOW) { // pressed?
|
if (btnState == USER_BTN_PRESSED) { // pressed?
|
||||||
if (_display->isOn()) {
|
if (_display->isOn()) {
|
||||||
// TODO: any action ?
|
// TODO: any action ?
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/CommonCLI.h>
|
#include <helpers/CommonCLI.h>
|
||||||
|
|
||||||
|
#ifndef USER_BTN_PRESSED
|
||||||
|
#define USER_BTN_PRESSED LOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
||||||
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ void UITask::loop() {
|
|||||||
if (millis() >= _next_read) {
|
if (millis() >= _next_read) {
|
||||||
int btnState = digitalRead(PIN_USER_BTN);
|
int btnState = digitalRead(PIN_USER_BTN);
|
||||||
if (btnState != _prevBtnState) {
|
if (btnState != _prevBtnState) {
|
||||||
if (btnState == LOW) { // pressed?
|
if (btnState == USER_BTN_PRESSED) { // pressed?
|
||||||
if (_display->isOn()) {
|
if (_display->isOn()) {
|
||||||
// TODO: any action ?
|
// TODO: any action ?
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/CommonCLI.h>
|
#include <helpers/CommonCLI.h>
|
||||||
|
|
||||||
|
#ifndef USER_BTN_PRESSED
|
||||||
|
#define USER_BTN_PRESSED LOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
||||||
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ void UITask::loop() {
|
|||||||
if (millis() >= _next_read) {
|
if (millis() >= _next_read) {
|
||||||
int btnState = digitalRead(PIN_USER_BTN);
|
int btnState = digitalRead(PIN_USER_BTN);
|
||||||
if (btnState != _prevBtnState) {
|
if (btnState != _prevBtnState) {
|
||||||
if (btnState == LOW) { // pressed?
|
if (btnState == USER_BTN_PRESSED) { // pressed?
|
||||||
if (_display->isOn()) {
|
if (_display->isOn()) {
|
||||||
// TODO: any action ?
|
// TODO: any action ?
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#ifndef USER_BTN_PRESSED
|
||||||
|
#define USER_BTN_PRESSED LOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ESP_PLATFORM)
|
#if defined(ESP_PLATFORM)
|
||||||
|
|
||||||
#include <rom/rtc.h>
|
#include <rom/rtc.h>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
digitalWrite(LED_PIN, LOW);
|
digitalWrite(LED_PIN, LOW);
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH);
|
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||||
#endif
|
#endif
|
||||||
sd_power_system_off();
|
sd_power_system_off();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ build_flags = ${nrf52840_me25ls01.build_flags}
|
|||||||
-I variants/minewsemi_me25ls01
|
-I variants/minewsemi_me25ls01
|
||||||
-D me25ls01
|
-D me25ls01
|
||||||
-D PIN_USER_BTN=27
|
-D PIN_USER_BTN=27
|
||||||
-D USER_BTN_PRESSED=HIGH
|
|
||||||
-D PIN_STATUS_LED=39
|
-D PIN_STATUS_LED=39
|
||||||
-D P_LORA_TX_LED=22
|
-D P_LORA_TX_LED=22
|
||||||
-D RADIO_CLASS=CustomLR1110
|
-D RADIO_CLASS=CustomLR1110
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
uint8_t v = digitalRead(BUTTON_PIN);
|
uint8_t v = digitalRead(BUTTON_PIN);
|
||||||
if (v != btn_prev_state) {
|
if (v != btn_prev_state) {
|
||||||
btn_prev_state = v;
|
btn_prev_state = v;
|
||||||
return (v == LOW) ? 1 : -1;
|
return (v == USER_BTN_PRESSED) ? 1 : -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ build_flags = ${nrf52_base.build_flags}
|
|||||||
-I src/helpers/ui
|
-I src/helpers/ui
|
||||||
-D THINKNODE_M3
|
-D THINKNODE_M3
|
||||||
-D PIN_USER_BTN=12
|
-D PIN_USER_BTN=12
|
||||||
-D USER_BTN_PRESSED=LOW
|
|
||||||
-D PIN_STATUS_LED=35
|
-D PIN_STATUS_LED=35
|
||||||
-D RADIO_CLASS=CustomLR1110
|
-D RADIO_CLASS=CustomLR1110
|
||||||
-D WRAPPER_CLASS=CustomLR1110Wrapper
|
-D WRAPPER_CLASS=CustomLR1110Wrapper
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ build_flags = ${stm32_base.build_flags}
|
|||||||
-D RX_BOOSTED_GAIN=true
|
-D RX_BOOSTED_GAIN=true
|
||||||
-D P_LORA_TX_LED=LED_RED
|
-D P_LORA_TX_LED=LED_RED
|
||||||
-D PIN_USER_BTN=USER_BTN
|
-D PIN_USER_BTN=USER_BTN
|
||||||
-D USER_BTN_PRESSED=LOW
|
|
||||||
-I variants/wio-e5-mini
|
-I variants/wio-e5-mini
|
||||||
build_src_filter = ${stm32_base.build_src_filter}
|
build_src_filter = ${stm32_base.build_src_filter}
|
||||||
+<../variants/wio-e5-mini>
|
+<../variants/wio-e5-mini>
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/NRF52Board.h>
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
|
#ifndef USER_BTN_PRESSED
|
||||||
|
#define USER_BTN_PRESSED LOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XIAO_NRF52
|
#ifdef XIAO_NRF52
|
||||||
|
|
||||||
class XiaoNrf52Board : public NRF52BoardDCDC {
|
class XiaoNrf52Board : public NRF52BoardDCDC {
|
||||||
@@ -35,7 +39,7 @@ public:
|
|||||||
// set led on and wait for button release before poweroff
|
// set led on and wait for button release before poweroff
|
||||||
digitalWrite(PIN_LED, LOW);
|
digitalWrite(PIN_LED, LOW);
|
||||||
#ifdef PIN_USER_BTN
|
#ifdef PIN_USER_BTN
|
||||||
while(digitalRead(PIN_USER_BTN) == LOW);
|
while(digitalRead(PIN_USER_BTN) == USER_BTN_PRESSED);
|
||||||
#endif
|
#endif
|
||||||
digitalWrite(LED_GREEN, HIGH);
|
digitalWrite(LED_GREEN, HIGH);
|
||||||
digitalWrite(LED_BLUE, HIGH);
|
digitalWrite(LED_BLUE, HIGH);
|
||||||
|
|||||||
Reference in New Issue
Block a user