From 76adcbb46ba2c8c57158db37a73a6d75bb4511be Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 11:57:49 +0800 Subject: [PATCH 01/35] Enhanced t-echo file system integrity check --- src/FSCommon.cpp | 86 ++++++++++++++++++++++++++++++---- variants/t-echo/platformio.ini | 1 + 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index d5ca72142..3d2885654 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -205,6 +205,63 @@ void rmDir(const char *dirname) #endif } +bool fsCheck() +{ +#if defined(ARCH_NRF52) + size_t write_size = 0; + size_t read_size = 0; + char buf[32] = {0}; + while (!Serial); + + Adafruit_LittleFS_Namespace::File file(FSCom); + const char *text = "meshtastic fs test"; + size_t text_length = strlen(text); + const char *filename = "/meshtastic.txt"; + + LOG_DEBUG("Try create file .\n"); + if (file.open(filename, FILE_O_WRITE)) { + write_size = file.write(text); + } else { + LOG_DEBUG("Open file failed .\n");; + goto FORMAT_FS; + } + + if (write_size != text_length) { + LOG_DEBUG("Text bytes do not match .\n"); + file.close(); + goto FORMAT_FS; + } + + file.close(); + + if (!file.open(filename, FILE_O_READ)) { + LOG_DEBUG("Open file failed .\n"); + goto FORMAT_FS; + } + + read_size = file.readBytes(buf, text_length); + if (read_size != text_length) { + LOG_DEBUG("Text bytes do not match .\n"); + file.close(); + goto FORMAT_FS; + } + + if (memcmp(buf, text, text_length) != 0) { + LOG_DEBUG("The written bytes do not match the read bytes .\n"); + file.close(); + goto FORMAT_FS; + } + return true; +FORMAT_FS: + LOG_DEBUG("Format FS ....\n"); + FSCom.format(); + FSCom.begin(); + return false; +#else + return true; +#endif +} + void fsInit() { #ifdef FSCom @@ -219,15 +276,28 @@ void fsInit() * nRF52840 has a certain chance of automatic formatting failure. * Try to create a file after initializing the file system. If the creation fails, * it means that the file system is not working properly. Please format it manually again. + * To check the normality of the file system, you need to disable the LFS_NO_ASSERT assertion. + * Otherwise, the assertion will be entered at the moment of reading or opening, and the FS will not be formatted. * */ - Adafruit_LittleFS_Namespace::File file(FSCom); - const char *filename = "/meshtastic.txt"; - if (!file.open(filename, FILE_O_WRITE)) { - LOG_DEBUG("Format ...."); - FSCom.format(); - FSCom.begin(); - } else { - file.close(); + bool ret = false; + uint8_t retry = 3; + + while (retry--) { + ret = fsCheck(); + if (ret) { + LOG_DEBUG("File system check is OK.\n"); + break; + } + delay(10); + } + + // It may not be possible to reach this step. + // Add a loop here to prevent unpredictable situations from happening. + // Can add a screen to display error status later. + if (!ret) { + while (1) { + Serial.println("The file system is damaged and cannot proceed to the next step.\n"); delay(1000); + } } #else LOG_DEBUG("Filesystem files:\n"); diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 9ff60be3f..900c7ffd8 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -17,6 +17,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. + -DLFS_NO_ASSERT ; Disable LFS assertions build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo> lib_deps = ${nrf52840_base.lib_deps} From b63997b36f56e61ad2eefafaac80e66afd65dd18 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 13:42:00 +0800 Subject: [PATCH 02/35] Remove debug wait --- src/FSCommon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 3d2885654..28dd877ae 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -211,7 +211,6 @@ bool fsCheck() size_t write_size = 0; size_t read_size = 0; char buf[32] = {0}; - while (!Serial); Adafruit_LittleFS_Namespace::File file(FSCom); const char *text = "meshtastic fs test"; From 81ecd6d926f0dfe4a938ca0106975f326ca9f533 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 14:33:16 +0800 Subject: [PATCH 03/35] trunk fmt --- src/FSCommon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 28dd877ae..8e3b67fa0 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -208,8 +208,8 @@ void rmDir(const char *dirname) bool fsCheck() { #if defined(ARCH_NRF52) - size_t write_size = 0; - size_t read_size = 0; + size_t write_size = 0; + size_t read_size = 0; char buf[32] = {0}; Adafruit_LittleFS_Namespace::File file(FSCom); @@ -221,7 +221,7 @@ bool fsCheck() if (file.open(filename, FILE_O_WRITE)) { write_size = file.write(text); } else { - LOG_DEBUG("Open file failed .\n");; + LOG_DEBUG("Open file failed .\n"); goto FORMAT_FS; } @@ -295,7 +295,8 @@ void fsInit() // Can add a screen to display error status later. if (!ret) { while (1) { - Serial.println("The file system is damaged and cannot proceed to the next step.\n"); delay(1000); + Serial.println("The file system is damaged and cannot proceed to the next step.\n"); + delay(1000); } } #else From 8886d2df551fd66dfe7886114f82000353ed1e47 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 11:57:49 +0800 Subject: [PATCH 04/35] Enhanced t-echo file system integrity check --- src/FSCommon.cpp | 86 ++++++++++++++++++++++++++++++---- variants/t-echo/platformio.ini | 1 + 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index d5ca72142..3d2885654 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -205,6 +205,63 @@ void rmDir(const char *dirname) #endif } +bool fsCheck() +{ +#if defined(ARCH_NRF52) + size_t write_size = 0; + size_t read_size = 0; + char buf[32] = {0}; + while (!Serial); + + Adafruit_LittleFS_Namespace::File file(FSCom); + const char *text = "meshtastic fs test"; + size_t text_length = strlen(text); + const char *filename = "/meshtastic.txt"; + + LOG_DEBUG("Try create file .\n"); + if (file.open(filename, FILE_O_WRITE)) { + write_size = file.write(text); + } else { + LOG_DEBUG("Open file failed .\n");; + goto FORMAT_FS; + } + + if (write_size != text_length) { + LOG_DEBUG("Text bytes do not match .\n"); + file.close(); + goto FORMAT_FS; + } + + file.close(); + + if (!file.open(filename, FILE_O_READ)) { + LOG_DEBUG("Open file failed .\n"); + goto FORMAT_FS; + } + + read_size = file.readBytes(buf, text_length); + if (read_size != text_length) { + LOG_DEBUG("Text bytes do not match .\n"); + file.close(); + goto FORMAT_FS; + } + + if (memcmp(buf, text, text_length) != 0) { + LOG_DEBUG("The written bytes do not match the read bytes .\n"); + file.close(); + goto FORMAT_FS; + } + return true; +FORMAT_FS: + LOG_DEBUG("Format FS ....\n"); + FSCom.format(); + FSCom.begin(); + return false; +#else + return true; +#endif +} + void fsInit() { #ifdef FSCom @@ -219,15 +276,28 @@ void fsInit() * nRF52840 has a certain chance of automatic formatting failure. * Try to create a file after initializing the file system. If the creation fails, * it means that the file system is not working properly. Please format it manually again. + * To check the normality of the file system, you need to disable the LFS_NO_ASSERT assertion. + * Otherwise, the assertion will be entered at the moment of reading or opening, and the FS will not be formatted. * */ - Adafruit_LittleFS_Namespace::File file(FSCom); - const char *filename = "/meshtastic.txt"; - if (!file.open(filename, FILE_O_WRITE)) { - LOG_DEBUG("Format ...."); - FSCom.format(); - FSCom.begin(); - } else { - file.close(); + bool ret = false; + uint8_t retry = 3; + + while (retry--) { + ret = fsCheck(); + if (ret) { + LOG_DEBUG("File system check is OK.\n"); + break; + } + delay(10); + } + + // It may not be possible to reach this step. + // Add a loop here to prevent unpredictable situations from happening. + // Can add a screen to display error status later. + if (!ret) { + while (1) { + Serial.println("The file system is damaged and cannot proceed to the next step.\n"); delay(1000); + } } #else LOG_DEBUG("Filesystem files:\n"); diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 9ff60be3f..900c7ffd8 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -17,6 +17,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. + -DLFS_NO_ASSERT ; Disable LFS assertions build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo> lib_deps = ${nrf52840_base.lib_deps} From 8e7ede16efe2c20ce3ab31dc358944b35468ef8c Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 13:42:00 +0800 Subject: [PATCH 05/35] Remove debug wait --- src/FSCommon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 3d2885654..28dd877ae 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -211,7 +211,6 @@ bool fsCheck() size_t write_size = 0; size_t read_size = 0; char buf[32] = {0}; - while (!Serial); Adafruit_LittleFS_Namespace::File file(FSCom); const char *text = "meshtastic fs test"; From 1d583341e49ba353bf2339c67a21c677dbf3e85c Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 14:33:16 +0800 Subject: [PATCH 06/35] trunk fmt --- src/FSCommon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 28dd877ae..8e3b67fa0 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -208,8 +208,8 @@ void rmDir(const char *dirname) bool fsCheck() { #if defined(ARCH_NRF52) - size_t write_size = 0; - size_t read_size = 0; + size_t write_size = 0; + size_t read_size = 0; char buf[32] = {0}; Adafruit_LittleFS_Namespace::File file(FSCom); @@ -221,7 +221,7 @@ bool fsCheck() if (file.open(filename, FILE_O_WRITE)) { write_size = file.write(text); } else { - LOG_DEBUG("Open file failed .\n");; + LOG_DEBUG("Open file failed .\n"); goto FORMAT_FS; } @@ -295,7 +295,8 @@ void fsInit() // Can add a screen to display error status later. if (!ret) { while (1) { - Serial.println("The file system is damaged and cannot proceed to the next step.\n"); delay(1000); + Serial.println("The file system is damaged and cannot proceed to the next step.\n"); + delay(1000); } } #else From 73ab43c67a2a5aafbdf49eae951ffaf500a74c38 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Wed, 8 May 2024 08:45:24 +0800 Subject: [PATCH 07/35] Change to LOG_ERROR --- src/FSCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 8e3b67fa0..96aad1a9a 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -295,7 +295,7 @@ void fsInit() // Can add a screen to display error status later. if (!ret) { while (1) { - Serial.println("The file system is damaged and cannot proceed to the next step.\n"); + LOG_ERROR("The file system is damaged and cannot proceed to the next step.\n"); delay(1000); } } From 8c3b9a61395d15f4b88101760f0eb94989e21b14 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Wed, 8 May 2024 08:46:08 +0800 Subject: [PATCH 08/35] Move LFS_NO_ASSERT to nrf52.ini --- arch/nrf52/nrf52.ini | 1 + variants/t-echo/platformio.ini | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 0669a31e8..314c73361 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -9,6 +9,7 @@ build_flags = -DSERIAL_BUFFER_SIZE=1024 -Wno-unused-variable -Isrc/platform/nrf52 + -DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818 build_src_filter = ${arduino_base.build_src_filter} - - - - - - - - - - diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 900c7ffd8..9ff60be3f 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -17,7 +17,6 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. - -DLFS_NO_ASSERT ; Disable LFS assertions build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo> lib_deps = ${nrf52840_base.lib_deps} From 6c75f2e627a6e67e3dc059797dd99af63a182c92 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Wed, 8 May 2024 08:51:24 +0800 Subject: [PATCH 09/35] Move LFS_NO_ASSERT to nrf52.ini --- variants/t-echo/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 900c7ffd8..1ba0afe25 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -17,7 +17,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. - -DLFS_NO_ASSERT ; Disable LFS assertions + build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo> lib_deps = ${nrf52840_base.lib_deps} From 8105c0440a8ad943b924ba745538dac09688124a Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 8 May 2024 14:53:13 +0300 Subject: [PATCH 10/35] New variants PROMICRO_DIY (#3788) * New variants PROMICRO_DIY * Renaming and cleanup * Renaming - phase 2 * nrf52_promicro: Trunk formatting --------- Co-authored-by: Ben Meadors --- boards/promicro-nrf52840.json | 52 ++++++ src/platform/nrf52/architecture.h | 2 + .../diy/nrf52_promicro_diy_tcxo/variant.cpp | 31 ++++ .../diy/nrf52_promicro_diy_tcxo/variant.h | 154 ++++++++++++++++++ .../diy/nrf52_promicro_diy_xtal/variant.cpp | 31 ++++ .../diy/nrf52_promicro_diy_xtal/variant.h | 153 +++++++++++++++++ variants/diy/platformio.ini | 32 ++++ 7 files changed, 455 insertions(+) create mode 100644 boards/promicro-nrf52840.json create mode 100644 variants/diy/nrf52_promicro_diy_tcxo/variant.cpp create mode 100644 variants/diy/nrf52_promicro_diy_tcxo/variant.h create mode 100644 variants/diy/nrf52_promicro_diy_xtal/variant.cpp create mode 100644 variants/diy/nrf52_promicro_diy_xtal/variant.h diff --git a/boards/promicro-nrf52840.json b/boards/promicro-nrf52840.json new file mode 100644 index 000000000..99ae3f01e --- /dev/null +++ b/boards/promicro-nrf52840.json @@ -0,0 +1,52 @@ +{ + "build": { + "arduino": { + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + ["0x239A", "0x00B3"], + ["0x239A", "0x8029"], + ["0x239A", "0x0029"], + ["0x239A", "0x002A"], + ["0x239A", "0x802A"] + ], + "usb_product": "ProMicro compatible nRF52840", + "mcu": "nrf52840", + "variant": "promicro_diy", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": ["bluetooth"], + "debug": { + "jlink_device": "nRF52840_xxAA", + "svd_path": "nrf52840.svd" + }, + "frameworks": ["arduino"], + "name": "ProMicro compatible nRF52840", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "speed": 115200, + "protocol": "nrfutil", + "protocols": ["nrfutil", "jlink", "nrfjprog", "stlink"], + "use_1200bps_touch": true, + "require_upload_port": true, + "wait_for_upload_port": true + }, + "url": "https://www.nologo.tech/product/otherboard/NRF52840.html", + "vendor": "Nologo" +} diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 3be3e7e55..68bd87801 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -54,6 +54,8 @@ #define HW_VENDOR meshtastic_HardwareModel_NRF52840_PCA10059 #elif defined(TWC_MESH_V4) #define HW_VENDOR meshtastic_HardwareModel_TWC_MESH_V4 +#elif defined(NRF52_PROMICRO_DIY) +#define HW_VENDOR meshtastic_HardwareModel_NRF52_PROMICRO_DIY #elif defined(PRIVATE_HW) || defined(FEATHER_DIY) #define HW_VENDOR meshtastic_HardwareModel_PRIVATE_HW #else diff --git a/variants/diy/nrf52_promicro_diy_tcxo/variant.cpp b/variants/diy/nrf52_promicro_diy_tcxo/variant.cpp new file mode 100644 index 000000000..4030122e5 --- /dev/null +++ b/variants/diy/nrf52_promicro_diy_tcxo/variant.cpp @@ -0,0 +1,31 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; \ No newline at end of file diff --git a/variants/diy/nrf52_promicro_diy_tcxo/variant.h b/variants/diy/nrf52_promicro_diy_tcxo/variant.h new file mode 100644 index 000000000..8b957fe12 --- /dev/null +++ b/variants/diy/nrf52_promicro_diy_tcxo/variant.h @@ -0,0 +1,154 @@ +#ifndef _VARIANT_PROMICRO_DIY_ +#define _VARIANT_PROMICRO_DIY_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +// #define USE_LFXO // Board uses 32khz crystal for LF +#define USE_LFRC // Board uses RC for LF + +#define PROMICRO_DIY_TCXO + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/* +NRF52 PRO MICRO PIN ASSIGNMENT + +| Pin | Function | | Pin | Function | +|-------|------------|---|---------|-------------| +| Gnd | | | vbat | | +| P0.06 | Serial2 RX | | vbat | | +| P0.08 | Serial2 TX | | Gnd | | +| Gnd | | | reset | | +| Gnd | | | ext_vcc | *see 0.13 | +| P0.17 | RXEN | | P0.31 | BATTERY_PIN | +| P0.20 | GPS_RX | | P0.29 | BUSY | +| P0.22 | GPS_TX | | P0.02 | MISO | +| P0.24 | GPS_EN | | P1.15 | MOSI | +| P1.00 | BUTTON_PIN | | P1.13 | CS | +| P0.11 | SCL | | P1.11 | SCK | +| P1.04 | SDA | | P0.10 | DIO1/IRQ | +| P1.06 | Free pin | | P0.09 | RESET | +| | | | | | +| | Mid board | | | Internal | +| P1.01 | Free pin | | 0.15 | LED | +| P1.02 | Free pin | | 0.13 | 3V3_EN | +| P1.07 | Free pin | | | | +*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (1) +#define NUM_ANALOG_OUTPUTS (0) + +// Pin 13 enables 3.3V periphery. If the Lora module is on this pin, then it should stay enabled at all times. +#define PIN_3V3_EN (0 + 13) // P0.13 + +// Analog pins +#define BATTERY_PIN (0 + 31) // P0.31 Battery ADC +#define ADC_CHANNEL ADC1_GPIO4_CHANNEL +#define ADC_RESOLUTION 14 +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) +#define VBAT_DIVIDER (0.6F) +// Compensation factor for the VBAT divider +#define VBAT_DIVIDER_COMP (1.73) +// Fixed calculation of milliVolt from compensation value +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP // REAL_VBAT_MV_PER_LSB +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +// WIRE IC AND IIC PINS +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (32 + 4) // P1.04 +#define PIN_WIRE_SCL (0 + 11) // P0.11 + +// LED +#define PIN_LED1 (0 + 15) // P0.15 +#define LED_BUILTIN PIN_LED1 +// Actually red +#define LED_BLUE PIN_LED1 +#define LED_STATE_ON 1 // State when LED is lit + +// Button +#define BUTTON_PIN (32 + 0) // P1.00 + +// GPS +#define PIN_GPS_TX (0 + 22) // P0.22 +#define PIN_GPS_RX (0 + 20) // P0.20 + +#define PIN_GPS_EN (0 + 24) // P0.24 +#define GPS_POWER_TOGGLE +#define GPS_UBLOX +// define GPS_DEBUG + +// UART interfaces +#define PIN_SERIAL1_RX PIN_GPS_TX +#define PIN_SERIAL1_TX PIN_GPS_RX + +#define PIN_SERIAL2_RX (0 + 6) // P0.06 +#define PIN_SERIAL2_TX (0 + 8) // P0.08 + +// Serial interfaces +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 2) // P0.02 +#define PIN_SPI_MOSI (32 + 15) // P1.15 +#define PIN_SPI_SCK (32 + 11) // P1.11 + +// LORA MODULES +#define USE_LLCC68 +#define USE_SX1262 + +// LORA CONFIG +#define SX126X_CS (32 + 13) // P1.13 FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 (0 + 10) // P0.10 IRQ +#define SX126X_DIO2_AS_RF_SWITCH // Note for E22 modules: DIO2 is not attached internally to TXEN for automatic TX/RX switching, + // so it needs connecting externally if it is used in this way +#define SX126X_BUSY (0 + 29) // P0.29 +#define SX126X_RESET (0 + 9) // P0.09 +#define SX126X_RXEN (0 + 17) // P0.17 +#define SX126X_TXEN RADIOLIB_NC // Assuming that DIO2 is connected to TXEN pin. If not, TXEN must be connected. + +/* +On the SX1262, DIO3 sets the voltage for an external TCXO, if one is present. If one is not present, then this should not be used. + +Ebyte +e22-900mm22s has no TCXO +e22-900m22s has TCXO +e220-900mm22s has no TCXO, works with/without this definition, looks like DIO3 not connected at all + +AI-thinker +RA-01SH does not have TCXO + +Waveshare +Core1262 has TCXO + +*/ +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/variants/diy/nrf52_promicro_diy_xtal/variant.cpp b/variants/diy/nrf52_promicro_diy_xtal/variant.cpp new file mode 100644 index 000000000..4030122e5 --- /dev/null +++ b/variants/diy/nrf52_promicro_diy_xtal/variant.cpp @@ -0,0 +1,31 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; \ No newline at end of file diff --git a/variants/diy/nrf52_promicro_diy_xtal/variant.h b/variants/diy/nrf52_promicro_diy_xtal/variant.h new file mode 100644 index 000000000..fd0b21681 --- /dev/null +++ b/variants/diy/nrf52_promicro_diy_xtal/variant.h @@ -0,0 +1,153 @@ +#ifndef _VARIANT_PROMICRO_DIY_ +#define _VARIANT_PROMICRO_DIY_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +// #define USE_LFXO // Board uses 32khz crystal for LF +#define USE_LFRC // Board uses RC for LF + +#define PROMICRO_DIY_XTAL +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/* +NRF52 PRO MICRO PIN ASSIGNMENT + +| Pin | Function | | Pin | Function | +|-------|------------|---|---------|-------------| +| Gnd | | | vbat | | +| P0.06 | Serial2 RX | | vbat | | +| P0.08 | Serial2 TX | | Gnd | | +| Gnd | | | reset | | +| Gnd | | | ext_vcc | *see 0.13 | +| P0.17 | RXEN | | P0.31 | BATTERY_PIN | +| P0.20 | GPS_RX | | P0.29 | BUSY | +| P0.22 | GPS_TX | | P0.02 | MISO | +| P0.24 | GPS_EN | | P1.15 | MOSI | +| P1.00 | BUTTON_PIN | | P1.13 | CS | +| P0.11 | SCL | | P1.11 | SCK | +| P1.04 | SDA | | P0.10 | DIO1/IRQ | +| P1.06 | Free pin | | P0.09 | RESET | +| | | | | | +| | Mid board | | | Internal | +| P1.01 | Free pin | | 0.15 | LED | +| P1.02 | Free pin | | 0.13 | 3V3_EN | +| P1.07 | Free pin | | | | +*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (1) +#define NUM_ANALOG_OUTPUTS (0) + +// Pin 13 enables 3.3V periphery. If the Lora module is on this pin, then it should stay enabled at all times. +#define PIN_3V3_EN (0 + 13) // P0.13 + +// Analog pins +#define BATTERY_PIN (0 + 31) // P0.31 Battery ADC +#define ADC_CHANNEL ADC1_GPIO4_CHANNEL +#define ADC_RESOLUTION 14 +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) +#define VBAT_DIVIDER (0.6F) +// Compensation factor for the VBAT divider +#define VBAT_DIVIDER_COMP (1.73) +// Fixed calculation of milliVolt from compensation value +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP // REAL_VBAT_MV_PER_LSB +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +// WIRE IC AND IIC PINS +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (32 + 4) // P1.04 +#define PIN_WIRE_SCL (0 + 11) // P0.11 + +// LED +#define PIN_LED1 (0 + 15) // P0.15 +#define LED_BUILTIN PIN_LED1 +// Actually red +#define LED_BLUE PIN_LED1 +#define LED_STATE_ON 1 // State when LED is lit + +// Button +#define BUTTON_PIN (32 + 0) // P1.00 + +// GPS +#define PIN_GPS_TX (0 + 22) // P0.22 +#define PIN_GPS_RX (0 + 20) // P0.20 + +#define PIN_GPS_EN (0 + 24) // P0.24 +#define GPS_POWER_TOGGLE +#define GPS_UBLOX +// define GPS_DEBUG + +// UART interfaces +#define PIN_SERIAL1_RX PIN_GPS_TX +#define PIN_SERIAL1_TX PIN_GPS_RX + +#define PIN_SERIAL2_RX (0 + 6) // P0.06 +#define PIN_SERIAL2_TX (0 + 8) // P0.08 + +// Serial interfaces +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 2) // P0.02 +#define PIN_SPI_MOSI (32 + 15) // P1.15 +#define PIN_SPI_SCK (32 + 11) // P1.11 + +// LORA MODULES +#define USE_LLCC68 +#define USE_SX1262 + +// LORA CONFIG +#define SX126X_CS (32 + 13) // P1.13 FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 (0 + 10) // P0.10 IRQ +#define SX126X_DIO2_AS_RF_SWITCH // Note for E22 modules: DIO2 is not attached internally to TXEN for automatic TX/RX switching, + // so it needs connecting externally if it is used in this way +#define SX126X_BUSY (0 + 29) // P0.29 +#define SX126X_RESET (0 + 9) // P0.09 +#define SX126X_RXEN (0 + 17) // P0.17 +#define SX126X_TXEN RADIOLIB_NC // Assuming that DIO2 is connected to TXEN pin. If not, TXEN must be connected. + +/* +On the SX1262, DIO3 sets the voltage for an external TCXO, if one is present. If one is not present, then this should not be used. + +Ebyte +e22-900mm22s has no TCXO +e22-900m22s has TCXO +e220-900mm22s has no TCXO, works with/without this definition, looks like DIO3 not connected at all + +AI-thinker +RA-01SH does not have TCXO + +Waveshare +Core1262 has TCXO + +*/ +// #define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index e7d72d13f..5fb0f6421 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -44,3 +44,35 @@ build_flags = ${esp32_base.build_flags} -D DIY_V1 -I variants/diy/hydra + + +; Promicro + E22(0)-xxxMM / RA-01SH modules board variant - DIY - without TCXO +[env:nrf52_promicro_diy_xtal] +extends = nrf52840_base +board = promicro-nrf52840 +board_level = extra +build_flags = ${nrf52840_base.build_flags} + -I variants/diy/nrf52_promicro_diy_xtal + -D NRF52_PROMICRO_DIY + -D OLED_RU + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/diy/nrf52_promicro_diy_xtal> +lib_deps = + ${nrf52840_base.lib_deps} +debug_tool = jlink + + +; Promicro + E22(0)-xxxM / HT-RA62 modules board variant - DIY - with TCXO +[env:nrf52_promicro_diy_tcxo] +extends = nrf52840_base +board = promicro-nrf52840 +board_level = extra +build_flags = ${nrf52840_base.build_flags} + -I variants/diy/nrf52_promicro_diy_tcxo + -D NRF52_PROMICRO_DIY + -D OLED_RU + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/diy/nrf52_promicro_diy_tcxo> +lib_deps = + ${nrf52840_base.lib_deps} +debug_tool = jlink \ No newline at end of file From 5371f134ba5ab84b1292d3b5bf8a560ea6b9187f Mon Sep 17 00:00:00 2001 From: pr000t <20946964+pr000t@users.noreply.github.com> Date: Wed, 8 May 2024 14:02:53 +0200 Subject: [PATCH 11/35] Add Sensirion SHT4X sensors (#3792) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add Sensirion SHT4X sensors * Update platformio.ini Fix lib version * Delete src/mesh/generated/meshtastic/telemetry.pb.h * Revert "Delete src/mesh/generated/meshtastic/telemetry.pb.h" This reverts commit 8e5e6a9f6ff4e31ed32775741c03a855e663a5de. * remove modification on generated file * Update ScanI2CTwoWire.cpp Fix copy/paste issue --------- Co-authored-by: Thomas Göttgens --- platformio.ini | 1 + src/configuration.h | 2 +- src/detect/ScanI2C.h | 1 + src/detect/ScanI2CTwoWire.cpp | 15 ++++- src/main.cpp | 3 +- .../Telemetry/EnvironmentTelemetry.cpp | 6 ++ src/modules/Telemetry/Sensor/SHT4XSensor.cpp | 63 +++++++++++++++++++ src/modules/Telemetry/Sensor/SHT4XSensor.h | 23 +++++++ 8 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.cpp create mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.h diff --git a/platformio.ini b/platformio.ini index a6db1c76e..9d7c76fbf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -133,3 +133,4 @@ lib_deps = https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 + https://github.com/Sensirion/arduino-i2c-sht4x#1.1.0 diff --git a/src/configuration.h b/src/configuration.h index 493449764..0d9ee5451 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -126,7 +126,7 @@ along with this program. If not, see . #define SHTC3_ADDR 0x70 #define LPS22HB_ADDR 0x5C #define LPS22HB_ADDR_ALT 0x5D -#define SHT31_ADDR 0x44 +#define SHT31_4x_ADDR 0x44 #define PMSA0031_ADDR 0x12 #define RCWL9620_ADDR 0x57 diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index 20f22040c..a53df11f3 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -29,6 +29,7 @@ class ScanI2C INA3221, MCP9808, SHT31, + SHT4X, SHTC3, LPS22HB, QMC6310, diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 562a94c1f..58d46a58d 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -292,7 +292,18 @@ void ScanI2CTwoWire::scanPort(I2CPort port) break; - SCAN_SIMPLE_CASE(SHT31_ADDR, SHT31, "SHT31 sensor found\n") + case SHT31_4x_ADDR: + registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2); + if (registerValue == 0x11a2) { + type = SHT4X; + LOG_INFO("SHT4X sensor found\n"); + } else { + type = SHT31; + LOG_INFO("SHT31 sensor found\n"); + } + + break; + SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n") SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n") @@ -357,4 +368,4 @@ TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const size_t ScanI2CTwoWire::countDevices() const { return foundDevices.size(); -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index b7bc4892b..1465cd084 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -541,6 +541,7 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620) + SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) i2cScanner.reset(); @@ -1032,4 +1033,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 93184069d..62adc9a8c 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -26,6 +26,7 @@ #include "Sensor/MCP9808Sensor.h" #include "Sensor/RCWL9620Sensor.h" #include "Sensor/SHT31Sensor.h" +#include "Sensor/SHT4XSensor.h" #include "Sensor/SHTC3Sensor.h" BMP085Sensor bmp085Sensor; @@ -36,6 +37,7 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; +SHT4XSensor sht4xSensor; RCWL9620Sensor rcwl9620Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 @@ -91,6 +93,8 @@ int32_t EnvironmentTelemetryModule::runOnce() result = lps22hbSensor.runOnce(); if (sht31Sensor.hasSensor()) result = sht31Sensor.runOnce(); + if (sht4xSensor.hasSensor()) + result = sht4xSensor.runOnce(); if (ina219Sensor.hasSensor()) result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) @@ -246,6 +250,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); + if (sht4xSensor.hasSensor()) + valid = sht4xSensor.getMetrics(&m); if (lps22hbSensor.hasSensor()) valid = lps22hbSensor.getMetrics(&m); if (shtc3Sensor.hasSensor()) diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp new file mode 100644 index 000000000..d324b7fd6 --- /dev/null +++ b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp @@ -0,0 +1,63 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "SHT4XSensor.h" +#include "TelemetrySensor.h" +#include + +// macro definitions +// make sure that we use the proper definition of NO_ERROR +#ifdef NO_ERROR +#undef NO_ERROR +#endif +#define NO_ERROR 0 + +static char errorMessage[64]; +static int16_t error; + +SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {} + +int32_t SHT4XSensor::runOnce() +{ + LOG_INFO("Init sensor: %s\n", sensorName); + if (!hasSensor()) { + return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; + } + + uint32_t serialNumber = 0; + + sht4x.begin(*nodeTelemetrySensorsMap[sensorType].second, 0x44); + + error = sht4x.serialNumber(serialNumber); + LOG_DEBUG("serialNumber : %x\n", serialNumber); + if (error != NO_ERROR) { + LOG_DEBUG("Error trying to execute serialNumber(): "); + errorToString(error, errorMessage, sizeof errorMessage); + LOG_DEBUG(errorMessage); + status = 0; + } else { + status = 1; + } + + return initI2CSensor(); +} + +void SHT4XSensor::setup() +{ + // Set up oversampling and filter initialization +} + +bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement) +{ + float aTemperature = 0.0; + float aHumidity = 0.0; + sht4x.measureLowestPrecision(aTemperature, aHumidity); + measurement->variant.environment_metrics.temperature = aTemperature; + measurement->variant.environment_metrics.relative_humidity = aHumidity; + + return true; +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.h b/src/modules/Telemetry/Sensor/SHT4XSensor.h new file mode 100644 index 000000000..67045eb2a --- /dev/null +++ b/src/modules/Telemetry/Sensor/SHT4XSensor.h @@ -0,0 +1,23 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +class SHT4XSensor : public TelemetrySensor +{ + private: + SensirionI2cSht4x sht4x; + + protected: + virtual void setup() override; + + public: + SHT4XSensor(); + virtual int32_t runOnce() override; + virtual bool getMetrics(meshtastic_Telemetry *measurement) override; +}; + +#endif \ No newline at end of file From 147de75a0295e7c8e71605d7fd007dfa222a5c12 Mon Sep 17 00:00:00 2001 From: Nicholas Baddorf <42445164+nbaddorf@users.noreply.github.com> Date: Wed, 8 May 2024 08:37:50 -0400 Subject: [PATCH 12/35] Added modifier key combination to allow keyboard shortcuts on t-deck (#3668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated kbI2cBase.cpp Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab). * Update kbI2cBase.cpp * fixed formatting issues in kbI2cBase.cpp * Removed keyboard shortcut code that doesnt work alt+t does not work on a t-deck so I removed it to avoid confusion. * Updated kbI2cBase.cpp Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab). * Update kbI2cBase.cpp * fixed formatting issues in kbI2cBase.cpp * Removed keyboard shortcut code that doesnt work alt+t does not work on a t-deck so I removed it to avoid confusion. * Changed modifier key to alt+c * Added screen brightness functionality Use modifier key with o(+) to increase brightness or i(-) to decrease. Currently there are 4 levels of brightness, (L, ML, MH, H). I would like to add a popup message to tell you the brightness. * Added checks to disable screen brightness changes on unsupported hardware * Setting the brightness code to work on only applicable devices * Added "function symbol" display to bottom right corner of screen. Now shows when mute is active or modifier key is pressed. Also fixed some other minor issues. * commented out a log * Reworked how modifier functions worked, added I wasn’t happy with my previous implementation, and I think it would have caused issues with other devices. This should work on all devices. * Added back the function I moved causing issue with versions * Fixed the version conflicts, everything seems to work fine now --------- Co-authored-by: Ben Meadors Co-authored-by: Thomas Göttgens --- src/graphics/Screen.cpp | 77 +++++++++++++++++- src/graphics/Screen.h | 13 +++- src/graphics/TFTDisplay.cpp | 8 +- src/graphics/TFTDisplay.h | 3 + src/input/kbI2cBase.cpp | 80 ++++++++++++++++++- src/modules/CannedMessageModule.cpp | 117 ++++++++++++++++++---------- variants/t-deck/variant.h | 3 +- 7 files changed, 253 insertions(+), 48 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index e5f392036..0899335e6 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -94,6 +94,11 @@ std::vector moduleFrames; // Stores the last 4 of our hardware ID, to make finding the device for pairing easier static char ourId[5]; +// vector where symbols (string) are displayed in bottom corner of display. +std::vector functionSymbals; +// string displayed in bottom right corner of display. Created from elements in functionSymbals vector +std::string functionSymbalString = ""; + #if HAS_GPS // GeoCoord object for the screen GeoCoord geoCoord; @@ -260,6 +265,18 @@ static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, i #endif } +// draw overlay in bottom right corner of screen to show when notifications are muted or modifier key is active +static void drawFunctionOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) +{ + // LOG_DEBUG("Drawing function overlay\n"); + if (functionSymbals.begin() != functionSymbals.end()) { + char buf[64]; + display->setFont(FONT_SMALL); + snprintf(buf, sizeof(buf), "%s", functionSymbalString.c_str()); + display->drawString(SCREEN_WIDTH - display->getStringWidth(buf), SCREEN_HEIGHT - FONT_HEIGHT_SMALL, buf); + } +} + #ifdef USE_EINK /// Used on eink displays while in deep sleep static void drawDeepSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) @@ -1023,7 +1040,14 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver) #if !ARCH_PORTDUINO dispdev->displayOn(); #endif + +#if defined(ST7789_CS) && \ + !defined(M5STACK) // set display brightness when turning on screens. Just moved function from TFTDisplay to here. + static_cast(dispdev)->setDisplayBrightness(brightness); +#endif + dispdev->displayOn(); + enabled = true; setInterval(0); // Draw ASAP runASAP = true; @@ -1490,6 +1514,11 @@ void Screen::setFrames() ui->setFrames(normalFrames, numframes); ui->enableAllIndicators(); + // Add function overlay here. This can show when notifications muted, modifier key is active etc + static OverlayCallback functionOverlay[] = {drawFunctionOverlay}; + static const int functionOverlayCount = sizeof(functionOverlay) / sizeof(functionOverlay[0]); + ui->setOverlays(functionOverlay, functionOverlayCount); + prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list // just changed) @@ -1573,9 +1602,55 @@ void Screen::blink() delay(50); count = count - 1; } + // The dispdev->setBrightness does not work for t-deck display, it seems to run the setBrightness function in OLEDDisplay. dispdev->setBrightness(brightness); } +void Screen::increaseBrightness() +{ + brightness = ((brightness + 62) > 254) ? brightness : (brightness + 62); + +#if defined(ST7789_CS) + // run the setDisplayBrightness function. This works on t-decks + static_cast(dispdev)->setDisplayBrightness(brightness); +#endif + + /* TO DO: add little popup in center of screen saying what brightness level it is set to*/ +} + +void Screen::decreaseBrightness() +{ + brightness = (brightness < 70) ? brightness : (brightness - 62); + +#if defined(ST7789_CS) + static_cast(dispdev)->setDisplayBrightness(brightness); +#endif + + /* TO DO: add little popup in center of screen saying what brightness level it is set to*/ +} + +void Screen::setFunctionSymbal(std::string sym) +{ + if (std::find(functionSymbals.begin(), functionSymbals.end(), sym) == functionSymbals.end()) { + functionSymbals.push_back(sym); + functionSymbalString = ""; + for (auto symbol : functionSymbals) { + functionSymbalString = symbol + " " + functionSymbalString; + } + setFastFramerate(); + } +} + +void Screen::removeFunctionSymbal(std::string sym) +{ + functionSymbals.erase(std::remove(functionSymbals.begin(), functionSymbals.end(), sym), functionSymbals.end()); + functionSymbalString = ""; + for (auto symbol : functionSymbals) { + functionSymbalString = symbol + " " + functionSymbalString; + } + setFastFramerate(); +} + std::string Screen::drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds) { std::string uptime; @@ -1998,4 +2073,4 @@ int Screen::handleInputEvent(const InputEvent *event) } // namespace graphics #else graphics::Screen::Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY) {} -#endif // HAS_SCREEN +#endif // HAS_SCREEN \ No newline at end of file diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 2cb1cd5a9..cfb08c0f4 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -166,9 +166,6 @@ class Screen : public concurrency::OSThread void showPrevFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_PREV_FRAME}); } void showNextFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_NEXT_FRAME}); } - // Implementation to Adjust Brightness - uint8_t brightness = BRIGHTNESS_DEFAULT; - /// Starts showing the Bluetooth PIN screen. // // Switches over to a static frame showing the Bluetooth pairing screen @@ -202,6 +199,13 @@ class Screen : public concurrency::OSThread enqueueCmd(cmd); } + // functions for display brightness + void increaseBrightness(); + void decreaseBrightness(); + + void setFunctionSymbal(std::string sym); + void removeFunctionSymbal(std::string sym); + /// Stops showing the bluetooth PIN screen. void stopBluetoothPinScreen() { enqueueCmd(ScreenCmd{.cmd = Cmd::STOP_BLUETOOTH_PIN_SCREEN}); } @@ -395,6 +399,9 @@ class Screen : public concurrency::OSThread // Bluetooth PIN screen) bool showingNormalScreen = false; + // Implementation to Adjust Brightness + uint8_t brightness = BRIGHTNESS_DEFAULT; // H = 254, MH = 192, ML = 130 L = 103 + /// Holds state for debug information DebugInfo debugInfo; diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 36397a826..b19e402b8 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -596,7 +596,7 @@ void TFTDisplay::sendCommand(uint8_t com) unphone.backlight(true); // using unPhone library #endif #ifdef RAK14014 -#elif !defined(M5STACK) +#elif !defined(M5STACK) && !defined(ST7789_CS) // T-Deck gets brightness set in Screen.cpp in the handleSetOn function tft->setBrightness(172); #endif break; @@ -640,6 +640,12 @@ void TFTDisplay::sendCommand(uint8_t com) // Drop all other commands to device (we just update the buffer) } +void TFTDisplay::setDisplayBrightness(uint8_t _brightness) +{ + tft->setBrightness(_brightness); + LOG_DEBUG("Brightness is set to value: %i \n", _brightness); +} + void TFTDisplay::flipScreenVertically() { #if defined(T_WATCH_S3) diff --git a/src/graphics/TFTDisplay.h b/src/graphics/TFTDisplay.h index 3d6ea6cc6..42aa3abff 100644 --- a/src/graphics/TFTDisplay.h +++ b/src/graphics/TFTDisplay.h @@ -30,6 +30,9 @@ class TFTDisplay : public OLEDDisplay static bool hasTouch(void); static bool getTouch(int16_t *x, int16_t *y); + // Functions for changing display brightness + void setDisplayBrightness(uint8_t); + /** * shim to make the abstraction happy * diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp index 74a6c718d..af7c96b20 100644 --- a/src/input/kbI2cBase.cpp +++ b/src/input/kbI2cBase.cpp @@ -1,5 +1,4 @@ #include "kbI2cBase.h" - #include "configuration.h" #include "detect/ScanI2C.h" @@ -138,6 +137,9 @@ int32_t KbI2cBase::runOnce() break; case 0x13: // Code scanner says the SYM key is 0x13 is_sym = !is_sym; + e.inputEvent = ANYKEY; + e.kbchar = + is_sym ? 0xf1 : 0xf2; // send 0xf1 to tell CannedMessages to display that the modifier key is active break; case 0x0a: // apparently Enter on Q10 is a line feed instead of carriage return e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT; @@ -193,6 +195,75 @@ int32_t KbI2cBase::runOnce() e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE; e.source = this->_originName; switch (c) { + case 0x71: // This is the button q. If modifier and q pressed, it cancels the input + if (is_sym) { + is_sym = false; + e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL; + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; + case 0x74: // letter t. if modifier and t pressed call 'tab' + if (is_sym) { + is_sym = false; + e.inputEvent = ANYKEY; + e.kbchar = 0x09; // TAB Scancode + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; + case 0x6d: // letter m. Modifier makes it mute notifications + if (is_sym) { + is_sym = false; + e.inputEvent = ANYKEY; + e.kbchar = 0xac; // mute notifications + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; + case 0x6f: // letter o(+). Modifier makes screen increase in brightness + if (is_sym) { + is_sym = false; + e.inputEvent = ANYKEY; + e.kbchar = 0x11; // Increase Brightness code + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; + case 0x69: // letter i(-). Modifier makes screen decrease in brightness + if (is_sym) { + is_sym = false; + e.inputEvent = ANYKEY; + e.kbchar = 0x12; // Decrease Brightness code + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; + case 0x20: // Space. Send network ping like double press does + if (is_sym) { + is_sym = false; + e.inputEvent = ANYKEY; + e.kbchar = 0xaf; // (fn + space) + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; + case 0x67: // letter g. toggle gps + if (is_sym) { + is_sym = false; + e.inputEvent = ANYKEY; + e.kbchar = 0x9e; + } else { + e.inputEvent = ANYKEY; + e.kbchar = c; + } + break; case 0x1b: // ESC e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL; break; @@ -216,6 +287,12 @@ int32_t KbI2cBase::runOnce() e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT; e.kbchar = 0xb7; break; + case 0xc: // Modifier key: 0xc is alt+c (Other options could be: 0xea = shift+mic button or 0x4 shift+$(speaker)) + // toggle moddifiers button. + is_sym = !is_sym; + e.inputEvent = ANYKEY; + e.kbchar = is_sym ? 0xf1 : 0xf2; // send 0xf1 to tell CannedMessages to display that the modifier key is active + break; case 0x90: // fn+r case 0x91: // fn+t case 0x9b: // fn+s @@ -239,6 +316,7 @@ int32_t KbI2cBase::runOnce() } e.inputEvent = ANYKEY; e.kbchar = c; + is_sym = false; break; } diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 8cfea154e..0f17c268b 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -180,11 +180,75 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT; } - // pass the pressed key - // LOG_DEBUG("Canned message ANYKEY (%x)\n", event->kbchar); - this->payload = event->kbchar; - this->lastTouchMillis = millis(); - validEvent = true; + + validEvent = false; // If key is normal than it will be set to true. + + // Run modifier key code below, (doesnt inturrupt typing or reset to start screen page) + switch (event->kbchar) { + case 0x11: // make screen brighter + if (screen) + screen->increaseBrightness(); + LOG_DEBUG("increasing Screen Brightness\n"); + break; + case 0x12: // make screen dimmer + if (screen) + screen->decreaseBrightness(); + LOG_DEBUG("Decreasing Screen Brightness\n"); + break; + case 0xf1: // draw modifier (function) symbal + if (screen) + screen->setFunctionSymbal("Fn"); + break; + case 0xf2: // remove modifier (function) symbal + if (screen) + screen->removeFunctionSymbal("Fn"); + break; + // mute (switch off/toggle) external notifications on fn+m + case 0xac: + if (moduleConfig.external_notification.enabled == true) { + if (externalNotificationModule->getMute()) { + externalNotificationModule->setMute(false); + showTemporaryMessage("Notifications \nEnabled"); + if (screen) + screen->removeFunctionSymbal("M"); // remove the mute symbol from the bottom right corner + } else { + externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop + externalNotificationModule->setMute(true); + showTemporaryMessage("Notifications \nDisabled"); + if (screen) + screen->setFunctionSymbal("M"); // add the mute symbol to the bottom right corner + } + } + break; + case 0x9e: // toggle GPS like triple press does +#if !MESHTASTIC_EXCLUDE_GPS + if (gps != nullptr) { + gps->toggleGpsMode(); + } + if (screen) + screen->forceDisplay(); + showTemporaryMessage("GPS Toggled"); +#endif + break; + case 0xaf: // fn+space send network ping like double press does + service.refreshLocalMeshNode(); + if (service.trySendPosition(NODENUM_BROADCAST, true)) { + showTemporaryMessage("Position \nUpdate Sent"); + } else { + showTemporaryMessage("Node Info \nUpdate Sent"); + } + break; + default: + // pass the pressed key + // LOG_DEBUG("Canned message ANYKEY (%x)\n", event->kbchar); + this->payload = event->kbchar; + this->lastTouchMillis = millis(); + validEvent = true; + break; + } + if (screen && (event->kbchar != 0xf1)) { + screen->removeFunctionSymbal("Fn"); // remove modifier (function) symbal + } } if (event->inputEvent == static_cast(MATRIXKEY)) { LOG_DEBUG("Canned message event Matrix key pressed\n"); @@ -390,8 +454,9 @@ int32_t CannedMessageModule::runOnce() } if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { e.frameChanged = true; - switch (this->payload) { - case 0x08: // backspace + switch (this->payload) { // code below all trigger the freetext window (where you type to send a message) or reset the + // display back to the default window + case 0x08: // backspace if (this->freetext.length() > 0) { if (this->cursor == this->freetext.length()) { this->freetext = this->freetext.substring(0, this->freetext.length() - 1); @@ -403,7 +468,6 @@ int32_t CannedMessageModule::runOnce() } break; case 0x09: // tab - case 0x91: // alt+t for T-Deck that doesn't have a tab key if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL) { this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; } else if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) { @@ -416,7 +480,7 @@ int32_t CannedMessageModule::runOnce() case 0xb7: // right // already handled above break; - // handle fn+s for shutdown + // handle fn+s for shutdown case 0x9b: if (screen) screen->startShutdownScreen(); @@ -430,37 +494,6 @@ int32_t CannedMessageModule::runOnce() rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000; runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; - case 0x9e: // toggle GPS like triple press does -#if !MESHTASTIC_EXCLUDE_GPS - if (gps != nullptr) { - gps->toggleGpsMode(); - } - if (screen) - screen->forceDisplay(); - showTemporaryMessage("GPS Toggled"); -#endif - break; - // mute (switch off/toggle) external notifications on fn+m - case 0xac: - if (moduleConfig.external_notification.enabled == true) { - if (externalNotificationModule->getMute()) { - externalNotificationModule->setMute(false); - showTemporaryMessage("Notifications \nEnabled"); - } else { - externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop - externalNotificationModule->setMute(true); - showTemporaryMessage("Notifications \nDisabled"); - } - } - break; - case 0xaf: // fn+space send network ping like double press does - service.refreshLocalMeshNode(); - if (service.trySendPosition(NODENUM_BROADCAST, true)) { - showTemporaryMessage("Position \nUpdate Sent"); - } else { - showTemporaryMessage("Node Info \nUpdate Sent"); - } - break; default: if (this->cursor == this->freetext.length()) { this->freetext += this->payload; @@ -476,6 +509,8 @@ int32_t CannedMessageModule::runOnce() } break; } + if (screen) + screen->removeFunctionSymbal("Fn"); } this->lastTouchMillis = millis(); @@ -787,4 +822,4 @@ String CannedMessageModule::drawWithCursor(String text, int cursor) return result; } -#endif +#endif \ No newline at end of file diff --git a/variants/t-deck/variant.h b/variants/t-deck/variant.h index 09db198ec..7efa00c82 100644 --- a/variants/t-deck/variant.h +++ b/variants/t-deck/variant.h @@ -18,6 +18,7 @@ #define TFT_OFFSET_ROTATION 0 #define SCREEN_ROTATE #define SCREEN_TRANSITION_FRAMERATE 5 +#define BRIGHTNESS_DEFAULT 130 // Medium Low Brightness #define HAS_TOUCHSCREEN 1 #define SCREEN_TOUCH_INT 16 @@ -96,4 +97,4 @@ #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 // Internally the TTGO module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface -// code) +// code) \ No newline at end of file From 75dc8cccecd52da78f1d69eeb4eb017fbc68f26c Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Thu, 9 May 2024 09:08:24 +1200 Subject: [PATCH 13/35] Button ISR runs thread asap (#3801) --- src/ButtonThread.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 4566de924..97cce7bc2 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -214,6 +214,7 @@ int32_t ButtonThread::runOnce() btnEvent = BUTTON_EVENT_NONE; } + runASAP = false; return 50; } @@ -234,6 +235,7 @@ void ButtonThread::attachButtonInterrupts() BaseType_t higherWake = 0; mainDelay.interruptFromISR(&higherWake); ButtonThread::userButton.tick(); + runASAP = true; }, CHANGE); #endif @@ -280,6 +282,7 @@ void ButtonThread::wakeOnIrq(int irq, int mode) [] { BaseType_t higherWake = 0; mainDelay.interruptFromISR(&higherWake); + runASAP = true; }, FALLING); } From 5e160b21c78927dd36134a4c6d5f7b08a0603565 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 10 May 2024 01:14:58 +1200 Subject: [PATCH 14/35] T-Echo screen and button performance (#3840) * Make button timing configurable per variant * Adjust button timing for T-Echo Easier multi-clicks for features like "toggle backlight" (4x click) * Fewer full-refreshes for T-Echo display Disables ghost pixel tracking: T-Echo ghost pixels are fairly faint. --- src/ButtonThread.cpp | 10 +++++----- src/ButtonThread.h | 15 +++++++++++++-- variants/t-echo/platformio.ini | 2 +- variants/t-echo/variant.h | 3 +++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 97cce7bc2..aaead62be 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -52,8 +52,8 @@ ButtonThread::ButtonThread() : OSThread("Button") #if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) userButton.attachClick(userButtonPressed); - userButton.setClickMs(250); - userButton.setPressMs(c_longPressTime); + userButton.setClickMs(BUTTON_CLICK_MS); + userButton.setPressMs(BUTTON_LONGPRESS_MS); userButton.setDebounceMs(1); userButton.attachDoubleClick(userButtonDoublePressed); userButton.attachMultiClick(userButtonMultiPressed, this); // Reference to instance: get click count from non-static OneButton @@ -70,8 +70,8 @@ ButtonThread::ButtonThread() : OSThread("Button") pinMode(BUTTON_PIN_ALT, INPUT_PULLUP_SENSE); #endif userButtonAlt.attachClick(userButtonPressed); - userButtonAlt.setClickMs(250); - userButtonAlt.setPressMs(c_longPressTime); + userButtonAlt.setClickMs(BUTTON_CLICK_MS); + userButtonAlt.setPressMs(BUTTON_LONGPRESS_MS); userButtonAlt.setDebounceMs(1); userButtonAlt.attachDoubleClick(userButtonDoublePressed); userButtonAlt.attachLongPressStart(userButtonPressedLongStart); @@ -80,7 +80,7 @@ ButtonThread::ButtonThread() : OSThread("Button") #ifdef BUTTON_PIN_TOUCH userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true); - userButtonTouch.setPressMs(400); + userButtonTouch.setPressMs(BUTTON_TOUCH_MS); userButtonTouch.attachLongPressStart(touchPressedLongStart); // Better handling with longpress than click? #endif diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 07c7ccff7..d7a9201a3 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -4,11 +4,22 @@ #include "concurrency/OSThread.h" #include "configuration.h" +#ifndef BUTTON_CLICK_MS +#define BUTTON_CLICK_MS 250 +#endif + +#ifndef BUTTON_LONGPRESS_MS +#define BUTTON_LONGPRESS_MS 5000 +#endif + +#ifndef BUTTON_TOUCH_MS +#define BUTTON_TOCH_MS 400 +#endif + class ButtonThread : public concurrency::OSThread { public: - static const uint32_t c_longPressTime = 5000; // shutdown after 5s - static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot + static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot enum ButtonEventType { BUTTON_EVENT_NONE, diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 9ff60be3f..c036a39a2 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -15,7 +15,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DEINK_LIMIT_FASTREFRESH=20 ; How many consecutive fast-refreshes are permitted -DEINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates - -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated +; -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo> lib_deps = diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 2abeed16d..1c263a61a 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -65,6 +65,9 @@ extern "C" { #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 +#define BUTTON_CLICK_MS 400 +#define BUTTON_TOUCH_MS 200 + /* * Analog pins */ From 0c89aff0f64d7d93321238222d27b2fb32ad4c3f Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 9 May 2024 14:56:29 -0500 Subject: [PATCH 15/35] Enable telemetry and power telemetry on the native target --- src/modules/Modules.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 15b356b05..e6c44fae6 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -45,7 +45,7 @@ #include "modules/Telemetry/AirQualityTelemetry.h" #include "modules/Telemetry/EnvironmentTelemetry.h" #endif -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY #include "modules/Telemetry/PowerTelemetry.h" #endif #ifdef ARCH_ESP32 @@ -137,7 +137,7 @@ void setupModules() #if HAS_SCREEN && !MESHTASTIC_EXCLUDE_CANNEDMESSAGES cannedMessageModule = new CannedMessageModule(); #endif -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) +#if HAS_TELEMETRY new DeviceTelemetryModule(); #endif #if HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR @@ -146,7 +146,7 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR new PowerTelemetryModule(); #endif #if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ From 5d9800b7c2c7754e91db228efd7fd73320883a14 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 9 May 2024 21:25:36 -0500 Subject: [PATCH 16/35] Revert "Add Sensirion SHT4X sensors (#3792)" (#3845) This reverts commit 5371f134ba5ab84b1292d3b5bf8a560ea6b9187f. --- platformio.ini | 1 - src/configuration.h | 2 +- src/detect/ScanI2C.h | 1 - src/detect/ScanI2CTwoWire.cpp | 15 +---- src/main.cpp | 3 +- .../Telemetry/EnvironmentTelemetry.cpp | 6 -- src/modules/Telemetry/Sensor/SHT4XSensor.cpp | 63 ------------------- src/modules/Telemetry/Sensor/SHT4XSensor.h | 23 ------- 8 files changed, 4 insertions(+), 110 deletions(-) delete mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.cpp delete mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.h diff --git a/platformio.ini b/platformio.ini index 9d7c76fbf..a6db1c76e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -133,4 +133,3 @@ lib_deps = https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 - https://github.com/Sensirion/arduino-i2c-sht4x#1.1.0 diff --git a/src/configuration.h b/src/configuration.h index 0d9ee5451..493449764 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -126,7 +126,7 @@ along with this program. If not, see . #define SHTC3_ADDR 0x70 #define LPS22HB_ADDR 0x5C #define LPS22HB_ADDR_ALT 0x5D -#define SHT31_4x_ADDR 0x44 +#define SHT31_ADDR 0x44 #define PMSA0031_ADDR 0x12 #define RCWL9620_ADDR 0x57 diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index a53df11f3..20f22040c 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -29,7 +29,6 @@ class ScanI2C INA3221, MCP9808, SHT31, - SHT4X, SHTC3, LPS22HB, QMC6310, diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 58d46a58d..562a94c1f 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -292,18 +292,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port) break; - case SHT31_4x_ADDR: - registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2); - if (registerValue == 0x11a2) { - type = SHT4X; - LOG_INFO("SHT4X sensor found\n"); - } else { - type = SHT31; - LOG_INFO("SHT31 sensor found\n"); - } - - break; - + SCAN_SIMPLE_CASE(SHT31_ADDR, SHT31, "SHT31 sensor found\n") SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n") SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n") @@ -368,4 +357,4 @@ TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const size_t ScanI2CTwoWire::countDevices() const { return foundDevices.size(); -} +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1465cd084..b7bc4892b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -541,7 +541,6 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620) - SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) i2cScanner.reset(); @@ -1033,4 +1032,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} \ No newline at end of file +} diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 62adc9a8c..93184069d 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -26,7 +26,6 @@ #include "Sensor/MCP9808Sensor.h" #include "Sensor/RCWL9620Sensor.h" #include "Sensor/SHT31Sensor.h" -#include "Sensor/SHT4XSensor.h" #include "Sensor/SHTC3Sensor.h" BMP085Sensor bmp085Sensor; @@ -37,7 +36,6 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; -SHT4XSensor sht4xSensor; RCWL9620Sensor rcwl9620Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 @@ -93,8 +91,6 @@ int32_t EnvironmentTelemetryModule::runOnce() result = lps22hbSensor.runOnce(); if (sht31Sensor.hasSensor()) result = sht31Sensor.runOnce(); - if (sht4xSensor.hasSensor()) - result = sht4xSensor.runOnce(); if (ina219Sensor.hasSensor()) result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) @@ -250,8 +246,6 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); - if (sht4xSensor.hasSensor()) - valid = sht4xSensor.getMetrics(&m); if (lps22hbSensor.hasSensor()) valid = lps22hbSensor.getMetrics(&m); if (shtc3Sensor.hasSensor()) diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp deleted file mode 100644 index d324b7fd6..000000000 --- a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "configuration.h" - -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR - -#include "../mesh/generated/meshtastic/telemetry.pb.h" -#include "SHT4XSensor.h" -#include "TelemetrySensor.h" -#include - -// macro definitions -// make sure that we use the proper definition of NO_ERROR -#ifdef NO_ERROR -#undef NO_ERROR -#endif -#define NO_ERROR 0 - -static char errorMessage[64]; -static int16_t error; - -SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {} - -int32_t SHT4XSensor::runOnce() -{ - LOG_INFO("Init sensor: %s\n", sensorName); - if (!hasSensor()) { - return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; - } - - uint32_t serialNumber = 0; - - sht4x.begin(*nodeTelemetrySensorsMap[sensorType].second, 0x44); - - error = sht4x.serialNumber(serialNumber); - LOG_DEBUG("serialNumber : %x\n", serialNumber); - if (error != NO_ERROR) { - LOG_DEBUG("Error trying to execute serialNumber(): "); - errorToString(error, errorMessage, sizeof errorMessage); - LOG_DEBUG(errorMessage); - status = 0; - } else { - status = 1; - } - - return initI2CSensor(); -} - -void SHT4XSensor::setup() -{ - // Set up oversampling and filter initialization -} - -bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement) -{ - float aTemperature = 0.0; - float aHumidity = 0.0; - sht4x.measureLowestPrecision(aTemperature, aHumidity); - measurement->variant.environment_metrics.temperature = aTemperature; - measurement->variant.environment_metrics.relative_humidity = aHumidity; - - return true; -} - -#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.h b/src/modules/Telemetry/Sensor/SHT4XSensor.h deleted file mode 100644 index 67045eb2a..000000000 --- a/src/modules/Telemetry/Sensor/SHT4XSensor.h +++ /dev/null @@ -1,23 +0,0 @@ -#include "configuration.h" - -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR - -#include "../mesh/generated/meshtastic/telemetry.pb.h" -#include "TelemetrySensor.h" -#include - -class SHT4XSensor : public TelemetrySensor -{ - private: - SensirionI2cSht4x sht4x; - - protected: - virtual void setup() override; - - public: - SHT4XSensor(); - virtual int32_t runOnce() override; - virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; - -#endif \ No newline at end of file From 676319a9ca6c989ba6bfa5cac0bd0cce58a483e4 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 10 May 2024 04:36:20 -0500 Subject: [PATCH 17/35] Implement chunked SPI transfer for ch341 (#3847) This seems to fix the ch341 quirk where large packets fail to send. As it can be problematic for other radios, we gate it behind "ch341_quirk" in the config. --- bin/config-dist.yaml | 2 ++ src/main.cpp | 6 +++-- src/mesh/RadioLibInterface.cpp | 28 ++++++++++++++++++++++-- src/mesh/RadioLibInterface.h | 12 ++++++++-- src/platform/portduino/PortduinoGlue.cpp | 1 + src/platform/portduino/PortduinoGlue.h | 1 + 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml index 05b4a7b0a..333d6eadc 100644 --- a/bin/config-dist.yaml +++ b/bin/config-dist.yaml @@ -52,6 +52,8 @@ Lora: # TXen: x # TX and RX enable pins # RXen: x +# ch341_quirk: true # Uncomment this to use the chunked SPI transfer that seems to fix the ch341 + ### Set gpio chip to use in /dev/. Defaults to 0. ### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4 # gpiochip: 4 diff --git a/src/main.cpp b/src/main.cpp index b7bc4892b..7814ea596 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -738,7 +738,8 @@ void setup() if (settingsMap[use_sx1262]) { if (!rIf) { LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); + LockingArduinoHal *RadioLibHAL = + new LockingArduinoHal(SPI, spiSettings, (settingsMap[ch341Quirk] ? settingsMap[busy] : RADIOLIB_NC)); rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -752,7 +753,8 @@ void setup() } else if (settingsMap[use_rf95]) { if (!rIf) { LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); + LockingArduinoHal *RadioLibHAL = + new LockingArduinoHal(SPI, spiSettings, (settingsMap[ch341Quirk] ? settingsMap[busy] : RADIOLIB_NC)); rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index fc1563ee3..a4ceac9f1 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -25,7 +25,31 @@ void LockingArduinoHal::spiEndTransaction() #if ARCH_PORTDUINO void LockingArduinoHal::spiTransfer(uint8_t *out, size_t len, uint8_t *in) { - spi->transfer(out, in, len); + if (busy == RADIOLIB_NC) { + spi->transfer(out, in, len); + } else { + uint16_t offset = 0; + + while (len) { + uint8_t block_size = (len < 20 ? len : 20); + spi->transfer((out != NULL ? out + offset : NULL), (in != NULL ? in + offset : NULL), block_size); + if (block_size == len) + return; + + // ensure GPIO is low + + uint32_t start = millis(); + while (digitalRead(busy)) { + if (millis() - start >= 2000) { + LOG_ERROR("GPIO mid-transfer timeout, is it connected?"); + return; + } + } + + offset += block_size; + len -= block_size; + } + } } #endif @@ -414,4 +438,4 @@ void RadioLibInterface::startSend(meshtastic_MeshPacket *txp) // bits enableInterrupt(isrTxLevel0); } -} +} \ No newline at end of file diff --git a/src/mesh/RadioLibInterface.h b/src/mesh/RadioLibInterface.h index 62720cfc9..2c841a19e 100644 --- a/src/mesh/RadioLibInterface.h +++ b/src/mesh/RadioLibInterface.h @@ -21,12 +21,20 @@ class LockingArduinoHal : public ArduinoHal { public: - LockingArduinoHal(SPIClass &spi, SPISettings spiSettings) : ArduinoHal(spi, spiSettings){}; + LockingArduinoHal(SPIClass &spi, SPISettings spiSettings, RADIOLIB_PIN_TYPE _busy = RADIOLIB_NC) + : ArduinoHal(spi, spiSettings) + { +#if ARCH_PORTDUINO + busy = _busy; +#endif + }; void spiBeginTransaction() override; void spiEndTransaction() override; #if ARCH_PORTDUINO + RADIOLIB_PIN_TYPE busy; void spiTransfer(uint8_t *out, size_t len, uint8_t *in) override; + #endif }; @@ -179,4 +187,4 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified virtual void addReceiveMetadata(meshtastic_MeshPacket *mp) = 0; virtual void setStandby() = 0; -}; +}; \ No newline at end of file diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 7c5086ac2..4077a27bc 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -168,6 +168,7 @@ void portduinoSetup() settingsMap[txen] = yamlConfig["Lora"]["TXen"].as(RADIOLIB_NC); settingsMap[rxen] = yamlConfig["Lora"]["RXen"].as(RADIOLIB_NC); settingsMap[gpiochip] = yamlConfig["Lora"]["gpiochip"].as(0); + settingsMap[ch341Quirk] = yamlConfig["Lora"]["ch341_quirk"].as(false); gpioChipName += std::to_string(settingsMap[gpiochip]); settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as("spidev0.0"); diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 995793a21..ca935ea3b 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -11,6 +11,7 @@ enum configNames { rxen, dio2_as_rf_switch, dio3_tcxo_voltage, + ch341Quirk, use_rf95, use_sx1280, use_sx1268, From ac22a503de4ace307d5fcf86681fd43a7fe809af Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 10 May 2024 07:13:12 -0500 Subject: [PATCH 18/35] Revert "Revert "Add Sensirion SHT4X sensors (#3792)" (#3845)" (#3850) This reverts commit 5d9800b7c2c7754e91db228efd7fd73320883a14. --- platformio.ini | 1 + src/configuration.h | 2 +- src/detect/ScanI2C.h | 1 + src/detect/ScanI2CTwoWire.cpp | 15 ++++- src/main.cpp | 3 +- .../Telemetry/EnvironmentTelemetry.cpp | 6 ++ src/modules/Telemetry/Sensor/SHT4XSensor.cpp | 63 +++++++++++++++++++ src/modules/Telemetry/Sensor/SHT4XSensor.h | 23 +++++++ 8 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.cpp create mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.h diff --git a/platformio.ini b/platformio.ini index a6db1c76e..9d7c76fbf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -133,3 +133,4 @@ lib_deps = https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 + https://github.com/Sensirion/arduino-i2c-sht4x#1.1.0 diff --git a/src/configuration.h b/src/configuration.h index 493449764..0d9ee5451 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -126,7 +126,7 @@ along with this program. If not, see . #define SHTC3_ADDR 0x70 #define LPS22HB_ADDR 0x5C #define LPS22HB_ADDR_ALT 0x5D -#define SHT31_ADDR 0x44 +#define SHT31_4x_ADDR 0x44 #define PMSA0031_ADDR 0x12 #define RCWL9620_ADDR 0x57 diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index 20f22040c..a53df11f3 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -29,6 +29,7 @@ class ScanI2C INA3221, MCP9808, SHT31, + SHT4X, SHTC3, LPS22HB, QMC6310, diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 562a94c1f..58d46a58d 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -292,7 +292,18 @@ void ScanI2CTwoWire::scanPort(I2CPort port) break; - SCAN_SIMPLE_CASE(SHT31_ADDR, SHT31, "SHT31 sensor found\n") + case SHT31_4x_ADDR: + registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2); + if (registerValue == 0x11a2) { + type = SHT4X; + LOG_INFO("SHT4X sensor found\n"); + } else { + type = SHT31; + LOG_INFO("SHT31 sensor found\n"); + } + + break; + SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n") SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n") @@ -357,4 +368,4 @@ TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const size_t ScanI2CTwoWire::countDevices() const { return foundDevices.size(); -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index 7814ea596..93c6ef38f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -541,6 +541,7 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620) + SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) i2cScanner.reset(); @@ -1034,4 +1035,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 93184069d..62adc9a8c 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -26,6 +26,7 @@ #include "Sensor/MCP9808Sensor.h" #include "Sensor/RCWL9620Sensor.h" #include "Sensor/SHT31Sensor.h" +#include "Sensor/SHT4XSensor.h" #include "Sensor/SHTC3Sensor.h" BMP085Sensor bmp085Sensor; @@ -36,6 +37,7 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; +SHT4XSensor sht4xSensor; RCWL9620Sensor rcwl9620Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 @@ -91,6 +93,8 @@ int32_t EnvironmentTelemetryModule::runOnce() result = lps22hbSensor.runOnce(); if (sht31Sensor.hasSensor()) result = sht31Sensor.runOnce(); + if (sht4xSensor.hasSensor()) + result = sht4xSensor.runOnce(); if (ina219Sensor.hasSensor()) result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) @@ -246,6 +250,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); + if (sht4xSensor.hasSensor()) + valid = sht4xSensor.getMetrics(&m); if (lps22hbSensor.hasSensor()) valid = lps22hbSensor.getMetrics(&m); if (shtc3Sensor.hasSensor()) diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp new file mode 100644 index 000000000..d324b7fd6 --- /dev/null +++ b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp @@ -0,0 +1,63 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "SHT4XSensor.h" +#include "TelemetrySensor.h" +#include + +// macro definitions +// make sure that we use the proper definition of NO_ERROR +#ifdef NO_ERROR +#undef NO_ERROR +#endif +#define NO_ERROR 0 + +static char errorMessage[64]; +static int16_t error; + +SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {} + +int32_t SHT4XSensor::runOnce() +{ + LOG_INFO("Init sensor: %s\n", sensorName); + if (!hasSensor()) { + return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; + } + + uint32_t serialNumber = 0; + + sht4x.begin(*nodeTelemetrySensorsMap[sensorType].second, 0x44); + + error = sht4x.serialNumber(serialNumber); + LOG_DEBUG("serialNumber : %x\n", serialNumber); + if (error != NO_ERROR) { + LOG_DEBUG("Error trying to execute serialNumber(): "); + errorToString(error, errorMessage, sizeof errorMessage); + LOG_DEBUG(errorMessage); + status = 0; + } else { + status = 1; + } + + return initI2CSensor(); +} + +void SHT4XSensor::setup() +{ + // Set up oversampling and filter initialization +} + +bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement) +{ + float aTemperature = 0.0; + float aHumidity = 0.0; + sht4x.measureLowestPrecision(aTemperature, aHumidity); + measurement->variant.environment_metrics.temperature = aTemperature; + measurement->variant.environment_metrics.relative_humidity = aHumidity; + + return true; +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.h b/src/modules/Telemetry/Sensor/SHT4XSensor.h new file mode 100644 index 000000000..67045eb2a --- /dev/null +++ b/src/modules/Telemetry/Sensor/SHT4XSensor.h @@ -0,0 +1,23 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +class SHT4XSensor : public TelemetrySensor +{ + private: + SensirionI2cSht4x sht4x; + + protected: + virtual void setup() override; + + public: + SHT4XSensor(); + virtual int32_t runOnce() override; + virtual bool getMetrics(meshtastic_Telemetry *measurement) override; +}; + +#endif \ No newline at end of file From f06c56a51be7acf11eab4f3d4f59807e4936143e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 10 May 2024 07:14:28 -0500 Subject: [PATCH 19/35] Removing release build type due to huge amount of flash utilization --- arch/nrf52/nrf52.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 0669a31e8..6c6bd8738 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -3,7 +3,7 @@ platform = platformio/nordicnrf52@^10.4.0 extends = arduino_base -build_type = release +build_type = debug build_flags = ${arduino_base.build_flags} -DSERIAL_BUFFER_SIZE=1024 From 69d765622f74d8415eb0fe4b794ebf621a0ae384 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 08:16:49 -0500 Subject: [PATCH 20/35] [create-pull-request] automated change (#3846) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index a7a7fb1bd..69761c0ac 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 9 +build = 10 From 58484d7fe5b6fe7e52a866670ef717f95b03a980 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Sat, 11 May 2024 02:10:23 +0200 Subject: [PATCH 21/35] .github: add Linux Native and other as platform to Feature Request --- .github/ISSUE_TEMPLATE/feature.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 2b6ffce0a..91f52860e 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -16,6 +16,8 @@ body: options: - NRF52 - ESP32 + - Linux Native + - other validations: required: true - type: textarea From 86b14793de79060a450a9571230942f3a7fa721a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 11 May 2024 09:46:39 +0200 Subject: [PATCH 22/35] add optional define DEBUG_MUTE This shaves roughly 60k from firmware builds by not including the Logging Ressource strings. Define in variant.h or architecture.h Stats from T-ECHO compiles: Before: Flash: [======== ] 81.5% (used 664700 bytes from 815104 bytes) After: Flash: [======= ] 74.5% (used 606924 bytes from 815104 bytes) --- src/DebugConfiguration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index f0686b811..ca908197e 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -36,7 +36,7 @@ #define LOG_CRIT(...) SEGGER_RTT_printf(0, __VA_ARGS__) #define LOG_TRACE(...) SEGGER_RTT_printf(0, __VA_ARGS__) #else -#ifdef DEBUG_PORT +#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE) #define LOG_DEBUG(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_DEBUG, __VA_ARGS__) #define LOG_INFO(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_INFO, __VA_ARGS__) #define LOG_WARN(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_WARN, __VA_ARGS__) From 38347fa6db4a51338d8573a9aba028689d7e0d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 11 May 2024 10:03:13 +0200 Subject: [PATCH 23/35] exclude serial module for T-Echo, saves 3000 bytes --- variants/t-echo/variant.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 1c263a61a..a1166a19c 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -206,6 +206,9 @@ External serial flash WP25R1635FZUIL0 // To debug via the segger JLINK console rather than the CDC-ACM serial device // #define USE_SEGGER +// T-Echo does not have a free serial port for this module +#define MESHTASTIC_EXCLUDE_SERIAL 1 + // Battery // The battery sense is hooked to pin A0 (4) // it is defined in the anlaolgue pin section of this file From 3b6ce29cca8362b50ad349a37761171efde6215b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 11 May 2024 10:05:03 +0200 Subject: [PATCH 24/35] add the now common RP2040 --- .github/ISSUE_TEMPLATE/feature.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 91f52860e..b027a36cc 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -16,6 +16,7 @@ body: options: - NRF52 - ESP32 + - RP2040 - Linux Native - other validations: From d8d831b27aee53e67cedb11cef177d37c2c4af2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 11 May 2024 14:19:53 +0200 Subject: [PATCH 25/35] Revert "exclude serial module for T-Echo, saves 3000 bytes" This reverts commit 38347fa6db4a51338d8573a9aba028689d7e0d54. --- variants/t-echo/variant.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index a1166a19c..1c263a61a 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -206,9 +206,6 @@ External serial flash WP25R1635FZUIL0 // To debug via the segger JLINK console rather than the CDC-ACM serial device // #define USE_SEGGER -// T-Echo does not have a free serial port for this module -#define MESHTASTIC_EXCLUDE_SERIAL 1 - // Battery // The battery sense is hooked to pin A0 (4) // it is defined in the anlaolgue pin section of this file From 96b5bd2fd0d432c0c2412533c82cd47e10f3a4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 11 May 2024 15:20:11 +0200 Subject: [PATCH 26/35] unphone has a display, don't default BLE PIN to 123456 (#3865) fixes #3822 --- src/mesh/NodeDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 8cbeb8dd4..b79911a3e 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -273,7 +273,7 @@ void NodeDB::installDefaultConfig() // FIXME: Default to bluetooth capability of platform as default config.bluetooth.enabled = true; config.bluetooth.fixed_pin = defaultBLEPin; -#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7789_CS) +#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7789_CS) || defined(HX8357_CS) bool hasScreen = true; #elif ARCH_PORTDUINO bool hasScreen = false; From 5de0c71a3e20ae3b8bc66563dd81a9bedc42bed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 12 May 2024 02:50:54 +0200 Subject: [PATCH 27/35] add bobricius tracksenger variants (#3866) --- variants/tracksenger/internal/pins_arduino.h | 80 +++++++++++++ variants/tracksenger/internal/variant.h | 90 +++++++++++++++ variants/tracksenger/lcd/pins_arduino.h | 80 +++++++++++++ variants/tracksenger/lcd/variant.h | 114 +++++++++++++++++++ variants/tracksenger/oled/pins_arduino.h | 80 +++++++++++++ variants/tracksenger/oled/variant.h | 92 +++++++++++++++ variants/tracksenger/platformio.ini | 40 +++++++ 7 files changed, 576 insertions(+) create mode 100644 variants/tracksenger/internal/pins_arduino.h create mode 100644 variants/tracksenger/internal/variant.h create mode 100644 variants/tracksenger/lcd/pins_arduino.h create mode 100644 variants/tracksenger/lcd/variant.h create mode 100644 variants/tracksenger/oled/pins_arduino.h create mode 100644 variants/tracksenger/oled/variant.h create mode 100644 variants/tracksenger/platformio.ini diff --git a/variants/tracksenger/internal/pins_arduino.h b/variants/tracksenger/internal/pins_arduino.h new file mode 100644 index 000000000..5c0b529b0 --- /dev/null +++ b/variants/tracksenger/internal/pins_arduino.h @@ -0,0 +1,80 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define WIFI_LoRa_32_V3 true +#define DISPLAY_HEIGHT 80 +#define DISPLAY_WIDTH 160 + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +static const uint8_t LED_BUILTIN = 18; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 45; +static const uint8_t SCL = 46; + +static const uint8_t SS = 8; +static const uint8_t MOSI = 10; +static const uint8_t MISO = 11; +static const uint8_t SCK = 9; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +static const uint8_t Vext = 36; +static const uint8_t LED = 18; + +static const uint8_t RST_LoRa = 12; +static const uint8_t BUSY_LoRa = 13; +static const uint8_t DIO0 = 14; + +#endif /* Pins_Arduino_h */ diff --git a/variants/tracksenger/internal/variant.h b/variants/tracksenger/internal/variant.h new file mode 100644 index 000000000..e63cecd7b --- /dev/null +++ b/variants/tracksenger/internal/variant.h @@ -0,0 +1,90 @@ +#define LED_PIN 18 + +#define HELTEC_TRACKER_V1_X + +// TRACKSENGER builtin LCD + +// I2C +#define I2C_SDA SDA +#define I2C_SCL SCL + +// ST7735S TFT LCD +#define ST7735S 1 // there are different (sub-)versions of ST7735 +#define ST7735_CS 38 +#define ST7735_RS 40 // DC +#define ST7735_SDA 42 // MOSI +#define ST7735_SCK 41 +#define ST7735_RESET 39 +#define ST7735_MISO -1 +#define ST7735_BUSY -1 +#define ST7735_BL_V05 21 /* V1.1 PCB marking */ +#define ST7735_SPI_HOST SPI3_HOST +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 16000000 +#define SCREEN_ROTATE +#define TFT_HEIGHT DISPLAY_WIDTH +#define TFT_WIDTH DISPLAY_HEIGHT +#define TFT_OFFSET_X 26 +#define TFT_OFFSET_Y -1 +#define SCREEN_TRANSITION_FRAMERATE 3 // fps +#define DISPLAY_FORCE_SMALL_FONTS + +#define VEXT_ENABLE_V05 3 // active HIGH, powers the lora antenna boost +#define BUTTON_PIN 0 + +#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider +#define ADC_MULTIPLIER 4.9 +#define ADC_CTRL 2 // active HIGH, powers the voltage divider. Only on 1.1 +#define ADC_CTRL_ENABLED HIGH + +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 33 +#define GPS_TX_PIN 34 +#define PIN_GPS_RESET 35 +#define PIN_GPS_PPS 36 + +#define GPS_RESET_MODE LOW +#define GPS_UC6580 + +#define USE_SX1262 +#define LORA_DIO0 -1 // a No connect on the SX1262 module +#define LORA_RESET 12 +#define LORA_DIO1 14 // SX1262 IRQ +#define LORA_DIO2 13 // SX1262 BUSY +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled + +#define LORA_SCK 9 +#define LORA_MISO 11 +#define LORA_MOSI 10 +#define LORA_CS 8 + +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET + +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +// Picomputer gets a white on black display +#define TFT_MESH COLOR565(0xFF, 0xFF, 0xFF) + +// keyboard changes + +#define PIN_BUZZER 43 +#define CANNED_MESSAGE_MODULE_ENABLE 1 + +#define INPUTBROKER_MATRIX_TYPE 1 + +#define KEYS_COLS \ + { \ + 44, 45, 46, 4, 5, 6 \ + } +#define KEYS_ROWS \ + { \ + 26, 37, 17, 16, 15, 7 \ + } +// #end keyboard \ No newline at end of file diff --git a/variants/tracksenger/lcd/pins_arduino.h b/variants/tracksenger/lcd/pins_arduino.h new file mode 100644 index 000000000..5c0b529b0 --- /dev/null +++ b/variants/tracksenger/lcd/pins_arduino.h @@ -0,0 +1,80 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define WIFI_LoRa_32_V3 true +#define DISPLAY_HEIGHT 80 +#define DISPLAY_WIDTH 160 + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +static const uint8_t LED_BUILTIN = 18; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 45; +static const uint8_t SCL = 46; + +static const uint8_t SS = 8; +static const uint8_t MOSI = 10; +static const uint8_t MISO = 11; +static const uint8_t SCK = 9; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +static const uint8_t Vext = 36; +static const uint8_t LED = 18; + +static const uint8_t RST_LoRa = 12; +static const uint8_t BUSY_LoRa = 13; +static const uint8_t DIO0 = 14; + +#endif /* Pins_Arduino_h */ diff --git a/variants/tracksenger/lcd/variant.h b/variants/tracksenger/lcd/variant.h new file mode 100644 index 000000000..0f3423d52 --- /dev/null +++ b/variants/tracksenger/lcd/variant.h @@ -0,0 +1,114 @@ +#define LED_PIN 18 + +#define HELTEC_TRACKER_V1_X + +// TRACKSENGER 2.8" IPS 320x240 + +// I2C +// #define I2C_SDA 42 +// #define I2C_SCL 41 +// #define HAS_SCREEN 1 +// #define USE_SSD1306 + +// Default SPI1 will be mapped to the display +#define ST7789_SDA 42 +#define ST7789_SCK 41 +#define ST7789_CS 38 +#define ST7789_RS 40 +#define ST7789_BL 21 +// P#define ST7735_BL_V05 21 /* V1.1 PCB marking */ + +#define ST7789_RESET -1 +#define ST7789_MISO -1 +#define ST7789_BUSY -1 +#define ST7789_SPI_HOST SPI3_HOST +#define ST7789_BACKLIGHT_EN 21 +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 16000000 +#define TFT_HEIGHT 320 +#define TFT_WIDTH 240 +#define TFT_OFFSET_X 0 +#define TFT_OFFSET_Y 0 +#define TFT_OFFSET_ROTATION 0 +#define SCREEN_ROTATE + +// ST7735S TFT LCD +// #define ST7735S 1 // there are different (sub-)versions of ST7735 +// #define ST7735_CS 38 +// #define ST7735_RS 40 // DC +// #define ST7735_SDA 42 // MOSI +// #define ST7735_SCK 41 +// #define ST7735_RESET 39 +// #define ST7735_MISO -1 +// #define ST7735_BUSY -1 +#define ST7735_BL_V05 21 /* V1.1 PCB marking */ +// #define ST7735_SPI_HOST SPI3_HOST +// #define SPI_FREQUENCY 40000000 +// #define SPI_READ_FREQUENCY 16000000 +// #define SCREEN_ROTATE +// #define TFT_HEIGHT DISPLAY_WIDTH +// #define TFT_WIDTH DISPLAY_HEIGHT +// #define TFT_OFFSET_X 26 +// #define TFT_OFFSET_Y -1 +#define SCREEN_TRANSITION_FRAMERATE 3 // fps +// #define DISPLAY_FORCE_SMALL_FONTS + +#define VEXT_ENABLE_V05 3 // active HIGH, powers the lora antenna boost +#define BUTTON_PIN 0 + +#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider +#define ADC_MULTIPLIER 4.9 +#define ADC_CTRL 2 // active HIGH, powers the voltage divider. Only on 1.1 +#define ADC_CTRL_ENABLED HIGH + +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 33 +#define GPS_TX_PIN 34 +#define PIN_GPS_RESET 35 +#define PIN_GPS_PPS 36 + +#define GPS_RESET_MODE LOW +#define GPS_UC6580 + +#define USE_SX1262 +#define LORA_DIO0 -1 // a No connect on the SX1262 module +#define LORA_RESET 12 +#define LORA_DIO1 14 // SX1262 IRQ +#define LORA_DIO2 13 // SX1262 BUSY +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled + +#define LORA_SCK 9 +#define LORA_MISO 11 +#define LORA_MOSI 10 +#define LORA_CS 8 + +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET + +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +// Picomputer gets a white on black display +#define TFT_MESH COLOR565(0xFF, 0xFF, 0xFF) + +// keyboard changes + +#define PIN_BUZZER 43 +#define CANNED_MESSAGE_MODULE_ENABLE 1 + +#define INPUTBROKER_MATRIX_TYPE 1 + +#define KEYS_COLS \ + { \ + 44, 45, 46, 4, 5, 6 \ + } +#define KEYS_ROWS \ + { \ + 26, 37, 17, 16, 15, 7 \ + } +// #end keyboard \ No newline at end of file diff --git a/variants/tracksenger/oled/pins_arduino.h b/variants/tracksenger/oled/pins_arduino.h new file mode 100644 index 000000000..5c0b529b0 --- /dev/null +++ b/variants/tracksenger/oled/pins_arduino.h @@ -0,0 +1,80 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define WIFI_LoRa_32_V3 true +#define DISPLAY_HEIGHT 80 +#define DISPLAY_WIDTH 160 + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +static const uint8_t LED_BUILTIN = 18; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 45; +static const uint8_t SCL = 46; + +static const uint8_t SS = 8; +static const uint8_t MOSI = 10; +static const uint8_t MISO = 11; +static const uint8_t SCK = 9; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +static const uint8_t Vext = 36; +static const uint8_t LED = 18; + +static const uint8_t RST_LoRa = 12; +static const uint8_t BUSY_LoRa = 13; +static const uint8_t DIO0 = 14; + +#endif /* Pins_Arduino_h */ diff --git a/variants/tracksenger/oled/variant.h b/variants/tracksenger/oled/variant.h new file mode 100644 index 000000000..d6bacf139 --- /dev/null +++ b/variants/tracksenger/oled/variant.h @@ -0,0 +1,92 @@ +#define LED_PIN 18 + +#define HELTEC_TRACKER_V1_X + +// TRACKSENGER 2.42" I2C OLED + +// I2C +#define I2C_SDA 42 +#define I2C_SCL 41 +#define HAS_SCREEN 1 +#define USE_SSD1306 + +// ST7735S TFT LCD +// #define ST7735S 1 // there are different (sub-)versions of ST7735 +// #define ST7735_CS 38 +// #define ST7735_RS 40 // DC +// #define ST7735_SDA 42 // MOSI +// #define ST7735_SCK 41 +// #define ST7735_RESET 39 +// #define ST7735_MISO -1 +// #define ST7735_BUSY -1 +#define ST7735_BL_V05 21 /* V1.1 PCB marking */ +// #define ST7735_SPI_HOST SPI3_HOST +// #define SPI_FREQUENCY 40000000 +// #define SPI_READ_FREQUENCY 16000000 +// #define SCREEN_ROTATE +// #define TFT_HEIGHT DISPLAY_WIDTH +// #define TFT_WIDTH DISPLAY_HEIGHT +// #define TFT_OFFSET_X 26 +// #define TFT_OFFSET_Y -1 +#define SCREEN_TRANSITION_FRAMERATE 3 // fps +// #define DISPLAY_FORCE_SMALL_FONTS + +#define VEXT_ENABLE_V05 3 // active HIGH, powers the lora antenna boost +#define BUTTON_PIN 0 + +#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider +#define ADC_MULTIPLIER 4.9 +#define ADC_CTRL 2 // active HIGH, powers the voltage divider. Only on 1.1 +#define ADC_CTRL_ENABLED HIGH + +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 33 +#define GPS_TX_PIN 34 +#define PIN_GPS_RESET 35 +#define PIN_GPS_PPS 36 + +#define GPS_RESET_MODE LOW +#define GPS_UC6580 + +#define USE_SX1262 +#define LORA_DIO0 -1 // a No connect on the SX1262 module +#define LORA_RESET 12 +#define LORA_DIO1 14 // SX1262 IRQ +#define LORA_DIO2 13 // SX1262 BUSY +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled + +#define LORA_SCK 9 +#define LORA_MISO 11 +#define LORA_MOSI 10 +#define LORA_CS 8 + +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET + +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +// Picomputer gets a white on black display +#define TFT_MESH COLOR565(0xFF, 0xFF, 0xFF) + +// keyboard changes + +#define PIN_BUZZER 43 +#define CANNED_MESSAGE_MODULE_ENABLE 1 + +#define INPUTBROKER_MATRIX_TYPE 1 + +#define KEYS_COLS \ + { \ + 44, 45, 46, 4, 5, 6 \ + } +#define KEYS_ROWS \ + { \ + 26, 37, 17, 16, 15, 7 \ + } +// #end keyboard \ No newline at end of file diff --git a/variants/tracksenger/platformio.ini b/variants/tracksenger/platformio.ini new file mode 100644 index 000000000..d3e31264f --- /dev/null +++ b/variants/tracksenger/platformio.ini @@ -0,0 +1,40 @@ +[env:tracksenger] +extends = esp32s3_base +board = heltec_wireless_tracker +upload_protocol = esp-builtin + +build_flags = + ${esp32s3_base.build_flags} -I variants/tracksenger/internal + -D HELTEC_TRACKER_V1_1 + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output + +lib_deps = + ${esp32s3_base.lib_deps} + lovyan03/LovyanGFX@^1.1.8 + +[env:tracksenger-lcd] +extends = esp32s3_base +board = heltec_wireless_tracker +upload_protocol = esp-builtin + +build_flags = + ${esp32s3_base.build_flags} -I variants/tracksenger/lcd + -D HELTEC_TRACKER_V1_1 + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output + +lib_deps = + ${esp32s3_base.lib_deps} + lovyan03/LovyanGFX@^1.1.8 + +[env:tracksenger-oled] +extends = esp32s3_base +board = heltec_wireless_tracker +upload_protocol = esp-builtin + +build_flags = + ${esp32s3_base.build_flags} -I variants/tracksenger/oled + -D HELTEC_TRACKER_V1_1 + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output From 859fd7c25110c038bcb41aa7ef01d6b603b8ab9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 12 May 2024 22:43:47 +0200 Subject: [PATCH 28/35] Generate the build matrix from the variant files (#3870) --- .github/workflows/main_matrix.yml | 110 ++++++------------ bin/generate_ci_matrix.py | 7 +- variants/CDEBYTE_EoRa-S3/platformio.ini | 3 +- .../platformio.ini | 3 +- variants/betafpv_900_tx_nano/platformio.ini | 3 +- variants/chatter2/platformio.ini | 1 - variants/diy/platformio.ini | 4 +- variants/feather_diy/platformio.ini | 1 - variants/heltec_esp32c3/platformio.ini | 1 - variants/heltec_v2.1/platformio.ini | 1 - variants/heltec_v2/platformio.ini | 1 - variants/heltec_v3/platformio.ini | 1 + variants/m5stack_core/platformio.ini | 3 +- variants/m5stack_coreink/platformio.ini | 4 +- variants/rak10701/platformio.ini | 1 + variants/rak11200/platformio.ini | 4 +- variants/rak4631/platformio.ini | 3 +- variants/rpipico-slowclock/platformio.ini | 3 +- variants/rpipicow/platformio.ini | 1 - variants/station-g2/platformio.ini | 1 + variants/t-deck/platformio.ini | 1 + variants/t-echo/platformio.ini | 3 +- variants/t-watch-s3/platformio.ini | 1 + variants/tbeam-s3-core/platformio.ini | 1 + variants/tbeam/platformio.ini | 3 +- variants/tbeam_v07/platformio.ini | 1 - variants/tlora_t3s3_v1/platformio.ini | 1 + variants/tlora_v1_3/platformio.ini | 1 - variants/tlora_v2/platformio.ini | 1 - variants/tlora_v2_1_16/platformio.ini | 1 + variants/unphone/platformio.ini | 1 - variants/wiphone/platformio.ini | 4 +- 32 files changed, 71 insertions(+), 104 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 9ca0764b5..1d3d16c0c 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -8,7 +8,7 @@ on: branches: [master, develop] paths-ignore: - "**.md" - - "version.properties" + - version.properties # Note: This is different from "pull_request". Need to specify ref when doing checkouts. pull_request_target: @@ -20,25 +20,34 @@ on: workflow_dispatch: jobs: - check: + setup: strategy: fail-fast: false matrix: - include: - - board: rak11200 - - board: tlora-v2-1-1_6 - - board: tbeam - - board: heltec-v2_1 - - board: meshtastic-diy-v1 - - board: rak4631 - - board: t-echo - - board: station-g2 - - board: m5stack-coreink - - board: tbeam-s3-core - - board: tlora-t3s3-v1 - - board: t-watch-s3 - - board: t-deck - #- board: rak11310 + arch: [esp32, esp32s3, esp32c3, nrf52840, rp2040, check] + runs-on: ubuntu-latest + steps: + - id: checkout + uses: actions/checkout@v3 + name: Checkout base + - id: jsonStep + run: | + TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}}) + echo "$TARGETS" + echo "${{matrix.arch}}=$(jq -cn --argjson environments "$TARGETS" '{board: $environments}')" >> $GITHUB_OUTPUT + outputs: + esp32: ${{ steps.jsonStep.outputs.esp32 }} + esp32s3: ${{ steps.jsonStep.outputs.esp32s3 }} + esp32c3: ${{ steps.jsonStep.outputs.esp32c3 }} + nrf52840: ${{ steps.jsonStep.outputs.nrf52840 }} + rp2040: ${{ steps.jsonStep.outputs.rp2040 }} + check: ${{ steps.jsonStep.outputs.check }} + + check: + needs: setup + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.setup.outputs.check) }} runs-on: ubuntu-latest steps: @@ -55,93 +64,46 @@ jobs: run: bin/check-all.sh ${{ matrix.board }} build-esp32: + needs: setup strategy: fail-fast: false - matrix: - include: - - board: rak11200 - - board: tlora-v2 - - board: tlora-v1 - - board: tlora_v1_3 - - board: tlora-v2-1-1_6 - - board: tlora-v2-1-1_6-tcxo - - board: tlora-v2-1-1_8 - - board: tbeam - - board: heltec-v2_0 - - board: heltec-v2_1 - - board: tbeam0_7 - - board: meshtastic-diy-v1 - - board: hydra - - board: meshtastic-dr-dev - - board: nano-g1 - - board: station-g1 - - board: m5stack-core - - board: m5stack-coreink - - board: nano-g1-explorer - - board: chatter2 + matrix: ${{ fromJson(needs.setup.outputs.esp32) }} uses: ./.github/workflows/build_esp32.yml with: board: ${{ matrix.board }} build-esp32-s3: + needs: setup strategy: fail-fast: false - matrix: - include: - - board: heltec-v3 - - board: heltec-wsl-v3 - - board: heltec-wireless-tracker - - board: heltec-wireless-tracker-V1-0 - - board: heltec-wireless-paper-v1_0 - - board: heltec-wireless-paper #v1.1 - - board: tbeam-s3-core - - board: tlora-t3s3-v1 - - board: t-watch-s3 - - board: t-deck - - board: picomputer-s3 - - board: station-g2 - - board: unphone + matrix: ${{ fromJson(needs.setup.outputs.esp32s3) }} uses: ./.github/workflows/build_esp32_s3.yml with: board: ${{ matrix.board }} build-esp32-c3: + needs: setup strategy: fail-fast: false - matrix: - include: - - board: heltec-ht62-esp32c3-sx1262 + matrix: ${{ fromJson(needs.setup.outputs.esp32c3) }} uses: ./.github/workflows/build_esp32_c3.yml with: board: ${{ matrix.board }} build-nrf52: + needs: setup strategy: fail-fast: false - matrix: - include: - - board: rak4631 - - board: rak4631_eink - - board: monteops_hw1 - - board: t-echo - - board: canaryone - - board: pca10059_diy_eink - - board: feather_diy - - board: nano-g2-ultra + matrix: ${{ fromJson(needs.setup.outputs.nrf52840) }} uses: ./.github/workflows/build_nrf52.yml with: board: ${{ matrix.board }} build-rpi2040: + needs: setup strategy: fail-fast: false - matrix: - include: - - board: pico - - board: picow - - board: rak11310 - - board: senselora_rp2040 - - board: rp2040-lora + matrix: ${{ fromJson(needs.setup.outputs.rp2040) }} uses: ./.github/workflows/build_rpi2040.yml with: board: ${{ matrix.board }} diff --git a/bin/generate_ci_matrix.py b/bin/generate_ci_matrix.py index 2501e83c1..46398dd59 100755 --- a/bin/generate_ci_matrix.py +++ b/bin/generate_ci_matrix.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -"""Generate the CI matrix""" +"""Generate the CI matrix.""" import configparser import json @@ -34,5 +34,10 @@ for subdir, dirs, files in os.walk(rootdir): outlist.append(section) else: outlist.append(section) + if "board_check" in config[config[c].name]: + if (config[config[c].name]["board_check"] == "true") & ( + "check" in options + ): + outlist.append(section) print(json.dumps(outlist)) diff --git a/variants/CDEBYTE_EoRa-S3/platformio.ini b/variants/CDEBYTE_EoRa-S3/platformio.ini index 1ff54de88..88845a50c 100644 --- a/variants/CDEBYTE_EoRa-S3/platformio.ini +++ b/variants/CDEBYTE_EoRa-S3/platformio.ini @@ -1,8 +1,9 @@ [env:CDEBYTE_EoRa-S3] extends = esp32s3_base board = CDEBYTE_EoRa-S3 +board_level = extra build_flags = ${esp32s3_base.build_flags} -D CDEBYTE_EORA_S3 -I variants/CDEBYTE_EoRa-S3 - -D GPS_POWER_TOGGLE + -D GPS_POWER_TOGGLE \ No newline at end of file diff --git a/variants/Dongle_nRF52840-pca10059-v1/platformio.ini b/variants/Dongle_nRF52840-pca10059-v1/platformio.ini index b1608770e..2d14f1ca1 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/platformio.ini +++ b/variants/Dongle_nRF52840-pca10059-v1/platformio.ini @@ -1,7 +1,6 @@ [env:pca10059_diy_eink] extends = nrf52840_base board = nordic_pca10059 -board_level = extra build_flags = ${nrf52840_base.build_flags} -Ivariants/Dongle_nRF52840-pca10059-v1 -D NORDIC_PCA10059 -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" -DEINK_DISPLAY_MODEL=GxEPD2_420_M01 @@ -11,4 +10,4 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/Dongle_nRF52840- lib_deps = ${nrf52840_base.lib_deps} zinggjm/GxEPD2@^1.4.9 -debug_tool = jlink +debug_tool = jlink \ No newline at end of file diff --git a/variants/betafpv_900_tx_nano/platformio.ini b/variants/betafpv_900_tx_nano/platformio.ini index 68e1a469b..3bea16f6b 100644 --- a/variants/betafpv_900_tx_nano/platformio.ini +++ b/variants/betafpv_900_tx_nano/platformio.ini @@ -1,6 +1,7 @@ [env:betafpv_900_tx_nano] extends = esp32_base board = esp32doit-devkit-v1 +board_level = extra build_flags = ${esp32_base.build_flags} -D BETAFPV_900_TX_NANO @@ -13,4 +14,4 @@ upload_protocol = esptool ;upload_port = /dev/ttyUSB0 upload_speed = 460800 lib_deps = - ${esp32_base.lib_deps} + ${esp32_base.lib_deps} \ No newline at end of file diff --git a/variants/chatter2/platformio.ini b/variants/chatter2/platformio.ini index 0856debfc..1f086cf07 100644 --- a/variants/chatter2/platformio.ini +++ b/variants/chatter2/platformio.ini @@ -2,7 +2,6 @@ [env:chatter2] extends = esp32_base board = esp32doit-devkit-v1 -board_level = extra build_flags = ${esp32_base.build_flags} -D CHATTER_2 diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index 5fb0f6421..94d59553d 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -2,7 +2,7 @@ [env:meshtastic-diy-v1] extends = esp32_base board = esp32doit-devkit-v1 -board_level = extra +board_check = true build_flags = ${esp32_base.build_flags} -D DIY_V1 @@ -26,7 +26,6 @@ build_flags = [env:meshtastic-dr-dev] extends = esp32_base board = esp32doit-devkit-v1 -board_level = extra board_upload.maximum_size = 4194304 board_upload.maximum_ram_size = 532480 build_flags = @@ -39,7 +38,6 @@ build_flags = [env:hydra] extends = esp32_base board = esp32doit-devkit-v1 -board_level = extra build_flags = ${esp32_base.build_flags} -D DIY_V1 diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini index 924f9098d..47c864b8e 100644 --- a/variants/feather_diy/platformio.ini +++ b/variants/feather_diy/platformio.ini @@ -2,7 +2,6 @@ [env:feather_diy] extends = nrf52840_base board = adafruit_feather_nrf52840 -board_level = extra build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -Dfeather_diy -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> diff --git a/variants/heltec_esp32c3/platformio.ini b/variants/heltec_esp32c3/platformio.ini index c9c80213e..6fe5c3c69 100644 --- a/variants/heltec_esp32c3/platformio.ini +++ b/variants/heltec_esp32c3/platformio.ini @@ -1,7 +1,6 @@ [env:heltec-ht62-esp32c3-sx1262] extends = esp32c3_base board = esp32-c3-devkitm-1 -board_level = extra build_flags = ${esp32_base.build_flags} -D HELTEC_HT62 diff --git a/variants/heltec_v2.1/platformio.ini b/variants/heltec_v2.1/platformio.ini index 7d4daecc9..5aa04fc58 100644 --- a/variants/heltec_v2.1/platformio.ini +++ b/variants/heltec_v2.1/platformio.ini @@ -2,7 +2,6 @@ ;build_type = debug ; to make it possible to step through our jtag debugger extends = esp32_base board = heltec_wifi_lora_32_V2 -board_level = extra build_flags = ${esp32_base.build_flags} -D HELTEC_V2_1 -I variants/heltec_v2.1 -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. \ No newline at end of file diff --git a/variants/heltec_v2/platformio.ini b/variants/heltec_v2/platformio.ini index 3289f4e68..cee1537d0 100644 --- a/variants/heltec_v2/platformio.ini +++ b/variants/heltec_v2/platformio.ini @@ -2,6 +2,5 @@ ;build_type = debug ; to make it possible to step through our jtag debugger extends = esp32_base board = heltec_wifi_lora_32_V2 -board_level = extra build_flags = ${esp32_base.build_flags} -D HELTEC_V2_0 -I variants/heltec_v2 \ No newline at end of file diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index 58ee0b5ba..e8f73e1ef 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -1,6 +1,7 @@ [env:heltec-v3] extends = esp32s3_base board = heltec_wifi_lora_32_V3 +board_check = true # Temporary until espressif creates a release with this new target build_flags = ${esp32s3_base.build_flags} -D HELTEC_V3 -I variants/heltec_v3 diff --git a/variants/m5stack_core/platformio.ini b/variants/m5stack_core/platformio.ini index 84fb9f251..95f5aea9f 100644 --- a/variants/m5stack_core/platformio.ini +++ b/variants/m5stack_core/platformio.ini @@ -1,7 +1,6 @@ [env:m5stack-core] extends = esp32_base board = m5stack-core-esp32 -board_level = extra monitor_filters = esp32_exception_decoder build_src_filter = ${esp32_base.build_src_filter} @@ -26,4 +25,4 @@ lib_ignore = m5stack-core lib_deps = ${esp32_base.lib_deps} - lovyan03/LovyanGFX@^1.1.8 + lovyan03/LovyanGFX@^1.1.8 \ No newline at end of file diff --git a/variants/m5stack_coreink/platformio.ini b/variants/m5stack_coreink/platformio.ini index dfb078a0a..c0c8bd30e 100644 --- a/variants/m5stack_coreink/platformio.ini +++ b/variants/m5stack_coreink/platformio.ini @@ -1,7 +1,7 @@ [env:m5stack-coreink] extends = esp32_base board = m5stack-coreink -board_level = extra +board_check = true build_src_filter = ${esp32_base.build_src_filter} build_flags = @@ -24,4 +24,4 @@ lib_ignore = monitor_filters = esp32_exception_decoder board_build.f_cpu = 240000000L upload_protocol = esptool -upload_port = /dev/ttyACM0 +upload_port = /dev/ttyACM0 \ No newline at end of file diff --git a/variants/rak10701/platformio.ini b/variants/rak10701/platformio.ini index 37f785e84..ae43b1906 100644 --- a/variants/rak10701/platformio.ini +++ b/variants/rak10701/platformio.ini @@ -1,6 +1,7 @@ ; The very slick RAK wireless RAK10701 Field Tester device. Note you will have to flash to Arduino bootloader to use this firmware. Be aware touch is not currently working. [env:rak10701] extends = nrf52840_base +board_level = extra board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/rak10701 -D RAK_4631 -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" diff --git a/variants/rak11200/platformio.ini b/variants/rak11200/platformio.ini index f653adeb2..eddc3458e 100644 --- a/variants/rak11200/platformio.ini +++ b/variants/rak11200/platformio.ini @@ -1,7 +1,7 @@ [env:rak11200] extends = esp32_base -board_level = extra board = wiscore_rak11200 +board_check = true build_flags = ${esp32_base.build_flags} -D RAK_11200 -I variants/rak11200 -upload_speed = 115200 +upload_speed = 115200 \ No newline at end of file diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index b1bc2d9b5..115e96967 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -2,6 +2,7 @@ [env:rak4631] extends = nrf52840_base board = wiscore_rak4631 +board_check = true build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631 -D RAK_4631 -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. @@ -17,4 +18,4 @@ lib_deps = rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2 debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) -;upload_protocol = jlink +;upload_protocol = jlink \ No newline at end of file diff --git a/variants/rpipico-slowclock/platformio.ini b/variants/rpipico-slowclock/platformio.ini index eec76ca0f..0b94eb9c6 100644 --- a/variants/rpipico-slowclock/platformio.ini +++ b/variants/rpipico-slowclock/platformio.ini @@ -1,6 +1,7 @@ [env:pico_slowclock] extends = rp2040_base board = rpipico +board_level = extra upload_protocol = jlink # debug settings for external openocd with RP2040 support (custom build) debug_tool = custom @@ -25,4 +26,4 @@ lib_deps = ${rp2040_base.lib_deps} debug_build_flags = ${rp2040_base.build_flags} -g - -DNO_USB + -DNO_USB \ No newline at end of file diff --git a/variants/rpipicow/platformio.ini b/variants/rpipicow/platformio.ini index 29b5c8bcb..91ec964d9 100644 --- a/variants/rpipicow/platformio.ini +++ b/variants/rpipicow/platformio.ini @@ -1,7 +1,6 @@ [env:picow] extends = rp2040_base board = rpipicow -board_level = extra upload_protocol = picotool # add our variants files to the include and src paths diff --git a/variants/station-g2/platformio.ini b/variants/station-g2/platformio.ini index b39136684..e96c0ab88 100755 --- a/variants/station-g2/platformio.ini +++ b/variants/station-g2/platformio.ini @@ -1,6 +1,7 @@ [env:station-g2] extends = esp32s3_base board = station-g2 +board_check = true board_build.mcu = esp32s3 upload_protocol = esptool ;upload_port = /dev/ttyACM0 diff --git a/variants/t-deck/platformio.ini b/variants/t-deck/platformio.ini index 593fdae5e..a63ff57a7 100644 --- a/variants/t-deck/platformio.ini +++ b/variants/t-deck/platformio.ini @@ -2,6 +2,7 @@ [env:t-deck] extends = esp32s3_base board = t-deck +board_check = true upload_protocol = esptool #upload_port = COM29 diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 5bd56598b..aa8177b33 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -2,6 +2,7 @@ [env:t-echo] extends = nrf52840_base board = t-echo +board_check = true debug_tool = jlink # add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling. @@ -23,4 +24,4 @@ lib_deps = ${nrf52840_base.lib_deps} https://github.com/meshtastic/GxEPD2#55f618961db45a23eff0233546430f1e5a80f63a lewisxhe/PCF8563_Library@^1.0.1 -;upload_protocol = fs +;upload_protocol = fs \ No newline at end of file diff --git a/variants/t-watch-s3/platformio.ini b/variants/t-watch-s3/platformio.ini index 5d5904b30..1f5fc278b 100644 --- a/variants/t-watch-s3/platformio.ini +++ b/variants/t-watch-s3/platformio.ini @@ -2,6 +2,7 @@ [env:t-watch-s3] extends = esp32s3_base board = t-watch-s3 +board_check = true upload_protocol = esptool build_flags = ${esp32_base.build_flags} diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index 99d315a69..e50d506b9 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -2,6 +2,7 @@ [env:tbeam-s3-core] extends = esp32s3_base board = tbeam-s3-core +board_check = true lib_deps = ${esp32s3_base.lib_deps} diff --git a/variants/tbeam/platformio.ini b/variants/tbeam/platformio.ini index 76a03d126..85e66c2dd 100644 --- a/variants/tbeam/platformio.ini +++ b/variants/tbeam/platformio.ini @@ -2,9 +2,10 @@ [env:tbeam] extends = esp32_base board = ttgo-t-beam +board_check = true lib_deps = ${esp32_base.lib_deps} build_flags = ${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam -DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely. -upload_speed = 921600 +upload_speed = 921600 \ No newline at end of file diff --git a/variants/tbeam_v07/platformio.ini b/variants/tbeam_v07/platformio.ini index 5428b0e2a..105d65912 100644 --- a/variants/tbeam_v07/platformio.ini +++ b/variants/tbeam_v07/platformio.ini @@ -2,6 +2,5 @@ [env:tbeam0_7] extends = esp32_base board = ttgo-t-beam -board_level = extra build_flags = ${esp32_base.build_flags} -D TBEAM_V07 -I variants/tbeam_v07 \ No newline at end of file diff --git a/variants/tlora_t3s3_v1/platformio.ini b/variants/tlora_t3s3_v1/platformio.ini index fd3d393d9..002b2f224 100644 --- a/variants/tlora_t3s3_v1/platformio.ini +++ b/variants/tlora_t3s3_v1/platformio.ini @@ -1,6 +1,7 @@ [env:tlora-t3s3-v1] extends = esp32s3_base board = tlora-t3s3-v1 +board_check = true upload_protocol = esp-builtin build_flags = diff --git a/variants/tlora_v1_3/platformio.ini b/variants/tlora_v1_3/platformio.ini index 739f76268..9d9f41a7c 100644 --- a/variants/tlora_v1_3/platformio.ini +++ b/variants/tlora_v1_3/platformio.ini @@ -1,6 +1,5 @@ [env:tlora_v1_3] extends = esp32_base -board_level = extra board = ttgo-lora32-v1 build_flags = ${esp32_base.build_flags} -D TLORA_V1_3 -I variants/tlora_v1_3 \ No newline at end of file diff --git a/variants/tlora_v2/platformio.ini b/variants/tlora_v2/platformio.ini index 25ae3a360..8710068af 100644 --- a/variants/tlora_v2/platformio.ini +++ b/variants/tlora_v2/platformio.ini @@ -1,6 +1,5 @@ [env:tlora-v2] extends = esp32_base board = ttgo-lora32-v1 -board_level = extra build_flags = ${esp32_base.build_flags} -D TLORA_V2 -I variants/tlora_v2 \ No newline at end of file diff --git a/variants/tlora_v2_1_16/platformio.ini b/variants/tlora_v2_1_16/platformio.ini index 167f6c37c..351f71676 100644 --- a/variants/tlora_v2_1_16/platformio.ini +++ b/variants/tlora_v2_1_16/platformio.ini @@ -1,6 +1,7 @@ [env:tlora-v2-1-1_6] extends = esp32_base board = ttgo-lora32-v21 +board_check = true build_flags = ${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/tlora_v2_1_16 -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. \ No newline at end of file diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index e4a92fe4c..f66b5db49 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -3,7 +3,6 @@ [env:unphone] extends = esp32s3_base -board_level = extra board = unphone9 upload_speed = 921600 monitor_speed = 115200 diff --git a/variants/wiphone/platformio.ini b/variants/wiphone/platformio.ini index 10c0de55e..0218f8930 100644 --- a/variants/wiphone/platformio.ini +++ b/variants/wiphone/platformio.ini @@ -1,6 +1,7 @@ [env:wiphone] extends = esp32_base board = wiphone +board_level = extra monitor_filters = esp32_exception_decoder board_build.partitions = default_16MB.csv build_flags = @@ -9,5 +10,4 @@ lib_deps = ${esp32_base.lib_deps} lovyan03/LovyanGFX@^1.1.8 sparkfun/SX1509 IO Expander@^3.0.5 - pololu/APA102@^3.0.0 - \ No newline at end of file + pololu/APA102@^3.0.0 \ No newline at end of file From 4d8c98c23db3724347bf6b2283ed3cd66e266cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 13 May 2024 10:47:40 +0200 Subject: [PATCH 29/35] Update CI runner versions from Node 16 to 20. (#3872) --- .github/actions/setup-base/action.yml | 6 +-- .github/workflows/build_esp32.yml | 9 ++-- .github/workflows/build_esp32_c3.yml | 9 ++-- .github/workflows/build_esp32_s3.yml | 9 ++-- .github/workflows/build_nrf52.yml | 5 ++- .github/workflows/build_raspbian.yml | 5 ++- .github/workflows/build_rpi2040.yml | 5 ++- .github/workflows/main_matrix.yml | 49 ++++++++++++--------- .github/workflows/nightly.yml | 2 +- .github/workflows/package_raspbian.yml | 10 +++-- .github/workflows/sec_sast_flawfinder.yml | 7 +-- .github/workflows/sec_sast_semgrep_cron.yml | 7 +-- .github/workflows/sec_sast_semgrep_pull.yml | 2 +- .github/workflows/trunk-check.yml | 2 +- .github/workflows/update_protobufs.yml | 2 +- 15 files changed, 72 insertions(+), 57 deletions(-) diff --git a/.github/actions/setup-base/action.yml b/.github/actions/setup-base/action.yml index 7b97e1753..7e57f6a31 100644 --- a/.github/actions/setup-base/action.yml +++ b/.github/actions/setup-base/action.yml @@ -5,7 +5,7 @@ runs: using: "composite" steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: "recursive" ref: ${{github.event.pull_request.head.ref}} @@ -30,12 +30,12 @@ runs: sudo apt-get install -y libyaml-cpp-dev - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.x - name: Cache python libs - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache-pip # needed in if test with: path: ~/.cache/pip diff --git a/.github/workflows/build_esp32.yml b/.github/workflows/build_esp32.yml index 31f0dd5a0..4cbb4c7a4 100644 --- a/.github/workflows/build_esp32.yml +++ b/.github/workflows/build_esp32.yml @@ -11,13 +11,13 @@ jobs: build-esp32: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base - name: Pull web ui - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/web file: build.tar @@ -41,7 +41,7 @@ jobs: run: bin/build-esp32.sh ${{ inputs.board }} - name: Pull OTA Firmware - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/firmware-ota file: firmware.bin @@ -54,9 +54,10 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/*.bin release/*.elf diff --git a/.github/workflows/build_esp32_c3.yml b/.github/workflows/build_esp32_c3.yml index a30cf33f1..07727d711 100644 --- a/.github/workflows/build_esp32_c3.yml +++ b/.github/workflows/build_esp32_c3.yml @@ -13,13 +13,13 @@ jobs: build-esp32-c3: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base - name: Pull web ui - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/web file: build.tar @@ -41,7 +41,7 @@ jobs: run: bin/build-esp32.sh ${{ inputs.board }} - name: Pull OTA Firmware - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/firmware-ota file: firmware-c3.bin @@ -54,9 +54,10 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/*.bin release/*.elf diff --git a/.github/workflows/build_esp32_s3.yml b/.github/workflows/build_esp32_s3.yml index f603a6a31..10773833e 100644 --- a/.github/workflows/build_esp32_s3.yml +++ b/.github/workflows/build_esp32_s3.yml @@ -11,13 +11,13 @@ jobs: build-esp32-s3: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base - name: Pull web ui - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/web file: build.tar @@ -39,7 +39,7 @@ jobs: run: bin/build-esp32.sh ${{ inputs.board }} - name: Pull OTA Firmware - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/firmware-ota file: firmware-s3.bin @@ -52,9 +52,10 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/*.bin release/*.elf diff --git a/.github/workflows/build_nrf52.yml b/.github/workflows/build_nrf52.yml index 33ee4d00c..eb1779963 100644 --- a/.github/workflows/build_nrf52.yml +++ b/.github/workflows/build_nrf52.yml @@ -11,7 +11,7 @@ jobs: build-nrf52: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base @@ -24,9 +24,10 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/*.uf2 release/*.elf diff --git a/.github/workflows/build_raspbian.yml b/.github/workflows/build_raspbian.yml index 7a25892bc..cef61bb21 100644 --- a/.github/workflows/build_raspbian.yml +++ b/.github/workflows/build_raspbian.yml @@ -11,7 +11,7 @@ jobs: runs-on: [self-hosted, linux, ARM64] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive ref: ${{github.event.pull_request.head.ref}} @@ -37,9 +37,10 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-raspbian-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/meshtasticd_linux_aarch64 bin/config-dist.yaml diff --git a/.github/workflows/build_rpi2040.yml b/.github/workflows/build_rpi2040.yml index 76ca2c20e..6e258fe2a 100644 --- a/.github/workflows/build_rpi2040.yml +++ b/.github/workflows/build_rpi2040.yml @@ -11,7 +11,7 @@ jobs: build-rpi2040: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base @@ -24,9 +24,10 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/*.uf2 release/*.elf diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 1d3d16c0c..095981087 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - id: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 name: Checkout base - id: jsonStep run: | @@ -51,14 +51,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base - name: Trunk Check if: ${{ github.event_name != 'workflow_dispatch' }} - uses: trunk-io/trunk-action@782e83f803ca6e369f035d64c6ba2768174ba61b + uses: trunk-io/trunk-action@v1 - name: Check ${{ matrix.board }} run: bin/check-all.sh ${{ matrix.board }} @@ -120,7 +120,7 @@ jobs: build-native: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build base id: base uses: ./.github/actions/setup-base @@ -143,16 +143,17 @@ jobs: id: version - name: Store binaries as an artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-native-${{ steps.version.outputs.version }}.zip + overwrite: true path: | release/device-*.sh release/device-*.bat - name: Docker login if: ${{ github.event_name != 'pull_request_target' && github.event_name != 'pull_request' }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: meshtastic password: ${{ secrets.DOCKER_TOKEN }} @@ -184,7 +185,7 @@ jobs: needs: [check] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -207,14 +208,15 @@ jobs: ] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: ./ + merge-multiple: true - name: Display structure of downloaded files run: ls -R @@ -223,16 +225,14 @@ jobs: run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT id: version - - name: Move files up - run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./*tbeam-s3*/bleota-s3.bin ./*esp32c3*/bleota-c3.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase_v2.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./*native*/*device-*.sh ./*native*/*device-*.bat ./firmware-raspbian-*/release/meshtasticd_linux_aarch64 ./firmware-raspbian-*/bin/config-dist.yaml - - name: Repackage in single firmware zip - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: firmware-${{ steps.version.outputs.version }} + overwrite: true path: | - ./*.bin - ./*.uf2 + ./firmware-*.bin + ./firmware-*.uf2 ./firmware-*-ota.zip ./device-*.sh ./device-*.bat @@ -240,9 +240,10 @@ jobs: ./config-dist.yaml retention-days: 90 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: firmware-${{ steps.version.outputs.version }} + merge-multiple: true path: ./output # For diagnostics @@ -258,9 +259,10 @@ jobs: run: zip -j -9 -r ./firmware-${{ steps.version.outputs.version }}.zip ./output - name: Repackage in single elfs zip - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: debug-elfs-${{ steps.version.outputs.version }}.zip + overwrite: true path: ./*.elf retention-days: 30 @@ -282,10 +284,10 @@ jobs: needs: [gather-artifacts, after-checks] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.x @@ -293,13 +295,15 @@ jobs: run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT id: version - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: firmware-${{ steps.version.outputs.version }} + merge-multiple: true path: ./output - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: + merge-multiple: true name: artifact-deb - name: Display structure of downloaded files @@ -313,9 +317,10 @@ jobs: - name: Zip firmware run: zip -j -9 -r ./firmware-${{ steps.version.outputs.version }}.zip ./output - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: debug-elfs-${{ steps.version.outputs.version }}.zip + merge-multiple: true path: ./elfs - name: Zip Elfs diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index da59bc0fd..e249823a7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Trunk Check uses: trunk-io/trunk-action@782e83f803ca6e369f035d64c6ba2768174ba61b diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index 81ff6ee25..367f90c56 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -17,14 +17,14 @@ jobs: needs: build-raspbian steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - name: Pull web ui - uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 + uses: dsaltares/fetch-gh-release-asset@master with: repo: meshtastic/web file: build.tar @@ -36,9 +36,10 @@ jobs: id: version - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: firmware-raspbian-${{ steps.version.outputs.version }}.zip + merge-multiple: true - name: Display structure of downloaded files run: ls -R @@ -68,8 +69,9 @@ jobs: depends: libyaml-cpp0.7, openssl, libulfius2.7 desc: Native Linux Meshtastic binary. - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: artifact-deb + overwrite: true path: | ./*.deb diff --git a/.github/workflows/sec_sast_flawfinder.yml b/.github/workflows/sec_sast_flawfinder.yml index 2c7e751af..99cc72190 100644 --- a/.github/workflows/sec_sast_flawfinder.yml +++ b/.github/workflows/sec_sast_flawfinder.yml @@ -16,7 +16,7 @@ jobs: steps: # step 1 - name: clone application source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # step 2 - name: flawfinder_scan @@ -27,14 +27,15 @@ jobs: # step 3 - name: save report as pipeline artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: flawfinder_report.sarif + overwrite: true path: flawfinder_report.sarif # step 4 - name: publish code scanning alerts - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: flawfinder_report.sarif category: flawfinder diff --git a/.github/workflows/sec_sast_semgrep_cron.yml b/.github/workflows/sec_sast_semgrep_cron.yml index cdd2c3c37..2a0361f5e 100644 --- a/.github/workflows/sec_sast_semgrep_cron.yml +++ b/.github/workflows/sec_sast_semgrep_cron.yml @@ -17,7 +17,7 @@ jobs: steps: # step 1 - name: clone application source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # step 2 - name: full scan @@ -29,14 +29,15 @@ jobs: # step 3 - name: save report as pipeline artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: report.sarif + overwrite: true path: report.sarif # step 4 - name: publish code scanning alerts - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: report.sarif category: semgrep diff --git a/.github/workflows/sec_sast_semgrep_pull.yml b/.github/workflows/sec_sast_semgrep_pull.yml index 1697ffb1b..b6c288494 100644 --- a/.github/workflows/sec_sast_semgrep_pull.yml +++ b/.github/workflows/sec_sast_semgrep_pull.yml @@ -11,7 +11,7 @@ jobs: steps: # step 1 - name: clone application source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/trunk-check.yml b/.github/workflows/trunk-check.yml index e35b91cb9..6ed905bc8 100644 --- a/.github/workflows/trunk-check.yml +++ b/.github/workflows/trunk-check.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Trunk Check uses: trunk-io/trunk-action@v1 diff --git a/.github/workflows/update_protobufs.yml b/.github/workflows/update_protobufs.yml index 30f9b3578..30a5993c2 100644 --- a/.github/workflows/update_protobufs.yml +++ b/.github/workflows/update_protobufs.yml @@ -7,7 +7,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true From 078f33ff78f22d3ca53dc50b9c9b0e9cabd2f7e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 13 May 2024 11:45:22 +0200 Subject: [PATCH 30/35] Re-add missing files (#3873) --- .github/workflows/main_matrix.yml | 17 +++++++++++------ .github/workflows/update_protobufs.yml | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 095981087..7affd8fc1 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -157,14 +157,13 @@ jobs: with: username: meshtastic password: ${{ secrets.DOCKER_TOKEN }} - - name: Docker setup if: ${{ github.event_name != 'pull_request_target' && github.event_name != 'pull_request' }} - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Docker build and push tagged versions if: ${{ github.event_name == 'workflow_dispatch' }} - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile @@ -173,7 +172,7 @@ jobs: - name: Docker build and push if: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request_target' && github.event_name != 'pull_request' }} - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile @@ -225,6 +224,9 @@ jobs: run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT id: version + - name: Move files up + run: mv -b -t ./ ./release/meshtasticd_linux_aarch64 ./bin/config-dist.yaml + - name: Repackage in single firmware zip uses: actions/upload-artifact@v4 with: @@ -236,8 +238,11 @@ jobs: ./firmware-*-ota.zip ./device-*.sh ./device-*.bat - ./meshtasticd_linux_arm64 + ./meshtasticd_linux_*64 ./config-dist.yaml + ./littlefs-*.bin + ./bleota*bin + ./Meshtastic_nRF52_factory_erase*.uf2 retention-days: 90 - uses: actions/download-artifact@v4 @@ -378,7 +383,7 @@ jobs: bin/bump_version.py - name: Create version.properties pull request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v6 with: add-paths: | version.properties diff --git a/.github/workflows/update_protobufs.yml b/.github/workflows/update_protobufs.yml index 30a5993c2..4402a280e 100644 --- a/.github/workflows/update_protobufs.yml +++ b/.github/workflows/update_protobufs.yml @@ -26,7 +26,7 @@ jobs: ./bin/regen-protos.sh - name: Create pull request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v6 with: add-paths: | protobufs From a9a208de7336903fa466ebd3d749f317c0ae69ce Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Mon, 13 May 2024 23:42:41 +1200 Subject: [PATCH 31/35] Implement "Flip screen" setting for E-Ink displays (#3871) --- src/graphics/EInkDisplay2.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 04915fe07..bbc12521a 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -62,12 +62,19 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) return false; // FIXME - only draw bits have changed (use backbuf similar to the other displays) + const bool flipped = config.display.flip_screen; for (uint32_t y = 0; y < displayHeight; y++) { for (uint32_t x = 0; x < displayWidth; x++) { // get src pixel in the page based ordering the OLED lib uses FIXME, super inefficient auto b = buffer[x + (y / 8) * displayWidth]; auto isset = b & (1 << (y & 7)); - adafruitDisplay->drawPixel(x, y, isset ? GxEPD_BLACK : GxEPD_WHITE); + + // Handle flip here, rather than with setRotation(), + // Avoids issues when display width is not a multiple of 8 + if (flipped) + adafruitDisplay->drawPixel((displayWidth - 1) - x, (displayHeight - 1) - y, isset ? GxEPD_BLACK : GxEPD_WHITE); + else + adafruitDisplay->drawPixel(x, y, isset ? GxEPD_BLACK : GxEPD_WHITE); } } From 2388eb91ae6168ecf25c086abd6d856bfee2c8b3 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Tue, 14 May 2024 23:46:03 +1200 Subject: [PATCH 32/35] Fix immediate wake from deepsleep for some devices (#3884) Affects ESP32 boards without an external pull-up on the defined user-button pin. --- src/sleep.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sleep.cpp b/src/sleep.cpp index fe73a755c..590610e6c 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -264,7 +264,11 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false) #ifdef BUTTON_PIN // Avoid leakage through button pin if (GPIO_IS_VALID_OUTPUT_GPIO(BUTTON_PIN)) { +#ifdef BUTTON_NEED_PULLUP + pinMode(BUTTON_PIN, INPUT_PULLUP); +#else pinMode(BUTTON_PIN, INPUT); +#endif gpio_hold_en((gpio_num_t)BUTTON_PIN); } #endif From 3b5d4e92c5aa109056e89814434ab1a196ddc33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 14 May 2024 13:48:26 +0200 Subject: [PATCH 33/35] add psram flag on RAK11200 board definition (#3887) --- boards/wiscore_rak11200.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/wiscore_rak11200.json b/boards/wiscore_rak11200.json index 33d16ba77..54ee9b69e 100644 --- a/boards/wiscore_rak11200.json +++ b/boards/wiscore_rak11200.json @@ -4,7 +4,7 @@ "ldscript": "esp32_out.ld" }, "core": "esp32", - "extra_flags": "-DARDUINO_ESP32_DEV", + "extra_flags": ["-DBOARD_HAS_PSRAM", "-DARDUINO_ESP32_DEV"], "f_cpu": "240000000L", "f_flash": "40000000L", "flash_mode": "dio", From 1f9ff68f1d318de7bede8e4e0bed64ca0b990f2c Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Tue, 14 May 2024 19:04:31 +0200 Subject: [PATCH 34/35] RP2040: Add `getFreeHeap()` and `getHeapSize()` support --- src/memGet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/memGet.cpp b/src/memGet.cpp index 0575da279..e982ef7ee 100644 --- a/src/memGet.cpp +++ b/src/memGet.cpp @@ -22,6 +22,8 @@ uint32_t MemGet::getFreeHeap() return ESP.getFreeHeap(); #elif defined(ARCH_NRF52) return dbgHeapFree(); +#elif defined(ARCH_RP2040) + return rp2040.getFreeHeap(); #else // this platform does not have heap management function implemented return UINT32_MAX; @@ -38,6 +40,8 @@ uint32_t MemGet::getHeapSize() return ESP.getHeapSize(); #elif defined(ARCH_NRF52) return dbgHeapTotal(); +#elif defined(ARCH_RP2040) + return rp2040.getTotalHeap(); #else // this platform does not have heap management function implemented return UINT32_MAX; From 15178da566c23709026e5cac262b35d5245f6d80 Mon Sep 17 00:00:00 2001 From: pr000t <20946964+pr000t@users.noreply.github.com> Date: Tue, 14 May 2024 21:07:44 +0200 Subject: [PATCH 35/35] Change SHT4X sensors library from Sensirion to Adafruit --- platformio.ini | 2 +- src/modules/Telemetry/Sensor/SHT4XSensor.cpp | 38 +++++++------------- src/modules/Telemetry/Sensor/SHT4XSensor.h | 4 +-- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9d7c76fbf..5e53c495f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -133,4 +133,4 @@ lib_deps = https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 - https://github.com/Sensirion/arduino-i2c-sht4x#1.1.0 + https://github.com/adafruit/Adafruit_SHT4X#1.0.4 \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp index d324b7fd6..7f37327c6 100644 --- a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp +++ b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp @@ -5,17 +5,7 @@ #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "SHT4XSensor.h" #include "TelemetrySensor.h" -#include - -// macro definitions -// make sure that we use the proper definition of NO_ERROR -#ifdef NO_ERROR -#undef NO_ERROR -#endif -#define NO_ERROR 0 - -static char errorMessage[64]; -static int16_t error; +#include SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {} @@ -28,17 +18,15 @@ int32_t SHT4XSensor::runOnce() uint32_t serialNumber = 0; - sht4x.begin(*nodeTelemetrySensorsMap[sensorType].second, 0x44); + sht4x.begin(nodeTelemetrySensorsMap[sensorType].second); - error = sht4x.serialNumber(serialNumber); - LOG_DEBUG("serialNumber : %x\n", serialNumber); - if (error != NO_ERROR) { - LOG_DEBUG("Error trying to execute serialNumber(): "); - errorToString(error, errorMessage, sizeof errorMessage); - LOG_DEBUG(errorMessage); - status = 0; - } else { + serialNumber = sht4x.readSerial(); + if (serialNumber != 0) { + LOG_DEBUG("serialNumber : %x\n", serialNumber); status = 1; + } else { + LOG_DEBUG("Error trying to execute readSerial(): "); + status = 0; } return initI2CSensor(); @@ -51,12 +39,10 @@ void SHT4XSensor::setup() bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement) { - float aTemperature = 0.0; - float aHumidity = 0.0; - sht4x.measureLowestPrecision(aTemperature, aHumidity); - measurement->variant.environment_metrics.temperature = aTemperature; - measurement->variant.environment_metrics.relative_humidity = aHumidity; - + sensors_event_t humidity, temp; + sht4x.getEvent(&humidity, &temp); + measurement->variant.environment_metrics.temperature = temp.temperature; + measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity; return true; } diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.h b/src/modules/Telemetry/Sensor/SHT4XSensor.h index 67045eb2a..62a5cefeb 100644 --- a/src/modules/Telemetry/Sensor/SHT4XSensor.h +++ b/src/modules/Telemetry/Sensor/SHT4XSensor.h @@ -4,12 +4,12 @@ #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include +#include class SHT4XSensor : public TelemetrySensor { private: - SensirionI2cSht4x sht4x; + Adafruit_SHT4x sht4x = Adafruit_SHT4x(); protected: virtual void setup() override;