From 81afd83099c41a47a41d292e18551cf650ba1538 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Mon, 1 Sep 2025 16:10:45 +1000 Subject: [PATCH 1/5] * Meshadventurer companion USB build fix --- variants/meshadventurer/platformio.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/variants/meshadventurer/platformio.ini b/variants/meshadventurer/platformio.ini index 3ea09ba7..1b881c1a 100644 --- a/variants/meshadventurer/platformio.ini +++ b/variants/meshadventurer/platformio.ini @@ -80,6 +80,8 @@ extends = Meshadventurer build_src_filter = ${Meshadventurer.build_src_filter} +<../examples/companion_radio/*.cpp> + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> build_flags = ${Meshadventurer.build_flags} -I examples/companion_radio/ui-new From b8223e9d07a967870720319fb68f2244759851e3 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Mon, 1 Sep 2025 16:28:53 +1000 Subject: [PATCH 2/5] * reverting HeltecV3 _CURRENT_LIMIT change --- variants/heltec_v3/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index d667a576..f545d898 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -17,7 +17,7 @@ build_flags = -D PIN_VEXT_EN=36 -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 - -D SX126X_CURRENT_LIMIT=160 + -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D PIN_GPS_RX=47 -D PIN_GPS_TX=48 From 74722c24b8b0052ed17b4613866247cb35728e0f Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Mon, 1 Sep 2025 17:11:55 +1000 Subject: [PATCH 3/5] * MomentaryButton: added support for analog button (with threshold) * RAK: support for PIN_USER_BTN_ANA --- examples/companion_radio/ui-new/UITask.cpp | 11 +++++++++++ src/helpers/ui/MomentaryButton.cpp | 22 +++++++++++++++++++--- src/helpers/ui/MomentaryButton.h | 2 ++ variants/rak4631/target.cpp | 4 ++++ variants/rak4631/target.h | 3 +++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 22f394e7..c751eaf5 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -354,6 +354,9 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no #if defined(PIN_USER_BTN) user_btn.begin(); #endif +#if defined(PIN_USER_BTN_ANA) + analog_btn.begin(); +#endif _node_prefs = node_prefs; if (_display != NULL) { @@ -508,6 +511,14 @@ void UITask::loop() { c = handleLongPress(KEY_RIGHT); } #endif +#if defined(PIN_USER_BTN_ANA) + ev = analog_btn.check(); + if (ev == BUTTON_EVENT_CLICK) { + c = checkDisplayOn(KEY_SELECT); + } else if (ev == BUTTON_EVENT_LONG_PRESS) { + c = handleLongPress(KEY_ENTER); + } +#endif if (c != 0 && curr) { curr->handleInput(c); diff --git a/src/helpers/ui/MomentaryButton.cpp b/src/helpers/ui/MomentaryButton.cpp index 9ddf1327..36309600 100644 --- a/src/helpers/ui/MomentaryButton.cpp +++ b/src/helpers/ui/MomentaryButton.cpp @@ -8,16 +8,29 @@ MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse prev = _reverse ? HIGH : LOW; cancel = 0; _long_millis = long_press_millis; + _threshold = 0; +} + +MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, int analog_threshold) { + _pin = pin; + _reverse = false; + _pull = false; + down_at = 0; + prev = LOW; + cancel = 0; + _long_millis = long_press_millis; + _threshold = analog_threshold; } void MomentaryButton::begin() { - if (_pin >= 0) { + if (_pin >= 0 && _threshold == 0) { pinMode(_pin, _pull ? (_reverse ? INPUT_PULLUP : INPUT_PULLDOWN) : INPUT); } } bool MomentaryButton::isPressed() const { - return isPressed(digitalRead(_pin)); + int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin); + return isPressed(btn); } void MomentaryButton::cancelClick() { @@ -25,6 +38,9 @@ void MomentaryButton::cancelClick() { } bool MomentaryButton::isPressed(int level) const { + if (_threshold > 0) { + return level; + } if (_reverse) { return level == LOW; } else { @@ -36,7 +52,7 @@ int MomentaryButton::check(bool repeat_click) { if (_pin < 0) return BUTTON_EVENT_NONE; int event = BUTTON_EVENT_NONE; - int btn = digitalRead(_pin); + int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin); if (btn != prev) { if (isPressed(btn)) { down_at = millis(); diff --git a/src/helpers/ui/MomentaryButton.h b/src/helpers/ui/MomentaryButton.h index 0bcc776c..d002f652 100644 --- a/src/helpers/ui/MomentaryButton.h +++ b/src/helpers/ui/MomentaryButton.h @@ -11,12 +11,14 @@ class MomentaryButton { int8_t prev, cancel; bool _reverse, _pull; int _long_millis; + int _threshold; // analog mode unsigned long down_at; bool isPressed(int level) const; public: MomentaryButton(int8_t pin, int long_press_mills=0, bool reverse=false, bool pulldownup=false); + MomentaryButton(int8_t pin, int long_press_mills, int analog_threshold); void begin(); int check(bool repeat_click=false); // returns one of BUTTON_EVENT_* void cancelClick(); // suppress next BUTTON_EVENT_CLICK (if already in DOWN state) diff --git a/variants/rak4631/target.cpp b/variants/rak4631/target.cpp index 618c9fc5..efed90aa 100644 --- a/variants/rak4631/target.cpp +++ b/variants/rak4631/target.cpp @@ -11,6 +11,10 @@ RAK4631Board board; #ifdef DISPLAY_CLASS DISPLAY_CLASS display; MomentaryButton user_btn(PIN_USER_BTN, 1000, true); + + #if defined(PIN_USER_BTN_ANA) + MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20); + #endif #endif RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); diff --git a/variants/rak4631/target.h b/variants/rak4631/target.h index 5e93b7fc..aa6be664 100644 --- a/variants/rak4631/target.h +++ b/variants/rak4631/target.h @@ -13,6 +13,9 @@ extern DISPLAY_CLASS display; #include extern MomentaryButton user_btn; + #if defined(PIN_USER_BTN_ANA) + extern MomentaryButton analog_btn; + #endif #endif extern RAK4631Board board; From 3ad43431d973aeed5cae6d9b584ae895c3b19a22 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 1 Sep 2025 21:04:41 +1200 Subject: [PATCH 4/5] fixed wismesh pocket user button --- variants/rak4631/target.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/rak4631/target.cpp b/variants/rak4631/target.cpp index efed90aa..bc7465fd 100644 --- a/variants/rak4631/target.cpp +++ b/variants/rak4631/target.cpp @@ -10,7 +10,7 @@ RAK4631Board board; #ifdef DISPLAY_CLASS DISPLAY_CLASS display; - MomentaryButton user_btn(PIN_USER_BTN, 1000, true); + MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true); #if defined(PIN_USER_BTN_ANA) MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20); From 637891b81468c2f25acd41260f2512591a1fe3cb Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Mon, 1 Sep 2025 19:32:15 +1000 Subject: [PATCH 5/5] * ver bump --- examples/companion_radio/MyMesh.h | 4 ++-- examples/simple_repeater/main.cpp | 4 ++-- examples/simple_room_server/main.cpp | 4 ++-- examples/simple_sensor/SensorMesh.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 89ee8133..e3235128 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -8,11 +8,11 @@ #define FIRMWARE_VER_CODE 7 #ifndef FIRMWARE_BUILD_DATE -#define FIRMWARE_BUILD_DATE "31 Aug 2025" +#define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION -#define FIRMWARE_VERSION "v1.8.0" +#define FIRMWARE_VERSION "v1.8.1" #endif #if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 309be201..565dc04a 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -22,11 +22,11 @@ /* ------------------------------ Config -------------------------------- */ #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "31 Aug 2025" + #define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.8.0" + #define FIRMWARE_VERSION "v1.8.1" #endif #ifndef LORA_FREQ diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 76961e22..fd9c4397 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -22,11 +22,11 @@ /* ------------------------------ Config -------------------------------- */ #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "31 Aug 2025" + #define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.8.0" + #define FIRMWARE_VERSION "v1.8.1" #endif #ifndef LORA_FREQ diff --git a/examples/simple_sensor/SensorMesh.h b/examples/simple_sensor/SensorMesh.h index 89f2ee88..7b3b3954 100644 --- a/examples/simple_sensor/SensorMesh.h +++ b/examples/simple_sensor/SensorMesh.h @@ -49,11 +49,11 @@ struct ContactInfo { }; #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "31 Aug 2025" + #define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.8.0" + #define FIRMWARE_VERSION "v1.8.1" #endif #define FIRMWARE_ROLE "sensor"