From 9d8a1b3522ebca3db031d8b183f96c0f67cfac21 Mon Sep 17 00:00:00 2001 From: Erik R Norell Date: Thu, 6 Jan 2022 19:25:16 +0300 Subject: [PATCH 1/3] Feature: add disable_tx setting #1065 --- src/mesh/RadioLibInterface.cpp | 3 ++- src/mesh/generated/admin.pb.h | 4 ++-- src/mesh/generated/radioconfig.pb.h | 13 ++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 4455b971c..89b4b11bc 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -93,7 +93,8 @@ bool RadioLibInterface::canSendImmediately() /// bluetooth comms code. If the txmit queue is empty it might return an error ErrorCode RadioLibInterface::send(MeshPacket *p) { - if (disabled) { + if (disabled || radioConfig.preferences.is_lora_tx_disabled) { + DEBUG_MSG("send - lora_tx_disabled\n"); packetPool.release(p); return ERRNO_DISABLED; } diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index ebc6fc9a0..d75c2b418 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -5,8 +5,8 @@ #define PB_ADMIN_PB_H_INCLUDED #include #include "channel.pb.h" -#include "radioconfig.pb.h" #include "mesh.pb.h" +#include "radioconfig.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 529 +#define AdminMessage_size 532 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index f1ce58de1..9eb6fa875 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -155,6 +155,7 @@ typedef struct _RadioConfig_UserPreferences { uint32_t hop_limit; char mqtt_username[32]; char mqtt_password[32]; + bool is_lora_tx_disabled; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -199,9 +200,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -272,6 +273,7 @@ extern "C" { #define RadioConfig_UserPreferences_hop_limit_tag 154 #define RadioConfig_UserPreferences_mqtt_username_tag 155 #define RadioConfig_UserPreferences_mqtt_password_tag 156 +#define RadioConfig_UserPreferences_is_lora_tx_disabled_tag 157 #define RadioConfig_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -349,7 +351,8 @@ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \ X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \ X(a, STATIC, SINGULAR, UINT32, hop_limit, 154) \ X(a, STATIC, SINGULAR, STRING, mqtt_username, 155) \ -X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) +X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) \ +X(a, STATIC, SINGULAR, BOOL, is_lora_tx_disabled, 157) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -361,8 +364,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 526 -#define RadioConfig_UserPreferences_size 523 +#define RadioConfig_size 529 +#define RadioConfig_UserPreferences_size 526 #ifdef __cplusplus } /* extern "C" */ From b6eb927ad2d6c86f76cd0a0cea70086e63a261db Mon Sep 17 00:00:00 2001 From: Erik R Norell Date: Thu, 6 Jan 2022 20:00:53 +0300 Subject: [PATCH 2/3] Missed a spot to disable. --- src/mesh/RadioLibInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 89b4b11bc..67c1ad4a6 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -301,7 +301,7 @@ void RadioLibInterface::handleReceiveInterrupt() void RadioLibInterface::startSend(MeshPacket *txp) { printPacket("Starting low level send", txp); - if (disabled) { + if (disabled || radioConfig.preferences.is_lora_tx_disabled) { DEBUG_MSG("startSend is dropping tx packet because we are disabled\n"); packetPool.release(txp); } else { From 17dfb7d15225b2ccbd77e4f19da4ddebc2b428e6 Mon Sep 17 00:00:00 2001 From: Erik R Norell Date: Fri, 7 Jan 2022 09:57:29 +0300 Subject: [PATCH 3/3] Touch on T-Echo to refresh e-ink screen --- src/configuration.h | 4 ++++ src/main.cpp | 49 +++++++++++++++++++++++++++++++++++++++ variants/t-echo/variant.h | 1 + 3 files changed, 54 insertions(+) diff --git a/src/configuration.h b/src/configuration.h index 89fa106ff..57469bfd5 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -84,6 +84,10 @@ along with this program. If not, see . #define BUTTON_PIN_ALT PIN_BUTTON2 #endif +#ifdef PIN_BUTTON_TOUCH +#define BUTTON_PIN_TOUCH PIN_BUTTON_TOUCH +#endif + // FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets) #elif defined(CubeCell_BoardPlus) diff --git a/src/main.cpp b/src/main.cpp index 41d504e40..15085034d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -187,6 +187,9 @@ class ButtonThread : public OSThread #endif #ifdef BUTTON_PIN_ALT OneButton userButtonAlt; +#endif +#ifdef BUTTON_PIN_TOUCH + OneButton userButtonTouch; #endif static bool shutdown_on_long_stop; @@ -222,6 +225,21 @@ class ButtonThread : public OSThread userButtonAlt.attachLongPressStop(userButtonPressedLongStop); wakeOnIrq(BUTTON_PIN_ALT, FALLING); #endif + +#ifdef BUTTON_PIN_TOUCH + userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true); +#ifdef INPUT_PULLUP_SENSE + // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did + pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE); +#endif + userButtonTouch.attachClick(touchPressed); + userButtonTouch.attachDuringLongPress(touchPressedLong); + userButtonTouch.attachDoubleClick(touchDoublePressed); + userButtonTouch.attachLongPressStart(touchPressedLongStart); + userButtonTouch.attachLongPressStop(touchPressedLongStop); + wakeOnIrq(BUTTON_PIN_TOUCH, FALLING); +#endif + } protected: @@ -237,6 +255,10 @@ class ButtonThread : public OSThread #ifdef BUTTON_PIN_ALT userButtonAlt.tick(); canSleep &= userButtonAlt.isIdle(); +#endif +#ifdef BUTTON_PIN_TOUCH + userButtonTouch.tick(); + canSleep &= userButtonTouch.isIdle(); #endif // if (!canSleep) DEBUG_MSG("Supressing sleep!\n"); // else DEBUG_MSG("sleep ok\n"); @@ -245,6 +267,33 @@ class ButtonThread : public OSThread } private: + static void touchPressed() + { + screen->forceDisplay(); + DEBUG_MSG("touch press!\n"); + } + static void touchDoublePressed() + { + DEBUG_MSG("touch double press!\n"); + } + static void touchPressedLong() + { + DEBUG_MSG("touch press long!\n"); + } + static void touchDoublePressedLong() + { + DEBUG_MSG("touch double pressed!\n"); + } + static void touchPressedLongStart() + { + DEBUG_MSG("touch long press start!\n"); + } + static void touchPressedLongStop() + { + DEBUG_MSG("touch long press stop!\n"); + } + + static void userButtonPressed() { // DEBUG_MSG("press!\n"); diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index df57ee913..a1471c67b 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -120,6 +120,7 @@ extern "C" { */ #define PIN_BUTTON1 (32 + 10) #define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO +#define PIN_BUTTON_TOUCH (0 + 11) // 0.11 is the soft touch button on T-Echo /* * Analog pins