From 0ebdc7ab0c241adaeef5893c9bb4751b52869685 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Sat, 17 Aug 2024 00:37:22 +0200 Subject: [PATCH 01/11] Update architecture.h add Minewsemi ME25LS01 LR1110 breakout ME25LE01_V1.0 and fix buzzer (#4472) * Update architecture.h * Update variant.h * Update variant.h * Update architecture.h * Update architecture.h * Delete src/platform/nrf52/architecture.h * Add files via upload * Update architecture.h * Update architecture.h * Update architecture.h --- src/platform/nrf52/architecture.h | 4 +++- variants/ME25LS01-4Y10TD/variant.h | 4 ++-- variants/ME25LS01-4Y10TD_e-ink/variant.h | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index d5685d611c..ebb847dc81 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -62,6 +62,8 @@ #define HW_VENDOR meshtastic_HardwareModel_WIO_WM1110 #elif defined(TRACKER_T1000_E) #define HW_VENDOR meshtastic_HardwareModel_TRACKER_T1000_E +#elif defined(ME25LS01) +#define HW_VENDOR meshtastic_HardwareModel_ME25LS01 #elif defined(PRIVATE_HW) || defined(FEATHER_DIY) #define HW_VENDOR meshtastic_HardwareModel_PRIVATE_HW #else @@ -116,4 +118,4 @@ #if !defined(PIN_SERIAL_RX) && !defined(NRF52840_XXAA) // No serial ports on this board - ONLY use segger in memory console #define USE_SEGGER -#endif \ No newline at end of file +#endif diff --git a/variants/ME25LS01-4Y10TD/variant.h b/variants/ME25LS01-4Y10TD/variant.h index 24ed65b33b..715de8ee6c 100644 --- a/variants/ME25LS01-4Y10TD/variant.h +++ b/variants/ME25LS01-4Y10TD/variant.h @@ -126,7 +126,7 @@ extern "C" { #define VBAT_AR_INTERNAL AR_INTERNAL_3_0 // Buzzer -#define BUZZER_EN_PIN -1 +#define PIN_BUZZER (0 + 25) #ifdef __cplusplus } @@ -136,4 +136,4 @@ extern "C" { * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif // _VARIANT_ME25LS01_4Y10TD_ \ No newline at end of file +#endif // _VARIANT_ME25LS01_4Y10TD_ diff --git a/variants/ME25LS01-4Y10TD_e-ink/variant.h b/variants/ME25LS01-4Y10TD_e-ink/variant.h index 7c7740505d..9006d5a63f 100644 --- a/variants/ME25LS01-4Y10TD_e-ink/variant.h +++ b/variants/ME25LS01-4Y10TD_e-ink/variant.h @@ -149,7 +149,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #define VBAT_AR_INTERNAL AR_INTERNAL_3_0 // Buzzer -#define BUZZER_EN_PIN -1 +#define PIN_BUZZER (0 + 25) #ifdef __cplusplus } @@ -159,4 +159,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif // _VARIANT_ME25LS01_4Y10TD__ \ No newline at end of file +#endif // _VARIANT_ME25LS01_4Y10TD__ From e0b4a8e31ea22206ad60de20dac24dfc9dcbb8da Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Sat, 17 Aug 2024 22:51:53 +1200 Subject: [PATCH 02/11] Radio Master Joystick (#4476) * Radio Master Bandit 5-Way Joystick: first draft Untested on genuine hardware * "Okay" moves to next frame, even when canned message disabled * Refactor to allow easier customization * Implement feedback from testing * guard toggleGPS() * show "Shutting down.." screen * split adhoc ping alert onto two lines * Don't block while waiting for shutdown Was preventing the alert from showing --- src/input/ExpressLRSFiveWay.cpp | 260 ++++++++++++++++++ src/input/ExpressLRSFiveWay.h | 85 ++++++ src/modules/Modules.cpp | 4 + .../radiomaster_900_bandit_nano/variant.h | 11 +- 4 files changed, 353 insertions(+), 7 deletions(-) create mode 100644 src/input/ExpressLRSFiveWay.cpp create mode 100644 src/input/ExpressLRSFiveWay.h diff --git a/src/input/ExpressLRSFiveWay.cpp b/src/input/ExpressLRSFiveWay.cpp new file mode 100644 index 0000000000..c444800ba2 --- /dev/null +++ b/src/input/ExpressLRSFiveWay.cpp @@ -0,0 +1,260 @@ + +#include "ExpressLRSFiveWay.h" + +#ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE + +static const char inputSourceName[] = "ExpressLRS5Way"; // should match "allow input source" string + +/** + * @brief Calculate fuzz: half the distance to the next nearest neighbor for each joystick position. + * + * The goal is to avoid collisions between joystick positions while still maintaining + * the widest tolerance for the analog value. + * + * Example: {10,50,800,1000,300,1600} + * If we just choose the minimum difference for this array the value would + * be 40/2 = 20. + * + * 20 does not leave enough room for the joystick position using 1600 which + * could have a +-100 offset. + * + * Example Fuzz values: {20, 20, 100, 100, 125, 300} now the fuzz for the 1600 + * position is 300 instead of 20 + */ +void ExpressLRSFiveWay::calcFuzzValues() +{ + for (unsigned int i = 0; i < N_JOY_ADC_VALUES; i++) { + uint16_t closestDist = 0xffff; + uint16_t ival = joyAdcValues[i]; + // Find the closest value to ival + for (unsigned int j = 0; j < N_JOY_ADC_VALUES; j++) { + // Don't compare value with itself + if (j == i) + continue; + uint16_t jval = joyAdcValues[j]; + if (jval < ival && (ival - jval < closestDist)) + closestDist = ival - jval; + if (jval > ival && (jval - ival < closestDist)) + closestDist = jval - ival; + } // for j + + // And the fuzz is half the distance to the closest value + fuzzValues[i] = closestDist / 2; + // DBG("joy%u=%u f=%u, ", i, ival, fuzzValues[i]); + } // for i +} + +int ExpressLRSFiveWay::readKey() +{ + uint16_t value = analogRead(PIN_JOYSTICK); + + constexpr uint8_t IDX_TO_INPUT[N_JOY_ADC_VALUES - 1] = {UP, DOWN, LEFT, RIGHT, OK}; + for (unsigned int i = 0; i < N_JOY_ADC_VALUES - 1; ++i) { + if (value < (joyAdcValues[i] + fuzzValues[i]) && value > (joyAdcValues[i] - fuzzValues[i])) + return IDX_TO_INPUT[i]; + } + return NO_PRESS; +} + +ExpressLRSFiveWay::ExpressLRSFiveWay() : concurrency::OSThread(inputSourceName) +{ + // ExpressLRS: init values + isLongPressed = false; + keyInProcess = NO_PRESS; + keyDownStart = 0; + + // Express LRS: calculate the threshold for interpreting ADC values as various buttons + calcFuzzValues(); + + // Meshtastic: register with canned messages + inputBroker->registerSource(this); +} + +// ExpressLRS: interpret reading as key events +void ExpressLRSFiveWay::update(int *keyValue, bool *keyLongPressed) +{ + *keyValue = NO_PRESS; + + int newKey = readKey(); + uint32_t now = millis(); + if (keyInProcess == NO_PRESS) { + // New key down + if (newKey != NO_PRESS) { + keyDownStart = now; + // DBGLN("down=%u", newKey); + } + } else { + // if key released + if (newKey == NO_PRESS) { + // DBGLN("up=%u", keyInProcess); + if (!isLongPressed) { + if ((now - keyDownStart) > KEY_DEBOUNCE_MS) { + *keyValue = keyInProcess; + *keyLongPressed = false; + } + } + isLongPressed = false; + } + // else if the key has changed while down, reset state for next go-around + else if (newKey != keyInProcess) { + newKey = NO_PRESS; + } + // else still pressing, waiting for long if not already signaled + else if (!isLongPressed) { + if ((now - keyDownStart) > KEY_LONG_PRESS_MS) { + *keyValue = keyInProcess; + *keyLongPressed = true; + isLongPressed = true; + } + } + } // if keyInProcess != NO_PRESS + + keyInProcess = newKey; +} + +// Meshtastic: runs at regular intervals +int32_t ExpressLRSFiveWay::runOnce() +{ + uint32_t now = millis(); + + // Dismiss any alert frames after 2 seconds + // Feedback for GPS toggle / adhoc ping + if (alerting && now > alertingSinceMs + 2000) { + alerting = false; + screen->endAlert(); + } + + // Get key events from ExpressLRS code + int keyValue; + bool longPressed; + update(&keyValue, &longPressed); + + // Do something about this key press + determineAction((KeyType)keyValue, longPressed ? LONG : SHORT); + + // If there has been recent key activity, poll the joystick slightly more frequently + if (now < keyDownStart + (20 * 1000UL)) // Within last 20 seconds + return 100; + + // Otherwise, poll slightly less often + // Too many missed pressed if much slower than 250ms + return 250; +} + +// Determine what action to take when a button press is detected +// Written verbose for easier remapping by user +void ExpressLRSFiveWay::determineAction(KeyType key, PressLength length) +{ + switch (key) { + case LEFT: + if (inCannedMessageMenu()) // If in canned message menu + sendKey(CANCEL); // exit the menu (press imaginary cancel key) + else + sendKey(LEFT); + break; + + case RIGHT: + if (inCannedMessageMenu()) // If in canned message menu: + sendKey(CANCEL); // exit the menu (press imaginary cancel key) + else + sendKey(RIGHT); + break; + + case UP: + if (length == LONG) + toggleGPS(); + else + sendKey(UP); + break; + + case DOWN: + if (length == LONG) + sendAdhocPing(); + else + sendKey(DOWN); + break; + + case OK: + if (length == LONG) + shutdown(); + else + click(); // Use instead of sendKey(OK). Works better when canned message module disabled + break; + + default: + break; + } +} + +// Feed input to the canned messages module +void ExpressLRSFiveWay::sendKey(KeyType key) +{ + InputEvent e; + e.source = inputSourceName; + e.inputEvent = key; + notifyObservers(&e); +} + +// Enable or Disable a connected GPS +// Contained as one method for easier remapping of buttons by user +void ExpressLRSFiveWay::toggleGPS() +{ +#if HAS_GPS && !MESHTASTIC_EXCLUDE_GPS + if (!config.device.disable_triple_click && (gps != nullptr)) { + gps->toggleGpsMode(); + screen->startAlert("GPS Toggled"); + alerting = true; + alertingSinceMs = millis(); + } +#endif +} + +// Send either node-info or position, on demand +// Contained as one method for easier remapping of buttons by user +void ExpressLRSFiveWay::sendAdhocPing() +{ + service->refreshLocalMeshNode(); + bool sentPosition = service->trySendPosition(NODENUM_BROADCAST, true); + + // Show custom alert frame, with multi-line centering + screen->startAlert([sentPosition](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void { + uint16_t x_offset = display->width() / 2; + uint16_t y_offset = 26; // Same constant as the default startAlert frame + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->setFont(FONT_MEDIUM); + display->drawString(x_offset + x, y_offset + y, "Sent ad-hoc"); + display->drawString(x_offset + x, y_offset + FONT_HEIGHT_MEDIUM + y, sentPosition ? "position" : "nodeinfo"); + }); + + alerting = true; + alertingSinceMs = millis(); +} + +// Shutdown the node (enter deep-sleep) +// Contained as one method for easier remapping of buttons by user +void ExpressLRSFiveWay::shutdown() +{ + LOG_INFO("Shutdown from long press\n"); + powerFSM.trigger(EVENT_PRESS); + screen->startAlert("Shutting down..."); + // Don't set alerting = true. We don't want to auto-dismiss this alert. + + playShutdownMelody(); // In case user adds a buzzer + + shutdownAtMsec = millis() + 3000; +} + +// Emulate user button, or canned message SELECT +// This is necessary as canned message module doesn't translate SELECT to user button presses if the module is disabled +// Contained as one method for easier remapping of buttons by user +void ExpressLRSFiveWay::click() +{ + if (!moduleConfig.canned_message.enabled) + powerFSM.trigger(EVENT_PRESS); + else + sendKey(OK); +} + +ExpressLRSFiveWay *expressLRSFiveWayInput = nullptr; + +#endif \ No newline at end of file diff --git a/src/input/ExpressLRSFiveWay.h b/src/input/ExpressLRSFiveWay.h new file mode 100644 index 0000000000..c53aa9c09b --- /dev/null +++ b/src/input/ExpressLRSFiveWay.h @@ -0,0 +1,85 @@ +/* + Input source for Radio Master Bandit Nano, and similar hardware. + Devices have a 5-button "resistor ladder" style joystick, read by ADC. + These devices do not use the ADC to monitor input voltage. + + Much of this code taken directly from ExpressLRS FiveWayButton class: + https://github.com/ExpressLRS/ExpressLRS/tree/d9f56f8bd6f9f7144d5f01caaca766383e1e0950/src/lib/SCREEN/FiveWayButton +*/ + +#pragma once + +#include "configuration.h" + +#ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE + +#include +#include + +#include "InputBroker.h" +#include "MeshService.h" // For adhoc ping action +#include "buzz.h" +#include "concurrency/OSThread.h" +#include "graphics/Screen.h" // Feedback for adhoc ping / toggle GPS +#include "main.h" +#include "modules/CannedMessageModule.h" + +#if HAS_GPS && !MESHTASTIC_EXCLUDE_GPS +#include "GPS.h" // For toggle GPS action +#endif + +class ExpressLRSFiveWay : public Observable, public concurrency::OSThread +{ + private: + // Number of values in JOY_ADC_VALUES, if defined + // These must be ADC readings for {UP, DOWN, LEFT, RIGHT, ENTER, IDLE} + static constexpr size_t N_JOY_ADC_VALUES = 6; + static constexpr uint32_t KEY_DEBOUNCE_MS = 25; + static constexpr uint32_t KEY_LONG_PRESS_MS = 3000; // How many milliseconds to hold key for a long press + + // This merged an enum used by the ExpressLRS code, with meshtastic canned message values + // Key names are kept simple, to allow user customizaton + typedef enum { + UP = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP, + DOWN = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN, + LEFT = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT, + RIGHT = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT, + OK = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT, + CANCEL = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL, + NO_PRESS = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE + } KeyType; + + typedef enum { SHORT, LONG } PressLength; + + // From ExpressLRS + int keyInProcess; + uint32_t keyDownStart; + bool isLongPressed; + const uint16_t joyAdcValues[N_JOY_ADC_VALUES] = {JOYSTICK_ADC_VALS}; + uint16_t fuzzValues[N_JOY_ADC_VALUES]; + void calcFuzzValues(); + int readKey(); + void update(int *keyValue, bool *keyLongPressed); + + // Meshtastic code + void determineAction(KeyType key, PressLength length); + void sendKey(KeyType key); + inline bool inCannedMessageMenu() { return cannedMessageModule->shouldDraw(); } + int32_t runOnce() override; + + // Simplified Meshtastic actions, for easier remapping by user + void toggleGPS(); + void sendAdhocPing(); + void shutdown(); + void click(); + + bool alerting = false; // Is the screen showing an alert frame? Feedback for GPS toggle / adhoc ping actions + uint32_t alertingSinceMs = 0; // When did screen begin showing an alert frame? Used to auto-dismiss + + public: + ExpressLRSFiveWay(); +}; + +extern ExpressLRSFiveWay *expressLRSFiveWayInput; + +#endif \ No newline at end of file diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index a1c9f4a03d..eca0e8ac91 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -1,5 +1,6 @@ #include "configuration.h" #if !MESHTASTIC_EXCLUDE_INPUTBROKER +#include "input/ExpressLRSFiveWay.h" #include "input/InputBroker.h" #include "input/RotaryEncoderInterruptImpl1.h" #include "input/ScanAndSelect.h" @@ -176,6 +177,9 @@ void setupModules() trackballInterruptImpl1 = new TrackballInterruptImpl1(); trackballInterruptImpl1->init(); #endif +#ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE + expressLRSFiveWayInput = new ExpressLRSFiveWay(); +#endif #if HAS_SCREEN && !MESHTASTIC_EXCLUDE_CANNEDMESSAGES cannedMessageModule = new CannedMessageModule(); #endif diff --git a/variants/radiomaster_900_bandit_nano/variant.h b/variants/radiomaster_900_bandit_nano/variant.h index 39c1bc06f3..1b6bba126e 100644 --- a/variants/radiomaster_900_bandit_nano/variant.h +++ b/variants/radiomaster_900_bandit_nano/variant.h @@ -41,14 +41,11 @@ /* Five way button when using ADC. - 2.632V, 2.177V, 1.598V, 1.055V, 0V - - Possible ADC Values: - { UP, DOWN, LEFT, RIGHT, ENTER, IDLE } - 3227, 0 ,1961, 2668, 1290, 4095 + https://github.com/ExpressLRS/targets/blob/f3215b5ec891108db1a13523e4163950cfcadaac/TX/Radiomaster%20Bandit.json#L41 */ -#define BUTTON_PIN 39 -#define BUTTON_NEED_PULLUP +#define INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE +#define PIN_JOYSTICK 39 +#define JOYSTICK_ADC_VALS /*UP*/ 3227, /*DOWN*/ 0, /*LEFT*/ 1961, /*RIGHT*/ 2668, /*OK*/ 1290, /*IDLE*/ 4095 #define DISPLAY_FLIP_SCREEN From a577dd4142ab7becd0addd1b87a6a545f8b0af0f Mon Sep 17 00:00:00 2001 From: Matt Ranostaj Date: Sat, 17 Aug 2024 19:37:05 +0800 Subject: [PATCH 03/11] define PERIPHERAL_WARMUP_MS for heltec_capsule_sensor_v3 (#4473) * delay is at least needed for the GXHTC3 module to be detected --- variants/heltec_capsule_sensor_v3/variant.h | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/heltec_capsule_sensor_v3/variant.h b/variants/heltec_capsule_sensor_v3/variant.h index d77571c278..415de0559d 100644 --- a/variants/heltec_capsule_sensor_v3/variant.h +++ b/variants/heltec_capsule_sensor_v3/variant.h @@ -47,6 +47,7 @@ #define SENSOR_POWER_CTRL_PIN 21 #define SENSOR_POWER_ON 1 +#define PERIPHERAL_WARMUP_MS 100 #define SENSOR_GPS_CONFLICT #define ESP32S3_WAKE_TYPE ESP_EXT1_WAKEUP_ANY_HIGH \ No newline at end of file From 5ff1078c8c150eb61f1f611ec1118aa6b833e44c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 17 Aug 2024 11:51:53 -0500 Subject: [PATCH 04/11] Move NeighborInfo interval default to 6 hours (double NodeInfo) (#4483) * Move NeighborInfo in line with NodeInfo * Set default to 6 hours and cap minimum at 2 hours --- src/mesh/Default.h | 2 ++ src/modules/AdminModule.cpp | 4 ++++ src/modules/NeighborInfoModule.cpp | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesh/Default.h b/src/mesh/Default.h index 3c95544dac..bafa608981 100644 --- a/src/mesh/Default.h +++ b/src/mesh/Default.h @@ -13,7 +13,9 @@ #define default_min_wake_secs 10 #define default_screen_on_secs IF_ROUTER(1, 60 * 10) #define default_node_info_broadcast_secs 3 * 60 * 60 +#define default_neighbor_info_broadcast_secs 6 * 60 * 60 #define min_node_info_broadcast_secs 60 * 60 // No regular broadcasts of more than once an hour +#define min_neighbor_info_broadcast_secs 2 * 60 * 60 #define default_mqtt_address "mqtt.meshtastic.org" #define default_mqtt_username "meshdev" diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 25450992b1..cf22470315 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -557,6 +557,10 @@ void AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c) case meshtastic_ModuleConfig_neighbor_info_tag: LOG_INFO("Setting module config: Neighbor Info\n"); moduleConfig.has_neighbor_info = true; + if (moduleConfig.neighbor_info.update_interval < min_neighbor_info_broadcast_secs) { + LOG_DEBUG("Tried to set update_interval too low, setting to %d\n", default_neighbor_info_broadcast_secs); + moduleConfig.neighbor_info.update_interval = default_neighbor_info_broadcast_secs; + } moduleConfig.neighbor_info = c.payload_variant.neighbor_info; break; case meshtastic_ModuleConfig_detection_sensor_tag: diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index fb12490297..8284c52d9e 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -120,8 +120,7 @@ int32_t NeighborInfoModule::runOnce() if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) { sendNeighborInfo(NODENUM_BROADCAST, false); } - return Default::getConfiguredOrDefaultMsScaled(moduleConfig.neighbor_info.update_interval, default_broadcast_interval_secs, - numOnlineNodes); + return Default::getConfiguredOrDefault(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs); } /* From e37acae40583cac5cb55bdd3210db1b51950cd89 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sat, 17 Aug 2024 22:09:13 +0200 Subject: [PATCH 05/11] Fix RF switching logic on rp2040-lora board. (#4486) * Fix LED pinout for T-Echo board marked v1.0, date 2021-6-28 * Merge PR #420 * Fixed double and missing Default class. * Use correct format specifier and fixed typo. * Removed duplicate code. * Fix error: #if with no expression * Fix warning: extra tokens at end of #endif directive. * Fix antenna switching logic. Complementary-pin control logic is required on the rp2040-lora board. --------- Co-authored-by: Ben Meadors --- variants/rp2040-lora/variant.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/variants/rp2040-lora/variant.h b/variants/rp2040-lora/variant.h index 1f42c4db74..d0bbc0ec39 100644 --- a/variants/rp2040-lora/variant.h +++ b/variants/rp2040-lora/variant.h @@ -15,7 +15,7 @@ // rxd = 9 #define EXT_NOTIFY_OUT 22 -#define BUTTON_PIN 17 +#undef BUTTON_PIN // Pin 17 used for antenna switching via DIO4 #define LED_PIN PIN_LED @@ -32,23 +32,28 @@ // https://www.waveshare.com/rp2040-lora.htm // https://www.waveshare.com/img/devkit/RP2040-LoRa-HF/RP2040-LoRa-HF-details-11.jpg -#define LORA_SCK 14 // 10 -#define LORA_MISO 24 // 12 -#define LORA_MOSI 15 // 11 -#define LORA_CS 13 // 3 - -#define LORA_DIO0 RADIOLIB_NC -#define LORA_RESET 23 // 15 -#define LORA_DIO1 16 // 20 -#define LORA_DIO2 18 // 2 -#define LORA_DIO3 RADIOLIB_NC -#define LORA_DIO4 17 +#define LORA_SCK 14 // GPIO14 +#define LORA_MISO 24 // GPIO24 +#define LORA_MOSI 15 // GPIO15 +#define LORA_CS 13 // GPIO13 + +#define LORA_DIO0 RADIOLIB_NC // No GPIO connection +#define LORA_RESET 23 // GPIO23 +#define LORA_BUSY 18 // GPIO18 +#define LORA_DIO1 16 // GPIO16 +#define LORA_DIO2 RADIOLIB_NC // Antenna switching, no GPIO connection +#define LORA_DIO3 RADIOLIB_NC // No GPIO connection +#define LORA_DIO4 17 // GPIO17 + +// On rp2040-lora board the antenna switch is wired and works with complementary-pin control logic. +// See PE4259 datasheet page 4 #ifdef USE_SX1262 #define SX126X_CS LORA_CS #define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY LORA_DIO2 +#define SX126X_BUSY LORA_BUSY #define SX126X_RESET LORA_RESET -#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO2_AS_RF_SWITCH // Antenna switch CTRL +#define SX126X_RXEN LORA_DIO4 // Antenna switch !CTRL via GPIO17 // #define SX126X_DIO3_TCXO_VOLTAGE 1.8 #endif \ No newline at end of file From 1bbc273ba6cac076fa2c97a30178ef2bc12e682b Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 17 Aug 2024 17:35:05 -0500 Subject: [PATCH 06/11] Don't reject network time updates unintentionally (#4489) --- src/modules/PositionModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 1756e8508e..5acb5e9d15 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -140,7 +140,8 @@ void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal, bool forceUp bool PositionModule::hasQualityTimesource() { - bool setFromPhoneOrNtpToday = (millis() - lastSetFromPhoneNtpOrGps) <= (SEC_PER_DAY * 1000UL); + bool setFromPhoneOrNtpToday = + lastSetFromPhoneNtpOrGps == 0 ? false : (millis() - lastSetFromPhoneNtpOrGps) <= (SEC_PER_DAY * 1000UL); bool hasGpsOrRtc = (gps && gps->isConnected()) || (rtc_found.address != ScanI2C::ADDRESS_NONE.address); return hasGpsOrRtc || setFromPhoneOrNtpToday; } From a8999d77590408d1f5f71941ab17d4ce7331e47a Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Mon, 19 Aug 2024 00:22:16 +1200 Subject: [PATCH 07/11] Don't manually clear runAsap flag (#4496) --- src/ButtonThread.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 1b101044fd..5351fa049f 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -224,7 +224,6 @@ int32_t ButtonThread::runOnce() btnEvent = BUTTON_EVENT_NONE; } - runASAP = false; return 50; } From 7129cee944d78387f65a223bb69024253cdc20bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= <593860+mrfyda@users.noreply.github.com> Date: Sun, 18 Aug 2024 13:38:54 +0100 Subject: [PATCH 08/11] feature: default to fuzzy GPS location on the Default Channel (#4467) * feature: default to fuzzy GPS location on the Default Channel * Default to 13 * 13 default --------- Co-authored-by: Ben Meadors --- src/mesh/Channels.cpp | 4 ++-- src/modules/PositionModule.cpp | 5 +++-- userPrefs.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 6e721d9b04..bba7571d26 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -97,7 +97,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex) channelSettings.psk.bytes[0] = defaultpskIndex; channelSettings.psk.size = 1; strncpy(channelSettings.name, "", sizeof(channelSettings.name)); - channelSettings.module_settings.position_precision = 32; // default to sending location on the primary channel + channelSettings.module_settings.position_precision = 13; // default to sending location on the primary channel channelSettings.has_module_settings = true; ch.has_settings = true; @@ -363,4 +363,4 @@ bool Channels::decryptForHash(ChannelIndex chIndex, ChannelHash channelHash) int16_t Channels::setActiveByIndex(ChannelIndex channelIndex) { return setCrypto(channelIndex); -} \ No newline at end of file +} diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 5acb5e9d15..f534baf677 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -298,7 +298,8 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t cha if (channels.getByIndex(channel).settings.has_module_settings) { precision = channels.getByIndex(channel).settings.module_settings.position_precision; } else if (channels.getByIndex(channel).role == meshtastic_Channel_Role_PRIMARY) { - precision = 32; + // backwards compatibility for Primary channels created before position_precision was set by default + precision = 13; } else { precision = 0; } @@ -470,4 +471,4 @@ void PositionModule::handleNewPosition() } } -#endif \ No newline at end of file +#endif diff --git a/userPrefs.h b/userPrefs.h index 3ebbefcaf9..52209deaad 100644 --- a/userPrefs.h +++ b/userPrefs.h @@ -17,7 +17,7 @@ } */ // #define CHANNEL_0_NAME_USERPREFS "DEFCONnect" -// #define CHANNEL_0_PRECISION_USERPREFS 13 +// #define CHANNEL_0_PRECISION_USERPREFS 14 // #define CONFIG_OWNER_LONG_NAME_USERPREFS "My Long Name" // #define CONFIG_OWNER_SHORT_NAME_USERPREFS "MLN" From 14146d6ff57134a1328c3ea55293b0dcf00263d6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 19 Aug 2024 07:04:48 -0500 Subject: [PATCH 09/11] Ms! --- src/modules/NeighborInfoModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index 8284c52d9e..2de4374e69 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -120,7 +120,7 @@ int32_t NeighborInfoModule::runOnce() if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) { sendNeighborInfo(NODENUM_BROADCAST, false); } - return Default::getConfiguredOrDefault(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs); + return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs); } /* From e65e79c6c9f4fcd3e74e21b02b4cfd967c913c93 Mon Sep 17 00:00:00 2001 From: Talie5in Date: Mon, 19 Aug 2024 21:35:28 +0930 Subject: [PATCH 10/11] We need Millseconds not... rapid fire NeighbourInfo! (#4504) From 6de3ca4301c32ec1f2c5094357597bf5ae5646e7 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Mon, 19 Aug 2024 14:09:09 +0200 Subject: [PATCH 11/11] Fix deprecated macros. (#4505) * Fix LED pinout for T-Echo board marked v1.0, date 2021-6-28 * Merge PR #420 * Fixed double and missing Default class. * Use correct format specifier and fixed typo. * Removed duplicate code. * Fix error: #if with no expression * Fix warning: extra tokens at end of #endif directive. * Fix antenna switching logic. Complementary-pin control logic is required on the rp2040-lora board. * Fix deprecated macros. --------- Co-authored-by: Ben Meadors --- src/modules/Telemetry/Sensor/OPT3001Sensor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp b/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp index d0e38bf889..338bd9e2c1 100644 --- a/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp +++ b/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp @@ -25,10 +25,10 @@ void OPT3001Sensor::setup() { OPT3001_Config newConfig; - newConfig.RangeNumber = B1100; - newConfig.ConvertionTime = B0; - newConfig.Latch = B1; - newConfig.ModeOfConversionOperation = B11; + newConfig.RangeNumber = 0b1100; + newConfig.ConvertionTime = 0b0; + newConfig.Latch = 0b1; + newConfig.ModeOfConversionOperation = 0b11; OPT3001_ErrorCode errorConfig = opt3001.writeConfig(newConfig); if (errorConfig != NO_ERROR) {