From 33db9938b082c6faa00caaaf7d97cd5025900c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 14 Apr 2026 16:54:32 +0200 Subject: [PATCH] Define button behaviour and use all of the device flash --- boards/ThinkNode-M7.json | 42 +++++++++++++++++++ src/input/InputBroker.cpp | 6 +++ src/input/InputBroker.h | 1 + src/mesh/wifi/WiFiAPClient.cpp | 4 ++ src/modules/SystemCommandsModule.cpp | 11 +++++ src/platform/esp32/architecture.h | 2 + .../ELECROW-ThinkNode-M7/platformio.ini | 3 +- .../esp32s3/ELECROW-ThinkNode-M7/rfswitch.h | 4 +- .../esp32s3/ELECROW-ThinkNode-M7/variant.h | 6 +++ 9 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 boards/ThinkNode-M7.json diff --git a/boards/ThinkNode-M7.json b/boards/ThinkNode-M7.json new file mode 100644 index 000000000..2a0c5e583 --- /dev/null +++ b/boards/ThinkNode-M7.json @@ -0,0 +1,42 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-D BOARD_HAS_PSRAM", + "-D ARDUINO_USB_CDC_ON_BOOT=0", + "-D ARDUINO_USB_MODE=0", + "-D ARDUINO_RUNNING_CORE=1", + "-D ARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "qio_opi", + "hwids": [["0x303A", "0x1001"]], + "mcu": "esp32s3", + "variant": "ELECROW-ThinkNode-M7" + }, + "connectivity": ["wifi", "bluetooth", "lora"], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "ELECROW ThinkNode M7", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 524288, + "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.elecrow.com", + "vendor": "ELECROW" +} diff --git a/src/input/InputBroker.cpp b/src/input/InputBroker.cpp index b7c9b27a9..3b39c8dde 100644 --- a/src/input/InputBroker.cpp +++ b/src/input/InputBroker.cpp @@ -333,6 +333,12 @@ void InputBroker::Init() BaseType_t higherWake = 0; concurrency::mainDelay.interruptFromISR(&higherWake); }; +#if defined(ELECROW_ThinkNode_M7) + userConfigNoScreen.longLongPressTime = 15 * 1000; + userConfigNoScreen.longLongPress = INPUT_BROKER_FACTORY_RST; +#else + userConfigNoScreen.longLongPress = INPUT_BROKER_SHUTDOWN; +#endif userConfigNoScreen.singlePress = INPUT_BROKER_USER_PRESS; userConfigNoScreen.longPress = INPUT_BROKER_NONE; userConfigNoScreen.longPressTime = 500; diff --git a/src/input/InputBroker.h b/src/input/InputBroker.h index 847604011..975c9d9f4 100644 --- a/src/input/InputBroker.h +++ b/src/input/InputBroker.h @@ -25,6 +25,7 @@ enum input_broker_event { INPUT_BROKER_USER_PRESS, INPUT_BROKER_ALT_PRESS, INPUT_BROKER_ALT_LONG, + INPUT_BROKER_FACTORY_RST = 0x9a, INPUT_BROKER_SHUTDOWN = 0x9b, INPUT_BROKER_GPS_TOGGLE = 0x9e, INPUT_BROKER_SEND_PING = 0xaf, diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 3ee56b03c..be25e6865 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -129,7 +129,11 @@ bool initEthernet() ch390_conf.spi_mosi_gpio = ETH_MOSI_PIN; ch390_conf.spi_miso_gpio = ETH_MISO_PIN; ch390_conf.int_gpio = ETH_INT_PIN; +#ifdef ETH_RST_PIN ch390_conf.reset_gpio = ETH_RST_PIN; +#else + ch390_conf.reset_gpio = -1; +#endif ch390_conf.spi_clock_mhz = 20; if ((config.network.eth_enabled) && (ETH.begin(ch390_conf))) { WiFi.onEvent(WiFiEvent); diff --git a/src/modules/SystemCommandsModule.cpp b/src/modules/SystemCommandsModule.cpp index 1da756366..7e07414cd 100644 --- a/src/modules/SystemCommandsModule.cpp +++ b/src/modules/SystemCommandsModule.cpp @@ -115,6 +115,17 @@ int SystemCommandsModule::handleInputEvent(const InputEvent *event) case INPUT_BROKER_SHUTDOWN: shutdownAtMsec = millis(); return true; + // factory reset + case INPUT_BROKER_FACTORY_RST: + disableBluetooth(); + LOG_INFO("Initiate full factory reset"); + nodeDB->factoryReset(true); + // reboot(DEFAULT_REBOOT_SECONDS); + LOG_INFO("Reboot in %d seconds", DEFAULT_REBOOT_SECONDS); + if (screen) + screen->showSimpleBanner("Rebooting...", 0); // stays on screen + rebootAtMsec = (DEFAULT_REBOOT_SECONDS < 0) ? 0 : (millis() + DEFAULT_REBOOT_SECONDS * 1000); + return true; default: // No other input events handled here diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 30398a675..cd3ac1f9d 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -146,6 +146,8 @@ #define HW_VENDOR meshtastic_HardwareModel_THINKNODE_M2 #elif defined(ELECROW_ThinkNode_M5) #define HW_VENDOR meshtastic_HardwareModel_THINKNODE_M5 +#elif defined(ELECROW_ThinkNode_M7) +#define HW_VENDOR meshtastic_HardwareModel_THINKNODE_M7 #elif defined(ESP32_S3_PICO) #define HW_VENDOR meshtastic_HardwareModel_ESP32_S3_PICO #elif defined(SENSELORA_S3) diff --git a/variants/esp32s3/ELECROW-ThinkNode-M7/platformio.ini b/variants/esp32s3/ELECROW-ThinkNode-M7/platformio.ini index 78b8fffb0..f2ddbf8d2 100644 --- a/variants/esp32s3/ELECROW-ThinkNode-M7/platformio.ini +++ b/variants/esp32s3/ELECROW-ThinkNode-M7/platformio.ini @@ -1,7 +1,6 @@ [env:thinknode_m7] extends = esp32s3_base -board = ESP32-S3-WROOM-1-N4 -board_build.psram_type = opi +board = ThinkNode-M7 build_flags = ${esp32s3_base.build_flags} diff --git a/variants/esp32s3/ELECROW-ThinkNode-M7/rfswitch.h b/variants/esp32s3/ELECROW-ThinkNode-M7/rfswitch.h index 9bf672896..e5fe182c4 100644 --- a/variants/esp32s3/ELECROW-ThinkNode-M7/rfswitch.h +++ b/variants/esp32s3/ELECROW-ThinkNode-M7/rfswitch.h @@ -3,9 +3,9 @@ static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC}; static const Module::RfSwitchMode_t rfswitch_table[] = { - + // mode DIO5 DIO6 {LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}}, - {LR11x0::MODE_TX, {LOW, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, LOW}}, + {LR11x0::MODE_TX, {HIGH, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}}, {LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}}, {LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE, }; diff --git a/variants/esp32s3/ELECROW-ThinkNode-M7/variant.h b/variants/esp32s3/ELECROW-ThinkNode-M7/variant.h index 801d8d0c6..9724b20fa 100644 --- a/variants/esp32s3/ELECROW-ThinkNode-M7/variant.h +++ b/variants/esp32s3/ELECROW-ThinkNode-M7/variant.h @@ -1,13 +1,19 @@ #define HAS_GPS 0 #define HAS_WIRE 0 +#define HAS_SCREEN 0 #define I2C_NO_RESCAN +#define UART_TX 43 +#define UART_RX 44 + #define WIFI_LED 3 #define WIFI_STATE_ON 0 #define LED_PIN 46 #define LED_STATE_ON 0 #define BUTTON_PIN 4 +#define BUTTON_ACTIVE_LOW true +#define BUTTON_ACTIVE_PULLUP true #define LORA_SCK 11 #define LORA_MISO 9