From d1cd686644b2c36b8c51276ab51c72e1b49003f4 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 15 Apr 2024 17:24:08 +0100 Subject: [PATCH 001/159] Fixed XPT2046 syntax and using unPhone library to clean up main and TFTDisplay. --- src/graphics/TFTDisplay.cpp | 48 ++++++++++++--------------------- src/main.cpp | 16 +---------- variants/unphone/platformio.ini | 15 +++++++++-- variants/unphone/variant.cpp | 20 ++++++++++++++ variants/unphone/variant.h | 14 +++++++--- 5 files changed, 62 insertions(+), 51 deletions(-) create mode 100644 variants/unphone/variant.cpp diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index fb64553ef..ddc4df2b3 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -411,8 +411,7 @@ class LGFX : public lgfx::LGFX_Device lgfx::Panel_HX8357D _panel_instance; lgfx::Bus_SPI _bus_instance; #if defined(USE_XPT2046) - lgfx::ITouch *_touch_instance; -// lgfx::Touch_XPT2046 _touch_instance; + lgfx::Touch_XPT2046 _touch_instance; #endif public: @@ -466,8 +465,7 @@ class LGFX : public lgfx::LGFX_Device #if defined(USE_XPT2046) { // Configure settings for touch control. - _touch_instance = new lgfx::Touch_XPT2046; - auto touch_cfg = _touch_instance->config(); + auto touch_cfg = _touch_instance.config(); touch_cfg.pin_cs = TOUCH_CS; touch_cfg.x_min = 0; @@ -478,8 +476,8 @@ class LGFX : public lgfx::LGFX_Device touch_cfg.bus_shared = true; touch_cfg.offset_rotation = 1; - _touch_instance->config(touch_cfg); - //_panel_instance->setTouch(_touch_instance); + _touch_instance.config(touch_cfg); + _panel_instance.setTouch(&_touch_instance); } #endif setPanel(&_panel_instance); @@ -496,6 +494,11 @@ static LGFX *tft = nullptr; #include "TFTDisplay.h" #include +#ifdef UNPHONE +#include "unPhone.h" +extern unPhone unphone; +#endif + TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus) { LOG_DEBUG("TFTDisplay!\n"); @@ -561,10 +564,8 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); -#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) - tft->wakeup(); - tft->powerSaveOff(); -#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#endif +#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #endif @@ -576,11 +577,7 @@ void TFTDisplay::sendCommand(uint8_t com) digitalWrite(VTFT_CTRL, LOW); #endif #ifdef UNPHONE - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x04); // Backlight on - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); + unphone.backlight(true); // using unPhone library #endif #ifdef RAK14014 #elif !defined(M5STACK) @@ -598,13 +595,10 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, !TFT_BACKLIGHT_ON); -#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) - tft->sleep(); - tft->powerSaveOn(); -#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#endif +#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #endif - #ifdef VTFT_CTRL_V03 digitalWrite(VTFT_CTRL_V03, HIGH); #endif @@ -612,11 +606,7 @@ void TFTDisplay::sendCommand(uint8_t com) digitalWrite(VTFT_CTRL, HIGH); #endif #ifdef UNPHONE - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x00); // Backlight off - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); + unphone.backlight(false); // using unPhone library #endif #ifdef RAK14014 #elif !defined(M5STACK) @@ -690,11 +680,7 @@ bool TFTDisplay::connect() digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); #endif #ifdef UNPHONE - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x04); // Backlight on - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); + unphone.backlight(true); // using unPhone library LOG_INFO("Power to TFT Backlight\n"); #endif @@ -718,4 +704,4 @@ bool TFTDisplay::connect() return true; } -#endif +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 587bcb56e..744fda4de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -590,20 +590,6 @@ void setup() if (config.display.oled != meshtastic_Config_DisplayConfig_OledType_OLED_AUTO) screen_model = config.display.oled; -#ifdef UNPHONE - // initialise IO expander with pinmodes - Wire.beginTransmission(0x26); - Wire.write(0x06); - Wire.write(0x7A); - Wire.write(0xDD); - Wire.endTransmission(); - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x04); // Backlight on - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); -#endif - #if defined(USE_SH1107) screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // set dimension of 128x128 display_geometry = GEOMETRY_128_128; @@ -1017,4 +1003,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index 06314eaa3..dad9a7177 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -1,5 +1,7 @@ +; platformio.ini for unphone meshtastic + [env:unphone] -;build_type = debug ; to make it possible to step through our jtag debugger + extends = esp32s3_base board_level = extra board = unphone9 @@ -14,6 +16,15 @@ build_flags = ${esp32_base.build_flags} -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 + -D UNPHONE_ACCEL=0 + -D UNPHONE_TOUCHS=0 + -D UNPHONE_SDCARD=0 + -D UNPHONE_UI0=0 + -D UNPHONE_LORA=0 + -D UNPHONE_FACTORY_MODE=0 + +build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> lib_deps = ${esp32s3_base.lib_deps} - lovyan03/LovyanGFX@^1.1.8 \ No newline at end of file + lovyan03/LovyanGFX @ ^1.1.8 + https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 \ No newline at end of file diff --git a/variants/unphone/variant.cpp b/variants/unphone/variant.cpp new file mode 100644 index 000000000..3f6d1c54d --- /dev/null +++ b/variants/unphone/variant.cpp @@ -0,0 +1,20 @@ +// meshtastic/firmware/variants/unphone/variant.cpp + +#include "unPhone.h" +unPhone unphone = unPhone("meshtastic_unphone"); + +void initVariant() +{ + unphone.begin(); // initialise hardware etc. + unphone.store(unphone.buildTime); + unphone.printWakeupReason(); // what woke us up? (stored, not printed :|) + unphone.checkPowerSwitch(); // if power switch is off, shutdown + unphone.backlight(false); // setup backlight and make sure its off + + for (int i = 0; i < 3; i++) { // buzz a bit + unphone.vibe(true); + delay(150); + unphone.vibe(false); + delay(150); + } +} \ No newline at end of file diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index 9306537f2..180fdfe2c 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -1,3 +1,7 @@ +// meshtastic/firmware/variants/unphone/variant.h + +#pragma once + #define SPI_SCK 39 #define SPI_MOSI 40 #define SPI_MISO 41 @@ -28,7 +32,7 @@ #define TFT_WIDTH 320 #define TFT_OFFSET_X 0 #define TFT_OFFSET_Y 0 -#define TFT_OFFSET_ROTATION 6 // the unPhone's screen is wired unusually, 0 is typical value here +#define TFT_OFFSET_ROTATION 6 // unPhone's screen wired unusually, 0 typical #define TFT_INVERT false #define SCREEN_ROTATE true #define SCREEN_TRANSITION_FRAMERATE 5 @@ -37,7 +41,10 @@ #define USE_XPT2046 1 #define TOUCH_CS 38 -#define HAS_GPS 0 // the unphone doesn't have a gps module +#define HAS_GPS \ + 0 // the unphone doesn't have a gps module by default (though + // GPS featherwing -- https://www.adafruit.com/product/3133 + // -- can be added) #undef GPS_RX_PIN #undef GPS_TX_PIN @@ -49,6 +56,7 @@ #define BUTTON_PIN 21 // Button 3 - square - top button in landscape mode #define BUTTON_NEED_PULLUP // we do need a helping hand up +#define BUTTON_PIN_ALT 45 // Button 1 - triangle - bottom button in landscape mode #define I2C_SDA 3 // I2C pins for this board #define I2C_SCL 4 @@ -58,6 +66,6 @@ // ratio of voltage divider = 3.20 (R1=100k, R2=220k) // #define ADC_MULTIPLIER 3.2 -// #define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// #define BATTERY_PIN 13 // battery V measurement pin; vbat divider is here // #define ADC_CHANNEL ADC2_GPIO13_CHANNEL // #define BAT_MEASURE_ADC_UNIT 2 \ No newline at end of file From 385d7296fee2ee4a0ad2260dbe44591cf3836381 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 15 Apr 2024 17:37:39 +0100 Subject: [PATCH 002/159] strange extra edits removed wtf --- src/graphics/TFTDisplay.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index ddc4df2b3..b561f3b56 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -564,8 +564,10 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); -#endif -#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) + tft->wakeup(); + tft->powerSaveOff(); +#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #endif @@ -595,10 +597,13 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, !TFT_BACKLIGHT_ON); -#endif -#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) + tft->sleep(); + tft->powerSaveOn(); +#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #endif + #ifdef VTFT_CTRL_V03 digitalWrite(VTFT_CTRL_V03, HIGH); #endif @@ -704,4 +709,4 @@ bool TFTDisplay::connect() return true; } -#endif \ No newline at end of file +#endif From 8a3322fbcbb470df00e71dbe0b861241e860a29f Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Tue, 16 Apr 2024 21:28:12 +0100 Subject: [PATCH 003/159] rgb led support for unPhone --- src/AmbientLightingThread.h | 25 ++++++++++-- src/detect/ScanI2C.h | 3 +- src/main.cpp | 20 +++++++++- src/modules/ExternalNotificationModule.cpp | 45 +++++++++++++++++++++- 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 98ccedde4..fd3c66cda 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -5,6 +5,11 @@ NCP5623 rgb; #endif +#ifdef UNPHONE +#include "unPhone.h" +extern unPhone unphone; +#endif + namespace concurrency { class AmbientLightingThread : public concurrency::OSThread @@ -20,8 +25,8 @@ class AmbientLightingThread : public concurrency::OSThread // moduleConfig.ambient_lighting.green = (myNodeInfo.my_node_num & 0x00FF00) >> 8; // moduleConfig.ambient_lighting.blue = myNodeInfo.my_node_num & 0x0000FF; -#ifdef HAS_NCP5623 _type = type; +#ifdef HAS_NCP5623 if (_type == ScanI2C::DeviceType::NONE) { LOG_DEBUG("AmbientLightingThread disabling due to no RGB leds found on I2C bus\n"); disable(); @@ -37,14 +42,23 @@ class AmbientLightingThread : public concurrency::OSThread rgb.begin(); setLighting(); } +#endif +#ifdef UNPHONE + if (!moduleConfig.ambient_lighting.led_state) { + LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); + disable(); + return; + } + LOG_DEBUG("AmbientLightingThread initializing\n"); + setLighting(); #endif } protected: int32_t runOnce() override { -#ifdef HAS_NCP5623 - if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { +#if defined(HAS_NCP5623) || defined(UNPHONE) + if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::RGBLED_CA) && moduleConfig.ambient_lighting.led_state) { setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification } else { @@ -68,6 +82,11 @@ class AmbientLightingThread : public concurrency::OSThread LOG_DEBUG("Initializing Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#endif +#ifdef UNPHONE + unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, + moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif } }; diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..b4341bcc0 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,9 +41,8 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, -#ifdef HAS_NCP5623 + RGBLED_CA, NCP5623, -#endif } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/main.cpp b/src/main.cpp index 744fda4de..4b3212f5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -494,11 +494,15 @@ void setup() * "found". */ -// Only one supported RGB LED currently +// Only one supported I2C RGB LED currently (plus common anode RGB LED used by the unPhone) #ifdef HAS_NCP5623 rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623); #endif +#ifdef UNPHONE + rgb_found.type = ScanI2C::DeviceType::RGBLED_CA; +#endif + #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) auto acc_info = i2cScanner->firstAccelerometer(); accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found; @@ -590,6 +594,20 @@ void setup() if (config.display.oled != meshtastic_Config_DisplayConfig_OledType_OLED_AUTO) screen_model = config.display.oled; +#ifdef UNPHONE + // initialise IO expander with pinmodes + Wire.beginTransmission(0x26); + Wire.write(0x06); + Wire.write(0x7A); + Wire.write(0xDD); + Wire.endTransmission(); + Wire.beginTransmission(0x26); + Wire.write(0x02); + Wire.write(0x04); // Backlight on + Wire.write(0x22); // G&B LEDs off + Wire.endTransmission(); +#endif + #if defined(USE_SH1107) screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // set dimension of 128x128 display_geometry = GEOMETRY_128_128; diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index a38b231af..be8fd2be2 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -36,6 +36,18 @@ uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets mul bool ascending = true; #endif +#ifdef UNPHONE +#include "unPhone.h" +extern unPhone unphone; + +uint8_t red = 0; +uint8_t green = 0; +uint8_t blue = 0; +uint8_t colorState = 1; +const uint8_t duration = 15; +uint8_t counter = 0; +#endif + #ifndef PIN_BUZZER #define PIN_BUZZER false #endif @@ -72,7 +84,6 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { - bool isPlaying = rtttl::isPlaying(); #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); @@ -133,6 +144,25 @@ int32_t ExternalNotificationModule::runOnce() } #endif +#ifdef UNPHONE + if (rgb_found.type == ScanI2C::RGBLED_CA) { + red = colorState & 4; // Red enabled on colorState = 4,5,6,7 + green = colorState & 2; // Green enabled on colorState = 2,3,6,7 + blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 + unphone.rgb(red, green, blue); + LOG_DEBUG("RGB runOnce: %i, %i, %i\n", red, green, blue); + + counter++; // tick on + if (counter > duration) { + counter = 0; + colorState++; // next color + if (colorState > 7) { + colorState = 1; + } + } + } +#endif + #ifdef T_WATCH_S3 drv.go(); #endif @@ -197,6 +227,11 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) rgb.setColor(red, green, blue); } #endif +#ifdef UNPHONE + if (rgb_found.type == ScanI2C::RGBLED_CA) { + unphone.rgb(red, green, blue); + } +#endif #ifdef T_WATCH_S3 drv.go(); #endif @@ -230,6 +265,14 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) rgb.setColor(red, green, blue); } #endif +#ifdef UNPHONE + if (rgb_found.type == ScanI2C::RGBLED_CA) { + red = 0; + green = 0; + blue = 0; + unphone.rgb(red, green, blue); + } +#endif #ifdef T_WATCH_S3 drv.stop(); #endif From 0632b96fcbeda61f4b21d236c4047429e7057a58 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Tue, 16 Apr 2024 21:40:13 +0100 Subject: [PATCH 004/159] just tiny tweak to minimise changes --- src/modules/ExternalNotificationModule.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index be8fd2be2..304b93389 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -84,7 +84,10 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { - bool isPlaying = rtttl::isPlaying(); + + bool isPlaying = rtttl::isPlaying();This PR just tidies up support for the unPhone by using its [library](https://gitlab.com/hamishcunningham/unphonelibrary) + +Also fixes incomplete syntax for the touchscreen driver invocation for XPT2046 when attached to a HX8357. #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); #endif @@ -551,4 +554,4 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) if (changed) { nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } -} \ No newline at end of file +} From afb4de21d9331a435281766b02af3c07080cee0a Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Tue, 16 Apr 2024 22:37:57 +0100 Subject: [PATCH 005/159] yet another random edit, think i'm brushing the touchpad or perhaps my computer is possessed by the devil determined to make me look foolish --- src/modules/ExternalNotificationModule.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 304b93389..be8fd2be2 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -84,10 +84,7 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { - - bool isPlaying = rtttl::isPlaying();This PR just tidies up support for the unPhone by using its [library](https://gitlab.com/hamishcunningham/unphonelibrary) - -Also fixes incomplete syntax for the touchscreen driver invocation for XPT2046 when attached to a HX8357. + bool isPlaying = rtttl::isPlaying(); #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); #endif @@ -554,4 +551,4 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) if (changed) { nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } -} +} \ No newline at end of file From 4b5549be8fa48cfe80a7de77ac6f9099fea7915b Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 09:22:31 +0100 Subject: [PATCH 006/159] added vibration notifications --- src/modules/ExternalNotificationModule.cpp | 44 +++++++++++----------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index be8fd2be2..d7997b849 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -145,20 +145,16 @@ int32_t ExternalNotificationModule::runOnce() #endif #ifdef UNPHONE - if (rgb_found.type == ScanI2C::RGBLED_CA) { - red = colorState & 4; // Red enabled on colorState = 4,5,6,7 - green = colorState & 2; // Green enabled on colorState = 2,3,6,7 - blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 - unphone.rgb(red, green, blue); - LOG_DEBUG("RGB runOnce: %i, %i, %i\n", red, green, blue); - - counter++; // tick on - if (counter > duration) { - counter = 0; - colorState++; // next color - if (colorState > 7) { - colorState = 1; - } + red = colorState & 4; // Red enabled on colorState = 4,5,6,7 + green = colorState & 2; // Green enabled on colorState = 2,3,6,7 + blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 + unphone.rgb(red, green, blue); + counter++; // tick on + if (counter > duration) { + counter = 0; + colorState++; // next color + if (colorState > 7) { + colorState = 1; } } #endif @@ -209,6 +205,9 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) switch (index) { case 1: +#ifdef UNPHONE + unphone.vibe(true); // the unPhone's vibration motor is on a i2c GPIO expander +#endif if (moduleConfig.external_notification.output_vibra) digitalWrite(moduleConfig.external_notification.output_vibra, true); break; @@ -228,9 +227,7 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) } #endif #ifdef UNPHONE - if (rgb_found.type == ScanI2C::RGBLED_CA) { - unphone.rgb(red, green, blue); - } + unphone.rgb(red, green, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -244,6 +241,9 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) switch (index) { case 1: +#ifdef UNPHONE + unphone.vibe(false); // the unPhone's vibration motor is on a i2c GPIO expander +#endif if (moduleConfig.external_notification.output_vibra) digitalWrite(moduleConfig.external_notification.output_vibra, false); break; @@ -266,12 +266,10 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) } #endif #ifdef UNPHONE - if (rgb_found.type == ScanI2C::RGBLED_CA) { - red = 0; - green = 0; - blue = 0; - unphone.rgb(red, green, blue); - } + red = 0; + green = 0; + blue = 0; + unphone.rgb(red, green, blue); #endif #ifdef T_WATCH_S3 drv.stop(); From a149999ceca1248d7cb4097384a61356d2b4f10b Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 20:57:03 +0100 Subject: [PATCH 007/159] tidy up first --- src/detect/ScanI2C.h | 3 ++- src/main.cpp | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index b4341bcc0..c8fcfee10 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,8 +41,9 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, - RGBLED_CA, +#ifdef HAS_NCP5623 NCP5623, +#endif } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/main.cpp b/src/main.cpp index 1699344a9..b1a15634f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -494,15 +494,11 @@ void setup() * "found". */ -// Only one supported I2C RGB LED currently (plus common anode RGB LED used by the unPhone) +// Only one supported RGB LED currently #ifdef HAS_NCP5623 rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623); #endif -#ifdef UNPHONE - rgb_found.type = ScanI2C::DeviceType::RGBLED_CA; -#endif - #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) auto acc_info = i2cScanner->firstAccelerometer(); accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found; From 7d77b23eb6a3383e4950f2f06ac7524b6a8102da Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 22:00:33 +0100 Subject: [PATCH 008/159] support for generic 4 pin CC and CA RGB LEDS --- src/AmbientLightingThread.h | 48 ++++++++++++++---- src/main.cpp | 2 +- src/modules/ExternalNotificationModule.cpp | 59 ++++++++++++++++++++++ 3 files changed, 99 insertions(+), 10 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index fd3c66cda..1425d3266 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -25,8 +25,8 @@ class AmbientLightingThread : public concurrency::OSThread // moduleConfig.ambient_lighting.green = (myNodeInfo.my_node_num & 0x00FF00) >> 8; // moduleConfig.ambient_lighting.blue = myNodeInfo.my_node_num & 0x0000FF; - _type = type; #ifdef HAS_NCP5623 + _type = type; if (_type == ScanI2C::DeviceType::NONE) { LOG_DEBUG("AmbientLightingThread disabling due to no RGB leds found on I2C bus\n"); disable(); @@ -51,22 +51,39 @@ class AmbientLightingThread : public concurrency::OSThread } LOG_DEBUG("AmbientLightingThread initializing\n"); setLighting(); +#endif +#ifdef RGBLED_RED + if (!moduleConfig.ambient_lighting.led_state) { + LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); + disable(); + return; + } + LOG_DEBUG("AmbientLightingThread initializing\n"); + pinMode(RGBLED_RED, output); + pinMode(RGBLED_GREEN, output); + pinMode(RGBLED_BLUE, output); + setLighting(); #endif } protected: int32_t runOnce() override { -#if defined(HAS_NCP5623) || defined(UNPHONE) - if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::RGBLED_CA) && moduleConfig.ambient_lighting.led_state) { +#ifdef HAS_NCP5623 + if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification - } else { - return disable(); } -#else - return disable(); #endif +#ifdef UNPHONE + setLighting(); + return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#endif +#ifdef RGBLED_RED + setLighting(); + return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#endif + return disable(); } private: @@ -79,14 +96,27 @@ class AmbientLightingThread : public concurrency::OSThread rgb.setRed(moduleConfig.ambient_lighting.red); rgb.setGreen(moduleConfig.ambient_lighting.green); rgb.setBlue(moduleConfig.ambient_lighting.blue); - LOG_DEBUG("Initializing Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n", + LOG_DEBUG("Initializing NCP5623 Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif #ifdef UNPHONE unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); - LOG_DEBUG("Initializing Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, + LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red); + analogWrite(RGBLED_GREEN, 255 - moduleConfig.ambient_lighting.green); + analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing Ambient lighting RGB Common Anode w/ red=%d, green=%d, blue=%d\n", + moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#elifdef RGBLED_RED + analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red); + analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green); + analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing Ambient lighting RGB Common Cathode w/ red=%d, green=%d, blue=%d\n", + moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif } }; diff --git a/src/main.cpp b/src/main.cpp index b1a15634f..d8640bb59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -608,7 +608,7 @@ void setup() #endif #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) - if (rgb_found.type != ScanI2C::DeviceType::NONE) { + if (rgb_found.type != ScanI2C::DeviceType::NONE || UNPHONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } #endif diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index d7997b849..ee3b73efd 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -48,6 +48,16 @@ const uint8_t duration = 15; uint8_t counter = 0; #endif +#ifdef RGBLED_RED +uint8_t red = 0; +uint8_t green = 0; +uint8_t blue = 0; +uint8_t colorState = 1; +uint8_t brightnessIndex = 0; +uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets multiplied by 1.5 +bool ascending = true; +#endif + #ifndef PIN_BUZZER #define PIN_BUZZER false #endif @@ -84,6 +94,7 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { + bool isPlaying = rtttl::isPlaying(); #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); @@ -159,6 +170,30 @@ int32_t ExternalNotificationModule::runOnce() } #endif +#ifdef RGBLED_RED + red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 + green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 + blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); + if (ascending) { // fade in + brightnessIndex++; + if (brightnessIndex == (sizeof(brightnessValues) - 1)) { + ascending = false; + } + } else { + brightnessIndex--; // fade out + } + if (brightnessIndex == 0) { + ascending = true; + colorState++; // next color + if (colorState > 7) { + colorState = 1; + } + } +#endif + #ifdef T_WATCH_S3 drv.go(); #endif @@ -229,6 +264,15 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) #ifdef UNPHONE unphone.rgb(red, green, blue); #endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - red); + analogWrite(RGBLED_GREEN, 255 - green); + analogWrite(RGBLED_BLUE, 255 - blue); +#elifdef RGBLED_RED + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); +#endif #ifdef T_WATCH_S3 drv.go(); #endif @@ -271,6 +315,21 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) blue = 0; unphone.rgb(red, green, blue); #endif +#ifdef RGBLED_CA + red = 0; + green = 0; + blue = 0; + analogWrite(RGBLED_RED, 255 - red); + analogWrite(RGBLED_GREEN, 255 - green); + analogWrite(RGBLED_BLUE, 255 - blue); +#elifdef RGBLED_RED + red = 0; + green = 0; + blue = 0; + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); +#endif #ifdef T_WATCH_S3 drv.stop(); #endif From 0ae76749820d6bc9a069ddfb8b8313ffbc1bbe7d Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 22:18:50 +0100 Subject: [PATCH 009/159] I'm sure there's a cleverer way to do this, but I'm stupid and I didn't find it after a few minutes of searching stack overflow --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d8640bb59..a1f2ebea1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -608,11 +608,15 @@ void setup() #endif #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) - if (rgb_found.type != ScanI2C::DeviceType::NONE || UNPHONE) { + if (rgb_found.type != ScanI2C::DeviceType::NONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } #endif +#ifdef UNPHONE + ambientLightingThread = new AmbientLightingThread(rgb_found.type); +#endif + #ifdef T_WATCH_S3 drv.begin(); drv.selectLibrary(1); From eea85d26ca4328fb7a321e9a98815daf0f62864e Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Fri, 19 Apr 2024 00:28:20 +0100 Subject: [PATCH 010/159] oh god the bugs, they are everywhere, I feel so dirty... --- src/AmbientLightingThread.h | 8 ++++---- src/main.cpp | 6 ++++-- src/modules/ExternalNotificationModule.cpp | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 1425d3266..81c9c85c7 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -59,9 +59,9 @@ class AmbientLightingThread : public concurrency::OSThread return; } LOG_DEBUG("AmbientLightingThread initializing\n"); - pinMode(RGBLED_RED, output); - pinMode(RGBLED_GREEN, output); - pinMode(RGBLED_BLUE, output); + pinMode(RGBLED_RED, OUTPUT); + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); setLighting(); #endif } @@ -111,7 +111,7 @@ class AmbientLightingThread : public concurrency::OSThread analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue); LOG_DEBUG("Initializing Ambient lighting RGB Common Anode w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red); analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green); analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue); diff --git a/src/main.cpp b/src/main.cpp index a1f2ebea1..fd06e8ae9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -611,11 +611,13 @@ void setup() if (rgb_found.type != ScanI2C::DeviceType::NONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } -#endif - #ifdef UNPHONE ambientLightingThread = new AmbientLightingThread(rgb_found.type); #endif +#ifdef RGBLED_RED + ambientLightingThread = new AmbientLightingThread(rgb_found.type); +#endif +#endif #ifdef T_WATCH_S3 drv.begin(); diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index ee3b73efd..4bab90527 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -268,7 +268,7 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_RED, 255 - red); analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); @@ -322,7 +322,7 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) analogWrite(RGBLED_RED, 255 - red); analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) red = 0; green = 0; blue = 0; From 2100f3135e417d8999a8ba9688534644ef82a836 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Fri, 19 Apr 2024 09:25:38 +0100 Subject: [PATCH 011/159] minor edit to have another go at CI --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fd06e8ae9..991fa3648 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -613,8 +613,7 @@ void setup() } #ifdef UNPHONE ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#endif -#ifdef RGBLED_RED +#elifdef RGBLED_RED ambientLightingThread = new AmbientLightingThread(rgb_found.type); #endif #endif From e0513d4078e93b3361145d58d151e706350536b6 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Fri, 19 Apr 2024 09:27:10 +0100 Subject: [PATCH 012/159] ahem, another minor edit to have another go at CI --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 991fa3648..430fa3a6b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -613,7 +613,7 @@ void setup() } #ifdef UNPHONE ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) ambientLightingThread = new AmbientLightingThread(rgb_found.type); #endif #endif From 9170fe0580f7eccd440b446100edca0e604bc16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 20 Apr 2024 16:16:20 +0200 Subject: [PATCH 013/159] Support radar sensor RCWL-9620 on i2c --- platformio.ini | 3 ++- src/configuration.h | 1 + src/detect/ScanI2C.h | 1 + src/detect/ScanI2CTwoWire.cpp | 1 + src/main.cpp | 1 + .../Telemetry/EnvironmentTelemetry.cpp | 25 ++++++++++++++---- .../Telemetry/Sensor/RCWL9620Sensor.cpp | 26 +++++++++++++++++++ src/modules/Telemetry/Sensor/RCWL9620Sensor.h | 17 ++++++++++++ 8 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp create mode 100644 src/modules/Telemetry/Sensor/RCWL9620Sensor.h diff --git a/platformio.ini b/platformio.ini index a1082a84a..01924e290 100644 --- a/platformio.ini +++ b/platformio.ini @@ -132,4 +132,5 @@ lib_deps = adafruit/Adafruit MPU6050@^2.2.4 adafruit/Adafruit LIS3DH@^1.2.4 https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 - adafruit/Adafruit LSM6DS@^4.7.2 \ No newline at end of file + adafruit/Adafruit LSM6DS@^4.7.2 + m5stack/M5Unit-Sonic@^0.0.2 diff --git a/src/configuration.h b/src/configuration.h index 701e07a32..493449764 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -128,6 +128,7 @@ along with this program. If not, see . #define LPS22HB_ADDR_ALT 0x5D #define SHT31_ADDR 0x44 #define PMSA0031_ADDR 0x12 +#define RCWL9620_ADDR 0x57 // ----------------------------------------------------------------------------- // ACCELEROMETER diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..6fb2057b2 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,6 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, + RCWL9620, #ifdef HAS_NCP5623 NCP5623, #endif diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 13c2f4609..53050d39b 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -288,6 +288,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port) 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") case LPS22HB_ADDR_ALT: SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB sensor found\n") diff --git a/src/main.cpp b/src/main.cpp index b1a15634f..3fe9ba185 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -533,6 +533,7 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658) 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) i2cScanner.reset(); diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 189ab7ed0..a8c2f0a8d 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -21,6 +21,7 @@ #include "Sensor/BMP280Sensor.h" #include "Sensor/LPS22HBSensor.h" #include "Sensor/MCP9808Sensor.h" +#include "Sensor/RCWL9620Sensor.h" #include "Sensor/SHT31Sensor.h" #include "Sensor/SHTC3Sensor.h" @@ -32,6 +33,7 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; +RCWL9620Sensor rcwl9620Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true @@ -90,6 +92,8 @@ int32_t EnvironmentTelemetryModule::runOnce() result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) result = ina260Sensor.runOnce(); + if (rcwl9620Sensor.hasSensor()) + result = rcwl9620Sensor.runOnce(); } return result; } else { @@ -183,6 +187,9 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); if (lastMeasurement.variant.environment_metrics.iaq != 0) display->drawString(x, y += fontHeight(FONT_SMALL), "IAQ: " + String(lastMeasurement.variant.environment_metrics.iaq)); + if (lastMeasurement.variant.environment_metrics.water_level != 0) + display->drawString(x, y += fontHeight(FONT_SMALL), + "Water Level: " + String(lastMeasurement.variant.environment_metrics.water_level, 0) + "mm"); } bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) @@ -192,10 +199,13 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, " - "temperature=%f, voltage=%f\n", + "temperature=%f\n", sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, - t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage); + t->variant.environment_metrics.temperature); + LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, water_level=%f\n", sender, t->variant.environment_metrics.voltage, + t->variant.environment_metrics.iaq, t->variant.environment_metrics.water_level); + #endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) @@ -220,6 +230,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.relative_humidity = 0; m.variant.environment_metrics.temperature = 0; m.variant.environment_metrics.voltage = 0; + m.variant.environment_metrics.iaq = 0; + m.variant.environment_metrics.water_level = 0; if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); @@ -241,13 +253,16 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) valid = ina219Sensor.getMetrics(&m); if (ina260Sensor.hasSensor()) valid = ina260Sensor.getMetrics(&m); + if (rcwl9620Sensor.hasSensor()) + valid = rcwl9620Sensor.getMetrics(&m); if (valid) { - LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, " - "voltage=%f\n", + LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f\n", m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, - m.variant.environment_metrics.temperature, m.variant.environment_metrics.voltage); + m.variant.environment_metrics.temperature); + LOG_INFO("(Sending): voltage=%f, IAQ=%d, water_level=%f\n", m.variant.environment_metrics.voltage, + m.variant.environment_metrics.iaq, m.variant.environment_metrics.water_level); sensor_read_error_count = 0; diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp new file mode 100644 index 000000000..d27dd459e --- /dev/null +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -0,0 +1,26 @@ +#include "RCWL9620Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" + +RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RCWL9620, "RCWL9620") {} + +int32_t RCWL9620Sensor::runOnce() +{ + LOG_INFO("Init sensor: %s\n", sensorName); + if (!hasSensor()) { + return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; + } + status = 1; + rcwl9620.begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first, -1, -1); + return initI2CSensor(); +} + +void RCWL9620Sensor::setup() {} + +bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) +{ + LOG_DEBUG("RCWL9620Sensor::getMetrics\n"); + measurement->variant.environment_metrics.water_level = rcwl9620.getDistance(); + return true; +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h new file mode 100644 index 000000000..d3efe0ef5 --- /dev/null +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h @@ -0,0 +1,17 @@ +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +class RCWL9620Sensor : public TelemetrySensor +{ + private: + SONIC_I2C rcwl9620; + + protected: + virtual void setup() override; + + public: + RCWL9620Sensor(); + virtual int32_t runOnce() override; + virtual bool getMetrics(meshtastic_Telemetry *measurement) override; +}; \ No newline at end of file From 94e1f016e57021a891f0cbd45bac0c910db11303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 20 Apr 2024 20:49:57 +0200 Subject: [PATCH 014/159] Change name --- src/modules/Telemetry/EnvironmentTelemetry.cpp | 14 +++++++------- src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index a8c2f0a8d..bbd734b5a 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -187,9 +187,9 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); if (lastMeasurement.variant.environment_metrics.iaq != 0) display->drawString(x, y += fontHeight(FONT_SMALL), "IAQ: " + String(lastMeasurement.variant.environment_metrics.iaq)); - if (lastMeasurement.variant.environment_metrics.water_level != 0) + if (lastMeasurement.variant.environment_metrics.distance != 0) display->drawString(x, y += fontHeight(FONT_SMALL), - "Water Level: " + String(lastMeasurement.variant.environment_metrics.water_level, 0) + "mm"); + "Water Level: " + String(lastMeasurement.variant.environment_metrics.distance, 0) + "mm"); } bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) @@ -203,8 +203,8 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, t->variant.environment_metrics.temperature); - LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, water_level=%f\n", sender, t->variant.environment_metrics.voltage, - t->variant.environment_metrics.iaq, t->variant.environment_metrics.water_level); + LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f\n", sender, t->variant.environment_metrics.voltage, + t->variant.environment_metrics.iaq, t->variant.environment_metrics.distance); #endif // release previous packet before occupying a new spot @@ -231,7 +231,7 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.temperature = 0; m.variant.environment_metrics.voltage = 0; m.variant.environment_metrics.iaq = 0; - m.variant.environment_metrics.water_level = 0; + m.variant.environment_metrics.distance = 0; if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); @@ -261,8 +261,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, m.variant.environment_metrics.temperature); - LOG_INFO("(Sending): voltage=%f, IAQ=%d, water_level=%f\n", m.variant.environment_metrics.voltage, - m.variant.environment_metrics.iaq, m.variant.environment_metrics.water_level); + LOG_INFO("(Sending): voltage=%f, IAQ=%d, distance=%f\n", m.variant.environment_metrics.voltage, + m.variant.environment_metrics.iaq, m.variant.environment_metrics.distance); sensor_read_error_count = 0; diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp index d27dd459e..96e9a7445 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -21,6 +21,6 @@ void RCWL9620Sensor::setup() {} bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) { LOG_DEBUG("RCWL9620Sensor::getMetrics\n"); - measurement->variant.environment_metrics.water_level = rcwl9620.getDistance(); + measurement->variant.environment_metrics.distance = rcwl9620.getDistance(); return true; } \ No newline at end of file From fb7a878d94874c116191c51784e89e002d5dca65 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 08:24:51 +0100 Subject: [PATCH 015/159] tweaked guards to allow various combinations of RGB leds --- src/detect/ScanI2C.h | 2 +- src/main.cpp | 11 +- src/modules/ExternalNotificationModule.cpp | 155 +++++++++------------ 3 files changed, 68 insertions(+), 100 deletions(-) diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..f2069cd09 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,7 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, -#ifdef HAS_NCP5623 +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) NCP5623, #endif } DeviceType; diff --git a/src/main.cpp b/src/main.cpp index 430fa3a6b..4d741d32e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -607,15 +607,14 @@ void setup() } #endif -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) +#ifdef UNPHONE + ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); +#elif defined(RGBLED_RED) + ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); +#elif !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) if (rgb_found.type != ScanI2C::DeviceType::NONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } -#ifdef UNPHONE - ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#elif defined(RGBLED_RED) - ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#endif #endif #ifdef T_WATCH_S3 diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 4bab90527..bc48e419b 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -26,29 +26,14 @@ #ifdef HAS_NCP5623 #include - -uint8_t red = 0; -uint8_t green = 0; -uint8_t blue = 0; -uint8_t colorState = 1; -uint8_t brightnessIndex = 0; -uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets multiplied by 1.5 -bool ascending = true; #endif #ifdef UNPHONE #include "unPhone.h" extern unPhone unphone; - -uint8_t red = 0; -uint8_t green = 0; -uint8_t blue = 0; -uint8_t colorState = 1; -const uint8_t duration = 15; -uint8_t counter = 0; #endif -#ifdef RGBLED_RED +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) uint8_t red = 0; uint8_t green = 0; uint8_t blue = 0; @@ -130,53 +115,27 @@ int32_t ExternalNotificationModule::runOnce() millis()) { getExternal(2) ? setExternalOff(2) : setExternalOn(2); } -#ifdef HAS_NCP5623 - if (rgb_found.type == ScanI2C::NCP5623) { - red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 - green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 - blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 - rgb.setColor(red, green, blue); - - if (ascending) { // fade in - brightnessIndex++; - if (brightnessIndex == (sizeof(brightnessValues) - 1)) { - ascending = false; - } - } else { - brightnessIndex--; // fade out - } - if (brightnessIndex == 0) { - ascending = true; - colorState++; // next color - if (colorState > 7) { - colorState = 1; - } - } - } -#endif - -#ifdef UNPHONE - red = colorState & 4; // Red enabled on colorState = 4,5,6,7 - green = colorState & 2; // Green enabled on colorState = 2,3,6,7 - blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 - unphone.rgb(red, green, blue); - counter++; // tick on - if (counter > duration) { - counter = 0; - colorState++; // next color - if (colorState > 7) { - colorState = 1; - } - } -#endif - -#ifdef RGBLED_RED +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 +#ifdef HAS_NCP5623 + if (rgb_found.type == ScanI2C::NCP5623) { + rgb.setColor(red, green, blue); + } +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); +#endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic + analogWrite(RGBLED_GREEN, 255 - green); + analogWrite(RGBLED_BLUE, 255 - blue); +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); +#endif if (ascending) { // fade in brightnessIndex++; if (brightnessIndex == (sizeof(brightnessValues) - 1)) { @@ -192,35 +151,35 @@ int32_t ExternalNotificationModule::runOnce() colorState = 1; } } + } #endif #ifdef T_WATCH_S3 - drv.go(); + drv.go(); #endif - } - - // Play RTTTL over i2s audio interface if enabled as buzzer -#ifdef HAS_I2S - if (moduleConfig.external_notification.use_i2s_as_buzzer) { - if (audioThread->isPlaying()) { - // Continue playing - } else if (isNagging && (nagCycleCutoff >= millis())) { - audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); - } - } -#endif - // now let the PWM buzzer play - if (moduleConfig.external_notification.use_pwm) { - if (rtttl::isPlaying()) { - rtttl::play(); - } else if (isNagging && (nagCycleCutoff >= millis())) { - // start the song again if we have time left - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); - } - } - - return EXT_NOTIFICATION_DEFAULT_THREAD_MS; } + + // Play RTTTL over i2s audio interface if enabled as buzzer +#ifdef HAS_I2S + if (moduleConfig.external_notification.use_i2s_as_buzzer) { + if (audioThread->isPlaying()) { + // Continue playing + } else if (isNagging && (nagCycleCutoff >= millis())) { + audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + } + } +#endif + // now let the PWM buzzer play + if (moduleConfig.external_notification.use_pwm) { + if (rtttl::isPlaying()) { + rtttl::play(); + } else if (isNagging && (nagCycleCutoff >= millis())) { + // start the song again if we have time left + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + } + } + + return EXT_NOTIFICATION_DEFAULT_THREAD_MS; } bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p) @@ -265,13 +224,13 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) unphone.rgb(red, green, blue); #endif #ifdef RGBLED_CA - analogWrite(RGBLED_RED, 255 - red); + analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); #elif defined(RGBLED_RED) - analogWrite(RGBLED_RED, red); - analogWrite(RGBLED_GREEN, green); - analogWrite(RGBLED_BLUE, blue); + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -315,21 +274,21 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) blue = 0; unphone.rgb(red, green, blue); #endif -#ifdef RGBLED_CA +#ifdef RGBLED_RED red = 0; green = 0; blue = 0; - analogWrite(RGBLED_RED, 255 - red); +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#elif defined(RGBLED_RED) - red = 0; - green = 0; - blue = 0; +#else analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); #endif +#endif + #ifdef T_WATCH_S3 drv.stop(); #endif @@ -427,6 +386,16 @@ ExternalNotificationModule::ExternalNotificationModule() rgb.begin(); rgb.setCurrent(10); } +#endif +#ifdef RGBLED_RED + pinMode(RGBLED_RED, OUTPUT); // set up the RGB led pins + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); +#endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255); // with a common anode type, logic is reversed + analogWrite(RGBLED_GREEN, 255); // so we want to initialise with lights off + analogWrite(RGBLED_BLUE, 255); #endif } else { LOG_INFO("External Notification Module Disabled\n"); @@ -489,7 +458,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP #ifdef HAS_I2S audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { @@ -533,7 +502,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); } #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { From cf65661c7ca9bce3e470d7f744df219c6af0d525 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 08:59:40 +0100 Subject: [PATCH 016/159] another silly error --- src/AmbientLightingThread.h | 40 ++++++------------ src/modules/ExternalNotificationModule.cpp | 48 +++++++++++----------- 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 81c9c85c7..2febc3d8c 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -32,56 +32,42 @@ class AmbientLightingThread : public concurrency::OSThread disable(); return; } +#endif +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) if (!moduleConfig.ambient_lighting.led_state) { LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); disable(); return; } LOG_DEBUG("AmbientLightingThread initializing\n"); +#ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623) { rgb.begin(); - setLighting(); - } -#endif -#ifdef UNPHONE - if (!moduleConfig.ambient_lighting.led_state) { - LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); - disable(); - return; - } - LOG_DEBUG("AmbientLightingThread initializing\n"); - setLighting(); #endif #ifdef RGBLED_RED - if (!moduleConfig.ambient_lighting.led_state) { - LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); - disable(); - return; + pinMode(RGBLED_RED, OUTPUT); + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); +#endif + setLighting(); +#endif +#ifdef HAS_NCP5623 } - LOG_DEBUG("AmbientLightingThread initializing\n"); - pinMode(RGBLED_RED, OUTPUT); - pinMode(RGBLED_GREEN, OUTPUT); - pinMode(RGBLED_BLUE, OUTPUT); - setLighting(); #endif } protected: int32_t runOnce() override { +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) #ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { +#endif setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#ifdef HAS_NCP5623 } #endif -#ifdef UNPHONE - setLighting(); - return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification -#endif -#ifdef RGBLED_RED - setLighting(); - return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification #endif return disable(); } diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index bc48e419b..236178498 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -151,35 +151,35 @@ int32_t ExternalNotificationModule::runOnce() colorState = 1; } } - } #endif #ifdef T_WATCH_S3 - drv.go(); + drv.go(); #endif - } + } - // Play RTTTL over i2s audio interface if enabled as buzzer + // Play RTTTL over i2s audio interface if enabled as buzzer #ifdef HAS_I2S - if (moduleConfig.external_notification.use_i2s_as_buzzer) { - if (audioThread->isPlaying()) { - // Continue playing - } else if (isNagging && (nagCycleCutoff >= millis())) { - audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + if (moduleConfig.external_notification.use_i2s_as_buzzer) { + if (audioThread->isPlaying()) { + // Continue playing + } else if (isNagging && (nagCycleCutoff >= millis())) { + audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + } } - } #endif - // now let the PWM buzzer play - if (moduleConfig.external_notification.use_pwm) { - if (rtttl::isPlaying()) { - rtttl::play(); - } else if (isNagging && (nagCycleCutoff >= millis())) { - // start the song again if we have time left - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + // now let the PWM buzzer play + if (moduleConfig.external_notification.use_pwm) { + if (rtttl::isPlaying()) { + rtttl::play(); + } else if (isNagging && (nagCycleCutoff >= millis())) { + // start the song again if we have time left + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + } } - } - return EXT_NOTIFICATION_DEFAULT_THREAD_MS; + return EXT_NOTIFICATION_DEFAULT_THREAD_MS; + } } bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p) @@ -228,9 +228,9 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); #elif defined(RGBLED_RED) - analogWrite(RGBLED_RED, red); - analogWrite(RGBLED_GREEN, green); - analogWrite(RGBLED_BLUE, blue); + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -458,7 +458,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP #ifdef HAS_I2S audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { @@ -502,7 +502,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); } #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { From 9e4ef92e6d9343d7209529799708c24a1f9eb8a0 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 09:16:50 +0100 Subject: [PATCH 017/159] lets just define it without guards! --- src/detect/ScanI2C.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index f2069cd09..05a5cb2ea 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,9 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) NCP5623, -#endif } DeviceType; // typedef uint8_t DeviceAddress; From c480f0870cee559f61ba99c8c23bb7fd6a4df937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 20 Apr 2024 16:16:20 +0200 Subject: [PATCH 018/159] Support radar sensor RCWL-9620 on i2c --- platformio.ini | 3 ++- src/configuration.h | 1 + src/detect/ScanI2C.h | 1 + src/detect/ScanI2CTwoWire.cpp | 1 + src/main.cpp | 1 + .../Telemetry/EnvironmentTelemetry.cpp | 25 ++++++++++++++---- .../Telemetry/Sensor/RCWL9620Sensor.cpp | 26 +++++++++++++++++++ src/modules/Telemetry/Sensor/RCWL9620Sensor.h | 17 ++++++++++++ 8 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp create mode 100644 src/modules/Telemetry/Sensor/RCWL9620Sensor.h diff --git a/platformio.ini b/platformio.ini index a1082a84a..01924e290 100644 --- a/platformio.ini +++ b/platformio.ini @@ -132,4 +132,5 @@ lib_deps = adafruit/Adafruit MPU6050@^2.2.4 adafruit/Adafruit LIS3DH@^1.2.4 https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 - adafruit/Adafruit LSM6DS@^4.7.2 \ No newline at end of file + adafruit/Adafruit LSM6DS@^4.7.2 + m5stack/M5Unit-Sonic@^0.0.2 diff --git a/src/configuration.h b/src/configuration.h index 701e07a32..493449764 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -128,6 +128,7 @@ along with this program. If not, see . #define LPS22HB_ADDR_ALT 0x5D #define SHT31_ADDR 0x44 #define PMSA0031_ADDR 0x12 +#define RCWL9620_ADDR 0x57 // ----------------------------------------------------------------------------- // ACCELEROMETER diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..6fb2057b2 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,6 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, + RCWL9620, #ifdef HAS_NCP5623 NCP5623, #endif diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index e2e2188b6..8ab4e4c7e 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -293,6 +293,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port) 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") case LPS22HB_ADDR_ALT: SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB sensor found\n") diff --git a/src/main.cpp b/src/main.cpp index b1a15634f..3fe9ba185 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -533,6 +533,7 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658) 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) i2cScanner.reset(); diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 189ab7ed0..a8c2f0a8d 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -21,6 +21,7 @@ #include "Sensor/BMP280Sensor.h" #include "Sensor/LPS22HBSensor.h" #include "Sensor/MCP9808Sensor.h" +#include "Sensor/RCWL9620Sensor.h" #include "Sensor/SHT31Sensor.h" #include "Sensor/SHTC3Sensor.h" @@ -32,6 +33,7 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; +RCWL9620Sensor rcwl9620Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true @@ -90,6 +92,8 @@ int32_t EnvironmentTelemetryModule::runOnce() result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) result = ina260Sensor.runOnce(); + if (rcwl9620Sensor.hasSensor()) + result = rcwl9620Sensor.runOnce(); } return result; } else { @@ -183,6 +187,9 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); if (lastMeasurement.variant.environment_metrics.iaq != 0) display->drawString(x, y += fontHeight(FONT_SMALL), "IAQ: " + String(lastMeasurement.variant.environment_metrics.iaq)); + if (lastMeasurement.variant.environment_metrics.water_level != 0) + display->drawString(x, y += fontHeight(FONT_SMALL), + "Water Level: " + String(lastMeasurement.variant.environment_metrics.water_level, 0) + "mm"); } bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) @@ -192,10 +199,13 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, " - "temperature=%f, voltage=%f\n", + "temperature=%f\n", sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, - t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage); + t->variant.environment_metrics.temperature); + LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, water_level=%f\n", sender, t->variant.environment_metrics.voltage, + t->variant.environment_metrics.iaq, t->variant.environment_metrics.water_level); + #endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) @@ -220,6 +230,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.relative_humidity = 0; m.variant.environment_metrics.temperature = 0; m.variant.environment_metrics.voltage = 0; + m.variant.environment_metrics.iaq = 0; + m.variant.environment_metrics.water_level = 0; if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); @@ -241,13 +253,16 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) valid = ina219Sensor.getMetrics(&m); if (ina260Sensor.hasSensor()) valid = ina260Sensor.getMetrics(&m); + if (rcwl9620Sensor.hasSensor()) + valid = rcwl9620Sensor.getMetrics(&m); if (valid) { - LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, " - "voltage=%f\n", + LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f\n", m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, - m.variant.environment_metrics.temperature, m.variant.environment_metrics.voltage); + m.variant.environment_metrics.temperature); + LOG_INFO("(Sending): voltage=%f, IAQ=%d, water_level=%f\n", m.variant.environment_metrics.voltage, + m.variant.environment_metrics.iaq, m.variant.environment_metrics.water_level); sensor_read_error_count = 0; diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp new file mode 100644 index 000000000..d27dd459e --- /dev/null +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -0,0 +1,26 @@ +#include "RCWL9620Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" + +RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RCWL9620, "RCWL9620") {} + +int32_t RCWL9620Sensor::runOnce() +{ + LOG_INFO("Init sensor: %s\n", sensorName); + if (!hasSensor()) { + return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; + } + status = 1; + rcwl9620.begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first, -1, -1); + return initI2CSensor(); +} + +void RCWL9620Sensor::setup() {} + +bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) +{ + LOG_DEBUG("RCWL9620Sensor::getMetrics\n"); + measurement->variant.environment_metrics.water_level = rcwl9620.getDistance(); + return true; +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h new file mode 100644 index 000000000..d3efe0ef5 --- /dev/null +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h @@ -0,0 +1,17 @@ +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +class RCWL9620Sensor : public TelemetrySensor +{ + private: + SONIC_I2C rcwl9620; + + protected: + virtual void setup() override; + + public: + RCWL9620Sensor(); + virtual int32_t runOnce() override; + virtual bool getMetrics(meshtastic_Telemetry *measurement) override; +}; \ No newline at end of file From 5218aaafcf039c6edbbc470cf8065b97cfc6e5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 20 Apr 2024 20:49:57 +0200 Subject: [PATCH 019/159] Change name --- src/modules/Telemetry/EnvironmentTelemetry.cpp | 14 +++++++------- src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index a8c2f0a8d..bbd734b5a 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -187,9 +187,9 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); if (lastMeasurement.variant.environment_metrics.iaq != 0) display->drawString(x, y += fontHeight(FONT_SMALL), "IAQ: " + String(lastMeasurement.variant.environment_metrics.iaq)); - if (lastMeasurement.variant.environment_metrics.water_level != 0) + if (lastMeasurement.variant.environment_metrics.distance != 0) display->drawString(x, y += fontHeight(FONT_SMALL), - "Water Level: " + String(lastMeasurement.variant.environment_metrics.water_level, 0) + "mm"); + "Water Level: " + String(lastMeasurement.variant.environment_metrics.distance, 0) + "mm"); } bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) @@ -203,8 +203,8 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, t->variant.environment_metrics.temperature); - LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, water_level=%f\n", sender, t->variant.environment_metrics.voltage, - t->variant.environment_metrics.iaq, t->variant.environment_metrics.water_level); + LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f\n", sender, t->variant.environment_metrics.voltage, + t->variant.environment_metrics.iaq, t->variant.environment_metrics.distance); #endif // release previous packet before occupying a new spot @@ -231,7 +231,7 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.temperature = 0; m.variant.environment_metrics.voltage = 0; m.variant.environment_metrics.iaq = 0; - m.variant.environment_metrics.water_level = 0; + m.variant.environment_metrics.distance = 0; if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); @@ -261,8 +261,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, m.variant.environment_metrics.temperature); - LOG_INFO("(Sending): voltage=%f, IAQ=%d, water_level=%f\n", m.variant.environment_metrics.voltage, - m.variant.environment_metrics.iaq, m.variant.environment_metrics.water_level); + LOG_INFO("(Sending): voltage=%f, IAQ=%d, distance=%f\n", m.variant.environment_metrics.voltage, + m.variant.environment_metrics.iaq, m.variant.environment_metrics.distance); sensor_read_error_count = 0; diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp index d27dd459e..96e9a7445 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -21,6 +21,6 @@ void RCWL9620Sensor::setup() {} bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) { LOG_DEBUG("RCWL9620Sensor::getMetrics\n"); - measurement->variant.environment_metrics.water_level = rcwl9620.getDistance(); + measurement->variant.environment_metrics.distance = rcwl9620.getDistance(); return true; } \ No newline at end of file From 402b0d7e0bb41c2437f94e346ab1f35b2d597345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 21 Apr 2024 14:39:55 +0200 Subject: [PATCH 020/159] ditch that no-good m5 dependancy and do it ourself --- platformio.ini | 1 - .../Telemetry/Sensor/RCWL9620Sensor.cpp | 41 +++++++++++++++++-- src/modules/Telemetry/Sensor/RCWL9620Sensor.h | 8 +++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 01924e290..89c69013d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -133,4 +133,3 @@ lib_deps = adafruit/Adafruit LIS3DH@^1.2.4 https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 adafruit/Adafruit LSM6DS@^4.7.2 - m5stack/M5Unit-Sonic@^0.0.2 diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp index 96e9a7445..84003188e 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -11,8 +11,7 @@ int32_t RCWL9620Sensor::runOnce() if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = 1; - rcwl9620.begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first, -1, -1); + status = begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); return initI2CSensor(); } @@ -21,6 +20,42 @@ void RCWL9620Sensor::setup() {} bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) { LOG_DEBUG("RCWL9620Sensor::getMetrics\n"); - measurement->variant.environment_metrics.distance = rcwl9620.getDistance(); + measurement->variant.environment_metrics.distance = getDistance(); return true; +} + +bool RCWL9620Sensor::begin(uint8_t addr, TwoWire *wire) +{ + _wire = wire; + _addr = addr; + if (i2c_dev) + delete i2c_dev; + i2c_dev = new Adafruit_I2CDevice(_addr, _wire); + if (!i2c_dev->begin()) + return false; + return true; +} + +float RCWL9620Sensor::getDistance() +{ + uint32_t data; + _wire->beginTransmission(_addr); // Transfer data to addr. + _wire->write(0x01); + _wire->endTransmission(); // Stop data transmission with the Ultrasonic + // Unit. + + _wire->requestFrom(_addr, + (uint8_t)3); // Request 3 bytes from Ultrasonic Unit. + + data = _wire->read(); + data <<= 8; + data |= _wire->read(); + data <<= 8; + data |= _wire->read(); + float Distance = float(data) / 1000; + if (Distance > 4500.00) { + return 4500.00; + } else { + return Distance; + } } \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h index d3efe0ef5..4120e19d9 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h @@ -1,14 +1,18 @@ #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include +#include class RCWL9620Sensor : public TelemetrySensor { private: - SONIC_I2C rcwl9620; + uint8_t _addr; + TwoWire *_wire; protected: virtual void setup() override; + bool begin(uint8_t addr = 0x57, TwoWire *wire = &Wire); + Adafruit_I2CDevice *i2c_dev = NULL; + float getDistance(); public: RCWL9620Sensor(); From a231cd2ad0463d8a89cba6bb74753dc4a216dba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 21 Apr 2024 16:35:41 +0200 Subject: [PATCH 021/159] derp... --- src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp | 15 +++++++-------- src/modules/Telemetry/Sensor/RCWL9620Sensor.h | 8 +++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp index 84003188e..03df57efd 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -11,7 +11,8 @@ int32_t RCWL9620Sensor::runOnce() if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); + status = 1; + begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first); return initI2CSensor(); } @@ -24,16 +25,14 @@ bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) return true; } -bool RCWL9620Sensor::begin(uint8_t addr, TwoWire *wire) +void RCWL9620Sensor::begin(TwoWire *wire, uint8_t addr, uint8_t sda, uint8_t scl, uint32_t speed) { _wire = wire; _addr = addr; - if (i2c_dev) - delete i2c_dev; - i2c_dev = new Adafruit_I2CDevice(_addr, _wire); - if (!i2c_dev->begin()) - return false; - return true; + _sda = sda; + _scl = scl; + _speed = speed; + _wire->begin(); } float RCWL9620Sensor::getDistance() diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h index 4120e19d9..4fb2aec2d 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h @@ -1,17 +1,19 @@ #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include +#include class RCWL9620Sensor : public TelemetrySensor { private: uint8_t _addr; TwoWire *_wire; + uint8_t _scl; + uint8_t _sda; + uint8_t _speed; protected: virtual void setup() override; - bool begin(uint8_t addr = 0x57, TwoWire *wire = &Wire); - Adafruit_I2CDevice *i2c_dev = NULL; + void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000L); float getDistance(); public: From 5dd08e95330f009f79f04963711a73092289dece Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 14:42:52 +0100 Subject: [PATCH 022/159] added NeoPixel support using Adafruit library --- src/AmbientLightingThread.h | 31 ++++++++--- src/main.cpp | 4 +- src/modules/ExternalNotificationModule.cpp | 61 ++++++++++++++-------- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 2febc3d8c..6b3360b1f 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -5,6 +5,11 @@ NCP5623 rgb; #endif +#ifdef HAS_NEOPIXEL +#include +Adafruit_NeoPixel pixels(NEOPIXEL_COUNT, NEOPIXEL_DATA, NEOPIXEL_TYPE); +#endif + #ifdef UNPHONE #include "unPhone.h" extern unPhone unphone; @@ -33,7 +38,7 @@ class AmbientLightingThread : public concurrency::OSThread return; } #endif -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) if (!moduleConfig.ambient_lighting.led_state) { LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); disable(); @@ -48,6 +53,11 @@ class AmbientLightingThread : public concurrency::OSThread pinMode(RGBLED_RED, OUTPUT); pinMode(RGBLED_GREEN, OUTPUT); pinMode(RGBLED_BLUE, OUTPUT); +#endif +#ifdef HAS_NEOPIXEL + pixels.begin(); // Initialise the pixel(s) + pixels.clear(); // Set all pixel colors to 'off' + pixels.setBrightness(moduleConfig.ambient_lighting.current); #endif setLighting(); #endif @@ -59,7 +69,7 @@ class AmbientLightingThread : public concurrency::OSThread protected: int32_t runOnce() override { -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) #ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { #endif @@ -86,10 +96,14 @@ class AmbientLightingThread : public concurrency::OSThread moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif -#ifdef UNPHONE - unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); - LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, - moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, + moduleConfig.ambient_lighting.blue), + 0, NEOPIXEL_COUNT); + pixels.show(); + LOG_DEBUG("Initializing NeoPixel Ambient lighting w/ brightness(current)=%d, red=%d, green=%d, blue=%d\n", + moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, + moduleConfig.ambient_lighting.blue); #endif #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red); @@ -103,6 +117,11 @@ class AmbientLightingThread : public concurrency::OSThread analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue); LOG_DEBUG("Initializing Ambient lighting RGB Common Cathode w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#endif +#ifdef UNPHONE + unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, + moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif } }; diff --git a/src/main.cpp b/src/main.cpp index 4d741d32e..c142ae15a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -607,9 +607,7 @@ void setup() } #endif -#ifdef UNPHONE - ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); -#elif defined(RGBLED_RED) +#if defined(HAS_NEOPIXEL) || defined(UNPHONE) || defined(RGBLED_RED) ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); #elif !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) if (rgb_found.type != ScanI2C::DeviceType::NONE) { diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 94e0aeadc..c02559240 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -28,12 +28,16 @@ #include #endif +#ifdef HAS_NEOPIXEL +#include +#endif + #ifdef UNPHONE #include "unPhone.h" extern unPhone unphone; #endif -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) uint8_t red = 0; uint8_t green = 0; uint8_t blue = 0; @@ -115,7 +119,7 @@ int32_t ExternalNotificationModule::runOnce() millis()) { getExternal(2) ? setExternalOff(2) : setExternalOn(2); } -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 @@ -124,9 +128,6 @@ int32_t ExternalNotificationModule::runOnce() rgb.setColor(red, green, blue); } #endif -#ifdef UNPHONE - unphone.rgb(red, green, blue); -#endif #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); @@ -135,6 +136,13 @@ int32_t ExternalNotificationModule::runOnce() analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); +#endif +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); + pixels.show(); +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); #endif if (ascending) { // fade in brightnessIndex++; @@ -220,9 +228,6 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) rgb.setColor(red, green, blue); } #endif -#ifdef UNPHONE - unphone.rgb(red, green, blue); -#endif #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); @@ -232,6 +237,13 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); #endif +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); + pixels.show(); +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); +#endif #ifdef T_WATCH_S3 drv.go(); #endif @@ -260,33 +272,31 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) break; } +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) + red = 0; + green = 0; + blue = 0; #ifdef HAS_NCP5623 if (rgb_found.type == ScanI2C::NCP5623) { - red = 0; - green = 0; - blue = 0; rgb.setColor(red, green, blue); } #endif -#ifdef UNPHONE - red = 0; - green = 0; - blue = 0; - unphone.rgb(red, green, blue); -#endif -#ifdef RGBLED_RED - red = 0; - green = 0; - blue = 0; #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#else +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); #endif +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); + pixels.show(); +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); +#endif #endif #ifdef T_WATCH_S3 @@ -397,6 +407,11 @@ ExternalNotificationModule::ExternalNotificationModule() analogWrite(RGBLED_RED, 255); // with a common anode type, logic is reversed analogWrite(RGBLED_GREEN, 255); // so we want to initialise with lights off analogWrite(RGBLED_BLUE, 255); +#endif +#ifdef HAS_NEOPIXEL + pixels.begin(); // Initialise the pixel(s) + pixels.clear(); // Set all pixel colors to 'off' + pixels.setBrightness(moduleConfig.ambient_lighting.current); #endif } else { LOG_INFO("External Notification Module Disabled\n"); @@ -578,4 +593,4 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) if (changed) { nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } -} \ No newline at end of file +} From ec2b854ea28bfc91f33b1ae92678b544afea1872 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 14:44:59 +0100 Subject: [PATCH 023/159] oops missed the extern enabling little chap --- src/graphics/NeoPixel.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/graphics/NeoPixel.h diff --git a/src/graphics/NeoPixel.h b/src/graphics/NeoPixel.h new file mode 100644 index 000000000..dde74366e --- /dev/null +++ b/src/graphics/NeoPixel.h @@ -0,0 +1,4 @@ +#ifdef HAS_NEOPIXEL +#include +extern Adafruit_NeoPixel pixels; +#endif \ No newline at end of file From 6669b22db386dd0dd40c7315fbf4c1a45d0e4d5c Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 16:37:05 +0100 Subject: [PATCH 024/159] tidied up, prob broke everything --- .../Dongle_nRF52840-pca10059-v1/variant.cpp | 7 ++----- .../Dongle_nRF52840-pca10059-v1/variant.h | 21 +++++-------------- variants/betafpv_2400_tx_micro/platformio.ini | 2 +- variants/betafpv_2400_tx_micro/variant.h | 9 +++++--- variants/esp32-s3-pico/platformio.ini | 2 +- variants/esp32-s3-pico/variant.h | 4 ++++ variants/lora_relay_v1/platformio.ini | 3 ++- variants/lora_relay_v1/variant.h | 12 +++++++---- variants/lora_relay_v2/platformio.ini | 1 + variants/lora_relay_v2/variant.h | 13 ++++++++---- variants/my_esp32s3_diy_eink/platformio.ini | 4 ++-- variants/my_esp32s3_diy_eink/variant.h | 4 ++++ variants/my_esp32s3_diy_oled/platformio.ini | 4 ++-- variants/my_esp32s3_diy_oled/variant.h | 6 +++++- variants/unphone/platformio.ini | 4 +++- variants/unphone/variant.cpp | 1 + variants/unphone/variant.h | 13 ++++++++++-- 17 files changed, 67 insertions(+), 43 deletions(-) diff --git a/variants/Dongle_nRF52840-pca10059-v1/variant.cpp b/variants/Dongle_nRF52840-pca10059-v1/variant.cpp index 8c6bf039c..2fc87c718 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/variant.cpp +++ b/variants/Dongle_nRF52840-pca10059-v1/variant.cpp @@ -29,10 +29,7 @@ const uint32_t g_ADigitalPinMap[] = { void initVariant() { - // LED1 & LED2 + // LED1 pinMode(PIN_LED1, OUTPUT); ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); -} +} \ No newline at end of file diff --git a/variants/Dongle_nRF52840-pca10059-v1/variant.h b/variants/Dongle_nRF52840-pca10059-v1/variant.h index 533367a30..aef702c7c 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/variant.h +++ b/variants/Dongle_nRF52840-pca10059-v1/variant.h @@ -43,24 +43,13 @@ extern "C" { #define NUM_ANALOG_OUTPUTS (0) // LEDs -#define PIN_LED1 (0 + 12) // Blue LED P1.12 -#define PIN_LED2 (0 + 6) // Built in Green P0.06 - -// Green Built in LED1 -// #define PIN_LED1 (0 + 6) // LED1 P1.15 - -// RGB NeoPixel LED2 -// #define PIN_LED1 (0 + 8) Red -// #define PIN_LED1 (32 + 9) Green -// #define PIN_LED1 (0 + 12) Blue +#define PIN_LED1 (0 + 6) // Built in Green P0.06 +#define RGBLED_RED (0 + 8) // Red of RGB P0.08 +#define RGBLED_GREEN (32 + 9) // Green of RGB P1.09 +#define RGBLED_BLUE (0 + 12) // Blue of RGB P0.12 +#define RGBLED_CA // comment out this line if you have a common cathode type, as defined use common anode logic #define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_GREEN PIN_LED1 -#define LED_BLUE PIN_LED2 - -#define LED_STATE_ON 0 // State when LED is litted /* * Buttons diff --git a/variants/betafpv_2400_tx_micro/platformio.ini b/variants/betafpv_2400_tx_micro/platformio.ini index 82fe2a9e4..531e8532d 100644 --- a/variants/betafpv_2400_tx_micro/platformio.ini +++ b/variants/betafpv_2400_tx_micro/platformio.ini @@ -15,4 +15,4 @@ upload_protocol = esptool upload_speed = 460800 lib_deps = ${esp32_base.lib_deps} - makuna/NeoPixelBus@^2.7.1 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/betafpv_2400_tx_micro/variant.h b/variants/betafpv_2400_tx_micro/variant.h index 8c615d168..fd06183ee 100644 --- a/variants/betafpv_2400_tx_micro/variant.h +++ b/variants/betafpv_2400_tx_micro/variant.h @@ -1,5 +1,4 @@ // https://betafpv.com/products/elrs-micro-tx-module -#include // 0.96" OLED #define I2C_SDA 22 @@ -15,7 +14,11 @@ #define LORA_CS 5 #define RF95_FAN_EN 17 -#define LED_PIN 16 // This is a LED_WS2812 not a standard LED +// #define LED_PIN 16 // This is a LED_WS2812 not a standard LED +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 16 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define BUTTON_PIN 25 #define BUTTON_NEED_PULLUP @@ -31,4 +34,4 @@ #define SX128X_TXEN 26 #define SX128X_RXEN 27 #define SX128X_RESET LORA_RESET -#define SX128X_MAX_POWER 13 +#define SX128X_MAX_POWER 13 \ No newline at end of file diff --git a/variants/esp32-s3-pico/platformio.ini b/variants/esp32-s3-pico/platformio.ini index ef737d98a..ff77c30e0 100644 --- a/variants/esp32-s3-pico/platformio.ini +++ b/variants/esp32-s3-pico/platformio.ini @@ -22,4 +22,4 @@ build_flags = ${esp32_base.build_flags} lib_deps = ${esp32s3_base.lib_deps} zinggjm/GxEPD2@^1.5.3 - ;adafruit/Adafruit NeoPixel@^1.10.7 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/esp32-s3-pico/variant.h b/variants/esp32-s3-pico/variant.h index 87378d378..bfcb6059d 100644 --- a/variants/esp32-s3-pico/variant.h +++ b/variants/esp32-s3-pico/variant.h @@ -10,6 +10,10 @@ // #define LED_PIN PIN_LED // Board has RGB LED 21 +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 21 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use // The usbPower state is revered ? // DEBUG | ??:??:?? 365 [Power] Battery: usbPower=0, isCharging=0, batMv=4116, batPct=90 diff --git a/variants/lora_relay_v1/platformio.ini b/variants/lora_relay_v1/platformio.ini index 77402aadc..8660bf64a 100644 --- a/variants/lora_relay_v1/platformio.ini +++ b/variants/lora_relay_v1/platformio.ini @@ -20,4 +20,5 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v1> lib_deps = ${nrf52840_base.lib_deps} sparkfun/SparkFun BQ27441 LiPo Fuel Gauge Arduino Library@^1.1.0 - bodmer/TFT_eSPI@^2.4.76 \ No newline at end of file + bodmer/TFT_eSPI@^2.4.76 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/lora_relay_v1/variant.h b/variants/lora_relay_v1/variant.h index 9cfb69337..29fb4cb84 100644 --- a/variants/lora_relay_v1/variant.h +++ b/variants/lora_relay_v1/variant.h @@ -44,15 +44,19 @@ extern "C" { // LEDs #define PIN_LED1 (3) #define PIN_LED2 (4) -#define PIN_NEOPIXEL (8) +// #define PIN_NEOPIXEL (8) +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 8 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 +#define PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define LED_STATE_ON 1 // State when LED is litted +#define 1 // State when LED is litted /* * Buttons @@ -154,4 +158,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file diff --git a/variants/lora_relay_v2/platformio.ini b/variants/lora_relay_v2/platformio.ini index 4439d8a46..cd2109f00 100644 --- a/variants/lora_relay_v2/platformio.ini +++ b/variants/lora_relay_v2/platformio.ini @@ -23,3 +23,4 @@ lib_deps = ${nrf52840_base.lib_deps} sparkfun/SparkFun BQ27441 LiPo Fuel Gauge Arduino Library@^1.1.0 bodmer/TFT_eSPI@^2.4.76 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/lora_relay_v2/variant.h b/variants/lora_relay_v2/variant.h index 3afe8620e..98881a496 100644 --- a/variants/lora_relay_v2/variant.h +++ b/variants/lora_relay_v2/variant.h @@ -61,16 +61,21 @@ extern "C" { // LEDs #define PIN_LED1 (3) #define PIN_LED2 (4) -#define PIN_NEOPIXEL (8) +// #define PIN_NEOPIXEL (8) +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 8 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use + #define PIN_BUZZER (40) #define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 +#define PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define LED_STATE_ON 1 // State when LED is litted +#define 1 // State when LED is litted /* * Buttons @@ -180,4 +185,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file diff --git a/variants/my_esp32s3_diy_eink/platformio.ini b/variants/my_esp32s3_diy_eink/platformio.ini index 966bc580e..e81f2c1ab 100644 --- a/variants/my_esp32s3_diy_eink/platformio.ini +++ b/variants/my_esp32s3_diy_eink/platformio.ini @@ -13,7 +13,7 @@ platform_packages = lib_deps = ${esp32_base.lib_deps} zinggjm/GxEPD2@^1.5.1 - adafruit/Adafruit NeoPixel@^1.10.7 + adafruit/Adafruit NeoPixel @ ^1.12.0 build_unflags = -DARDUINO_USB_MODE=1 build_flags = ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_eink @@ -24,4 +24,4 @@ build_flags = -DEINK_HEIGHT=128 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue - -DARDUINO_USB_MODE=0 + -DARDUINO_USB_MODE=0 \ No newline at end of file diff --git a/variants/my_esp32s3_diy_eink/variant.h b/variants/my_esp32s3_diy_eink/variant.h index 516fa7f34..024f912dd 100644 --- a/variants/my_esp32s3_diy_eink/variant.h +++ b/variants/my_esp32s3_diy_eink/variant.h @@ -12,6 +12,10 @@ #define I2C_SCL 17 // 2 // #define LED_PIN 38 // This is a RGB LED not a standard LED +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 38 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define BUTTON_PIN 0 // This is the BOOT button #define BUTTON_NEED_PULLUP diff --git a/variants/my_esp32s3_diy_oled/platformio.ini b/variants/my_esp32s3_diy_oled/platformio.ini index 9b8b09f7f..2d7a5cd91 100644 --- a/variants/my_esp32s3_diy_oled/platformio.ini +++ b/variants/my_esp32s3_diy_oled/platformio.ini @@ -12,11 +12,11 @@ platform_packages = tool-esptoolpy@^1.40500.0 lib_deps = ${esp32_base.lib_deps} - adafruit/Adafruit NeoPixel@^1.10.7 + adafruit/Adafruit NeoPixel @ ^1.12.0 build_unflags = -DARDUINO_USB_MODE=1 build_flags = ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_oled ${esp32_base.build_flags} -D PRIVATE_HW -I variants/my_esp32s3_diy_oled -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue - -DARDUINO_USB_MODE=0 + -DARDUINO_USB_MODE=0 \ No newline at end of file diff --git a/variants/my_esp32s3_diy_oled/variant.h b/variants/my_esp32s3_diy_oled/variant.h index 6dd18c236..8a3a39003 100644 --- a/variants/my_esp32s3_diy_oled/variant.h +++ b/variants/my_esp32s3_diy_oled/variant.h @@ -12,6 +12,10 @@ #define I2C_SCL 17 // 2 // #define LED_PIN 38 // This is a RGB LED not a standard LED +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 38 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define BUTTON_PIN 0 // This is the BOOT button #define BUTTON_NEED_PULLUP @@ -53,4 +57,4 @@ // #define PIN_EINK_DC 1 // #define PIN_EINK_RES (-1) // #define PIN_EINK_SCLK 5 -// #define PIN_EINK_MOSI 6 +// #define PIN_EINK_MOSI 6 \ No newline at end of file diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index dad9a7177..407976c48 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -13,6 +13,7 @@ build_unflags = -D ARDUINO_USB_MODE build_flags = ${esp32_base.build_flags} + -D BOARD_HAS_PSRAM -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 @@ -27,4 +28,5 @@ build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> lib_deps = ${esp32s3_base.lib_deps} lovyan03/LovyanGFX @ ^1.1.8 - https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 \ No newline at end of file + https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/unphone/variant.cpp b/variants/unphone/variant.cpp index 3f6d1c54d..7884f82e3 100644 --- a/variants/unphone/variant.cpp +++ b/variants/unphone/variant.cpp @@ -10,6 +10,7 @@ void initVariant() unphone.printWakeupReason(); // what woke us up? (stored, not printed :|) unphone.checkPowerSwitch(); // if power switch is off, shutdown unphone.backlight(false); // setup backlight and make sure its off + unphone.expanderPower(true); // enable power to expander / hat / sheild for (int i = 0; i < 3; i++) { // buzz a bit unphone.vibe(true); diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index 180fdfe2c..a3f2fce8c 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -1,7 +1,16 @@ // meshtastic/firmware/variants/unphone/variant.h #pragma once - +// RGB LED configuration +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA A0 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) #define SPI_SCK 39 #define SPI_MOSI 40 #define SPI_MISO 41 @@ -38,7 +47,7 @@ #define SCREEN_TRANSITION_FRAMERATE 5 #define HAS_TOUCHSCREEN 1 -#define USE_XPT2046 1 +#define USE_XPT2046 #define TOUCH_CS 38 #define HAS_GPS \ From ccbf635eef944d7d3fea9a9bb19440b94bafbfed Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 17:21:41 +0100 Subject: [PATCH 025/159] corrected a bit of overzealous tidying --- variants/Dongle_nRF52840-pca10059-v1/variant.h | 9 ++++++++- variants/lora_relay_v1/variant.h | 6 +++--- variants/lora_relay_v2/variant.h | 6 +++--- variants/unphone/platformio.ini | 2 +- variants/unphone/variant.h | 13 ++----------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/variants/Dongle_nRF52840-pca10059-v1/variant.h b/variants/Dongle_nRF52840-pca10059-v1/variant.h index aef702c7c..2318450eb 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/variant.h +++ b/variants/Dongle_nRF52840-pca10059-v1/variant.h @@ -44,12 +44,19 @@ extern "C" { // LEDs #define PIN_LED1 (0 + 6) // Built in Green P0.06 +#define PIN_LED2 (0 + 6) // Just here for completeness #define RGBLED_RED (0 + 8) // Red of RGB P0.08 #define RGBLED_GREEN (32 + 9) // Green of RGB P1.09 #define RGBLED_BLUE (0 + 12) // Blue of RGB P0.12 #define RGBLED_CA // comment out this line if you have a common cathode type, as defined use common anode logic #define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 0 // State when LED is litted /* * Buttons @@ -157,4 +164,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif diff --git a/variants/lora_relay_v1/variant.h b/variants/lora_relay_v1/variant.h index 29fb4cb84..54bc87b68 100644 --- a/variants/lora_relay_v1/variant.h +++ b/variants/lora_relay_v1/variant.h @@ -51,12 +51,12 @@ extern "C" { #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define LED_BUILTIN PIN_LED1 -#define PIN_LED2 +#define LED_CONN PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define 1 // State when LED is litted +#define LED_STATE_ON 1 // State when LED is litted /* * Buttons @@ -158,4 +158,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif diff --git a/variants/lora_relay_v2/variant.h b/variants/lora_relay_v2/variant.h index 98881a496..6ef7ad7d6 100644 --- a/variants/lora_relay_v2/variant.h +++ b/variants/lora_relay_v2/variant.h @@ -70,12 +70,12 @@ extern "C" { #define PIN_BUZZER (40) #define LED_BUILTIN PIN_LED1 -#define PIN_LED2 +#define LED_CONN PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define 1 // State when LED is litted +#define LED_STATE_ON 1 // State when LED is litted /* * Buttons @@ -185,4 +185,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index 407976c48..e4a92fe4c 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -13,7 +13,7 @@ build_unflags = -D ARDUINO_USB_MODE build_flags = ${esp32_base.build_flags} - -D BOARD_HAS_PSRAM + ;-D BOARD_HAS_PSRAM // what's up with this - doesn't seem to be recognised at boot -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index a3f2fce8c..180fdfe2c 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -1,16 +1,7 @@ // meshtastic/firmware/variants/unphone/variant.h #pragma once -// RGB LED configuration -#define HAS_NEOPIXEL // Enable the use of neopixels -#define NEOPIXEL_COUNT 1 // How many neopixels are connected -#define NEOPIXEL_DATA A0 // gpio pin used to send data to the neopixels -#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + #define SPI_SCK 39 #define SPI_MOSI 40 #define SPI_MISO 41 @@ -47,7 +38,7 @@ #define SCREEN_TRANSITION_FRAMERATE 5 #define HAS_TOUCHSCREEN 1 -#define USE_XPT2046 +#define USE_XPT2046 1 #define TOUCH_CS 38 #define HAS_GPS \ From d0e81b915155fff05f86825e526ed0d7e57715b7 Mon Sep 17 00:00:00 2001 From: Nicholas Baddorf <42445164+nbaddorf@users.noreply.github.com> Date: Tue, 23 Apr 2024 08:09:26 -0400 Subject: [PATCH 026/159] Fixed node and channel selection for t-deck (#3695) This enables the node and channel selection to be accessed by pressing the tab shortcut and then swiping between nodes or pressing tab again to change channels. (To access the tab function look at my other pull request https://github.com/meshtastic/firmware/pull/3668) Co-authored-by: Ben Meadors --- src/modules/CannedMessageModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index cbd6fee72..c80ccc5e7 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -161,10 +161,10 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) if (!event->kbchar) { if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) { this->payload = 0xb4; - this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE; + // this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE; } else if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) { this->payload = 0xb7; - this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE; + // this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE; } } else { // pass the pressed key From 7acaec8ef5148749df167acc9e4ea1d07862a50f Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 23 Apr 2024 20:11:22 +0800 Subject: [PATCH 027/159] Add power limit for TW region (#3701) The TW region had now power limit set, so defaulted to 16dBm. The relevant regulation is section 5.8.1 of the Low-power Radio-frequency Devices Technical Regulations, which notes the limits of 0.5W (27dBM) indoor or coastal, 1.0W (30dBM) outdoor. This patch updates the power limit to 27dbM, using the the lower limit specified in the regulations to be conservative. Regulation references: https://www.ncc.gov.tw/english/files/23070/102_5190_230703_1_doc_C.PDF (latest English version) https://gazette.nat.gov.tw/egFront/e_detail.do?metaid=147283 (latest Chinese version, February 2024) --- src/mesh/RadioInterface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 4fa0bef7a..f5eb35cbe 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -76,9 +76,12 @@ const RegionInfo regions[] = { RDEF(KR, 920.0f, 923.0f, 100, 0, 0, true, false, false), /* - ??? + Taiwan, 920-925Mhz, limited to 0.5W indoor or coastal, 1.0W outdoor. + 5.8.1 in the Low-power Radio-frequency Devices Technical Regulations + https://www.ncc.gov.tw/english/files/23070/102_5190_230703_1_doc_C.PDF + https://gazette.nat.gov.tw/egFront/e_detail.do?metaid=147283 */ - RDEF(TW, 920.0f, 925.0f, 100, 0, 0, true, false, false), + RDEF(TW, 920.0f, 925.0f, 100, 0, 27, true, false, false), /* https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf @@ -586,4 +589,4 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p) sendingPacket = p; return p->encrypted.size + sizeof(PacketHeader); -} \ No newline at end of file +} From 4599534616166a412db6c6a5f46f35d856356a59 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Wed, 24 Apr 2024 05:00:48 +1200 Subject: [PATCH 028/159] Terminate an async-full-refresh when caught by determineMode() instead of onNotify() (#3706) --- src/graphics/EInkDynamicDisplay.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/graphics/EInkDynamicDisplay.cpp b/src/graphics/EInkDynamicDisplay.cpp index b396446fa..5b97b8d48 100644 --- a/src/graphics/EInkDynamicDisplay.cpp +++ b/src/graphics/EInkDynamicDisplay.cpp @@ -534,6 +534,10 @@ void EInkDynamicDisplay::checkBusyAsyncRefresh() return; } + + // Async refresh appears to have stopped, but wasn't caught by onNotify() + else + pollAsyncRefresh(); // Check (and terminate) the async refresh manually } // Hold control while an async refresh runs From 27f0e42d2fe2bcf33fbd1ab5b686f495d07ab423 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:32:33 -0500 Subject: [PATCH 029/159] [create-pull-request] automated change (#3708) Co-authored-by: thebentern --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index eade2c6be..86640f20d 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit eade2c6befb65a9c46c5d28ae1e8e24c37a1a3d0 +Subproject commit 86640f20db7b9b5be42949d18e8d96ad10d47a68 diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 67b2edd15..68d9b4707 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -148,6 +148,9 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_TD_LORAC = 60, /* CDEBYTE EoRa-S3 board using their own MM modules, clone of LILYGO T3S3 */ meshtastic_HardwareModel_CDEBYTE_EORA_S3 = 61, + /* TWC_MESH_V4 + Adafruit NRF52840 feather express with SX1262, SSD1306 OLED and NEO6M GPS */ + meshtastic_HardwareModel_TWC_MESH_V4 = 62, /* ------------------------------------------------------------------------------------------------------------------------------------------ Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. ------------------------------------------------------------------------------------------------------------------------------------------ */ From 9c9d126f6b2aac4dda2f82193f26bc7959ade2e2 Mon Sep 17 00:00:00 2001 From: SCWhite Date: Wed, 24 Apr 2024 03:09:28 +0800 Subject: [PATCH 030/159] [BOARD] Add new variant: TWC_Mesh (#3705) * add new variant: TWC_mesh_v4 * fix trunk format * fix format under wsl * change board to TWC_mesh_v4 * change platformio & variant.h properly --------- Co-authored-by: Ben Meadors --- src/platform/nrf52/architecture.h | 4 +- variants/TWC_mesh_v4/platformio.ini | 10 +++ variants/TWC_mesh_v4/variant.cpp | 38 ++++++++ variants/TWC_mesh_v4/variant.h | 133 ++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 variants/TWC_mesh_v4/platformio.ini create mode 100644 variants/TWC_mesh_v4/variant.cpp create mode 100644 variants/TWC_mesh_v4/variant.h diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 35cd4fd84..3be3e7e55 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -52,6 +52,8 @@ #define HW_VENDOR meshtastic_HardwareModel_CANARYONE #elif defined(NORDIC_PCA10059) #define HW_VENDOR meshtastic_HardwareModel_NRF52840_PCA10059 +#elif defined(TWC_MESH_V4) +#define HW_VENDOR meshtastic_HardwareModel_TWC_MESH_V4 #elif defined(PRIVATE_HW) || defined(FEATHER_DIY) #define HW_VENDOR meshtastic_HardwareModel_PRIVATE_HW #else @@ -110,4 +112,4 @@ #if !defined(PIN_SERIAL_RX) && !defined(NRF52840_XXAA) // No serial ports on this board - ONLY use segger in memory console #define USE_SEGGER -#endif +#endif \ No newline at end of file diff --git a/variants/TWC_mesh_v4/platformio.ini b/variants/TWC_mesh_v4/platformio.ini new file mode 100644 index 000000000..9cf25c685 --- /dev/null +++ b/variants/TWC_mesh_v4/platformio.ini @@ -0,0 +1,10 @@ +[env:TWC_mesh_v4] +extends = nrf52840_base +board = TWC_mesh_v4 +board_level = extra +build_flags = ${nrf52840_base.build_flags} -I variants/TWC_mesh_v4 -D TWC_mesh_v4 -L".pio\libdeps\TWC_mesh_v4\BSEC2 Software Library\src\cortex-m4\fpv4-sp-d16-hard" +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/TWC_mesh_v4> +lib_deps = + ${nrf52840_base.lib_deps} + zinggjm/GxEPD2@^1.4.9 +debug_tool = jlink \ No newline at end of file diff --git a/variants/TWC_mesh_v4/variant.cpp b/variants/TWC_mesh_v4/variant.cpp new file mode 100644 index 000000000..b3712346d --- /dev/null +++ b/variants/TWC_mesh_v4/variant.cpp @@ -0,0 +1,38 @@ +/* + 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}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} \ No newline at end of file diff --git a/variants/TWC_mesh_v4/variant.h b/variants/TWC_mesh_v4/variant.h new file mode 100644 index 000000000..6a6f541e6 --- /dev/null +++ b/variants/TWC_mesh_v4/variant.h @@ -0,0 +1,133 @@ +#ifndef _VARIANT_TWC_MESH_V4_ +#define _VARIANT_TWC_MESH_V4_ + +#define PCA10059 + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (32 + 10) // Blue LED P1.10 +#define PIN_LED2 (32 + 15) // Built in Green P1.15 + +// RGB NeoPixel LED2 +// #define PIN_LED1 (0 + 8) Red +// #define PIN_LED1 (32 + 9) Green +// #define PIN_LED1 (0 + 12) Blue + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 0 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 (32 + 2) // BTN_DN P1.02 Built in button + +/* + * Analog pins + */ +#define PIN_A0 (0 + 29) // using VDIV (A6 / P0.29) + +static const uint8_t A0 = PIN_A0; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (-1) // AREF Not yet used + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (0 + 24) +#define PIN_SERIAL1_TX (0 + 25) + +// Connected to Jlink CDC +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 15) // MISO P0.15 +#define PIN_SPI_MOSI (0 + 13) // MOSI P0.13 +#define PIN_SPI_SCK (0 + 14) // SCK P0.14 + +static const uint8_t SS = (0 + 6); // LORA_CS P0.6 +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +////#define USE_EINK +#define USE_SSD1306 + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (0 + 12) // SDA P0.12 +#define PIN_WIRE_SCL (0 + 11) // SCL P0.11 + +// NiceRF 868 LoRa module +#define USE_SX1262 +#define USE_LLCC68 + +#define SX126X_CS (0 + 6) // LORA_CS P0.06 +#define SX126X_DIO1 (0 + 7) // DIO1 P0.07 +#define SX126X_BUSY (0 + 26) // LORA_BUSY P0.26 +#define SX126X_RESET (0 + 27) // LORA_RESET P0.27 +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +#define PIN_GPS_EN (-1) +#define PIN_GPS_PPS (-1) // Pulse per second input from the GPS + +#define GPS_RX_PIN PIN_SERIAL1_RX +#define GPS_TX_PIN PIN_SERIAL1_TX + +// Battery +// The battery sense is hooked to pin A6 (0.29) +#define BATTERY_PIN PIN_A0 +// and has 12 bit resolution +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER (2.0F) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file From 57d296e0db8757a4318f225094fdd21ef48f0198 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 23 Apr 2024 14:18:51 -0500 Subject: [PATCH 031/159] Add better support for the Adafruit PiTFT 2.8 for Native (#3704) * Add better support for the Adafruit PiTFT 2.8 for Native * native: Make touch i2c address configurable * Bump portduino to pick up I2C features --------- Co-authored-by: Ben Meadors --- arch/portduino/portduino.ini | 2 +- bin/config-dist.yaml | 12 ++++++++---- src/graphics/TFTDisplay.cpp | 7 ++++++- src/platform/portduino/PortduinoGlue.cpp | 3 ++- src/platform/portduino/PortduinoGlue.h | 1 + 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 53f06c9f3..452c34337 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based sim environment on top of any host OS, all hardware will be simulated [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#6fb39b6f94ece9c042141edb4afb91aca94dcaab +platform = https://github.com/meshtastic/platform-native.git#659e49346aa33008b150dfb206b1817ddabc7132 framework = arduino build_src_filter = diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml index f729f1ac7..f02c2a2c2 100644 --- a/bin/config-dist.yaml +++ b/bin/config-dist.yaml @@ -96,17 +96,21 @@ Display: # Panel: ILI9341 # CS: 8 # DC: 25 -# Backlight: 2 -# Width: 320 -# Height: 240 +# Width: 240 +# Height: 320 +# Rotate: true Touchscreen: ### Note, at least for now, the touchscreen must have a CS pin defined, even if you let Linux manage the CS switching. -# Module: STMPE610 +# Module: STMPE610 # Option 1 for Adafruit PiTFT 2.8 # CS: 7 # IRQ: 24 +# Module: FT5x06 # Option 2 for Adafruit PiTFT 2.8 +# IRQ: 24 +# I2CAddr: 0x38 + # Module: XPT2046 # Waveshare 2.8inch # CS: 7 # IRQ: 17 diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 12e549424..3c28a9e42 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -383,6 +383,8 @@ class LGFX : public lgfx::LGFX_Device _touch_instance = new lgfx::Touch_XPT2046; } else if (settingsMap[touchscreenModule] == stmpe610) { _touch_instance = new lgfx::Touch_STMPE610; + } else if (settingsMap[touchscreenModule] == ft5x06) { + _touch_instance = new lgfx::Touch_FT5x06; } auto touch_cfg = _touch_instance->config(); @@ -394,6 +396,9 @@ class LGFX : public lgfx::LGFX_Device touch_cfg.pin_int = settingsMap[touchscreenIRQ]; touch_cfg.bus_shared = true; touch_cfg.offset_rotation = 1; + if (settingsMap[touchscreenI2CAddr] != -1) { + touch_cfg.i2c_addr = settingsMap[touchscreenI2CAddr]; + } _touch_instance->config(touch_cfg); _panel_instance->setTouch(_touch_instance); @@ -711,4 +716,4 @@ bool TFTDisplay::connect() return true; } -#endif +#endif \ No newline at end of file diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index a04c9c12c..a8c473887 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -221,6 +221,7 @@ void portduinoSetup() settingsMap[touchscreenIRQ] = yamlConfig["Touchscreen"]["IRQ"].as(-1); settingsMap[touchscreenBusFrequency] = yamlConfig["Touchscreen"]["BusFrequency"].as(1000000); settingsMap[touchscreenRotate] = yamlConfig["Touchscreen"]["Rotate"].as(-1); + settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as(-1); if (yamlConfig["Touchscreen"]["spidev"]) { settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as(""); } @@ -332,4 +333,4 @@ int initGPIOPin(int pinNum, std::string gpioChipName) std::cout << "Warning, cannot claim pin " << gpio_name << (p ? p.__cxa_exception_type()->name() : "null") << std::endl; return ERRNO_DISABLED; } -} +} \ No newline at end of file diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index ed2954eef..4d2bcc262 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -21,6 +21,7 @@ enum configNames { touchscreenModule, touchscreenCS, touchscreenIRQ, + touchscreenI2CAddr, touchscreenBusFrequency, touchscreenRotate, touchscreenspidev, From ac16ccf40c2389b1cd1de8e366a540f44523f292 Mon Sep 17 00:00:00 2001 From: Gareth Coleman <30833824+garethhcoleman@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:41:05 +0100 Subject: [PATCH 032/159] fix for unPhone hangs during boot without sd card present (#3709) * work around sd card hang if not present * comment out the define for HAS_SDCARD --- variants/unphone/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index 180fdfe2c..7d5c30f79 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -48,7 +48,7 @@ #undef GPS_RX_PIN #undef GPS_TX_PIN -#define HAS_SDCARD 1 +// #define HAS_SDCARD 1 // causes hang if defined #define SDCARD_CS 43 #define LED_PIN 13 // the red part of the RGB LED From 9baccc80d8b06466d76a3a48ac0e1325af91abb7 Mon Sep 17 00:00:00 2001 From: Oleksandr Podolchak Date: Wed, 24 Apr 2024 16:41:01 +0300 Subject: [PATCH 033/159] Add SX1268 modules support for linux-native (#3702) * Add portduino Ebyte E22 XXXM30S/XXXM33S (sx1268) module support * Add Ebyte E22 XXXM3XS module config * Update comment for sx1268 module * Address review comments --------- Co-authored-by: Ben Meadors --- bin/config-dist.yaml | 9 +++++++++ src/main.cpp | 15 +++++++++++++++ src/platform/portduino/PortduinoGlue.cpp | 3 +++ src/platform/portduino/PortduinoGlue.h | 1 + 4 files changed, 28 insertions(+) diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml index f02c2a2c2..05b4a7b0a 100644 --- a/bin/config-dist.yaml +++ b/bin/config-dist.yaml @@ -38,6 +38,15 @@ Lora: # Busy: 20 # Reset: 18 +# Module: sx1268 # SX1268-based modules, tested with Ebyte E22 400M33S +# CS: 21 +# IRQ: 16 +# Busy: 20 +# Reset: 18 +# TXen: 6 +# RXen: 12 +# DIO3_TCXO_VOLTAGE: true + # DIO3_TCXO_VOLTAGE: true # the Waveshare Core1262 and others are known to need this setting # TXen: x # TX and RX enable pins diff --git a/src/main.cpp b/src/main.cpp index deaa60f3a..4a663a8a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -770,6 +770,21 @@ void setup() LOG_INFO("SX1280 Radio init succeeded, using SX1280 radio\n"); } } + } else if (settingsMap[use_sx1268]) { + if (!rIf) { + LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s\n", settingsStrings[spidev].c_str()); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + rIf = new SX1268Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], + settingsMap[busy]); + if (!rIf->init()) { + LOG_ERROR("Failed to find SX1268 radio\n"); + delete rIf; + rIf = NULL; + exit(EXIT_FAILURE); + } else { + LOG_INFO("SX1268 Radio init succeeded, using SX1268 radio\n"); + } + } } #elif defined(HW_SPI1_DEVICE) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index a8c473887..d86ac6677 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -136,6 +136,7 @@ void portduinoSetup() settingsMap[use_sx1262] = false; settingsMap[use_rf95] = false; settingsMap[use_sx1280] = false; + settingsMap[use_sx1268] = false; if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1262") { settingsMap[use_sx1262] = true; @@ -143,6 +144,8 @@ void portduinoSetup() settingsMap[use_rf95] = true; } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1280") { settingsMap[use_sx1280] = true; + } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1268") { + settingsMap[use_sx1268] = true; } settingsMap[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as(false); settingsMap[dio3_tcxo_voltage] = yamlConfig["Lora"]["DIO3_TCXO_VOLTAGE"].as(false); diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 4d2bcc262..94cdbf2f8 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -13,6 +13,7 @@ enum configNames { dio3_tcxo_voltage, use_rf95, use_sx1280, + use_sx1268, user, gpiochip, spidev, From e3610a2eb1e32350bb9b3adf1a7ced3394c0d024 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 24 Apr 2024 12:47:59 -0500 Subject: [PATCH 034/159] Move to lovyangfx develop for Native --- arch/portduino/portduino.ini | 4 +- src/graphics/TFTDisplay.cpp | 5 +- src/graphics/mesh_bus_spi.cpp | 188 ---------------------------------- src/graphics/mesh_bus_spi.h | 100 ------------------ 4 files changed, 4 insertions(+), 293 deletions(-) delete mode 100644 src/graphics/mesh_bus_spi.cpp delete mode 100644 src/graphics/mesh_bus_spi.h diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 452c34337..4857933ec 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -24,7 +24,7 @@ lib_deps = ${env.lib_deps} ${networking_base.lib_deps} rweather/Crypto@^0.4.0 - lovyan03/LovyanGFX@^1.1.12 + https://github.com/lovyan03/LovyanGFX.git#d35e60f269dfecbb18a8cb0fd07d594c2fb7e7a8 build_flags = ${arduino_base.build_flags} @@ -34,4 +34,4 @@ build_flags = -DPORTDUINO_LINUX_HARDWARE -lbluetooth -lgpiod - -lyaml-cpp + -lyaml-cpp \ No newline at end of file diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 3c28a9e42..b529bf0e4 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -1,7 +1,6 @@ #include "configuration.h" #include "main.h" #if ARCH_PORTDUINO -#include "mesh_bus_spi.h" #include "platform/portduino/PortduinoGlue.h" #endif @@ -340,7 +339,7 @@ static TFT_eSPI *tft = nullptr; // Invoke library, pins defined in User_Setup.h class LGFX : public lgfx::LGFX_Device { lgfx::Panel_LCD *_panel_instance; - lgfx::Mesh_Bus_SPI _bus_instance; + lgfx::Bus_SPI _bus_instance; lgfx::ITouch *_touch_instance; @@ -357,7 +356,7 @@ class LGFX : public lgfx::LGFX_Device _panel_instance = new lgfx::Panel_ILI9341; auto buscfg = _bus_instance.config(); buscfg.spi_mode = 0; - _bus_instance.spi_device(DisplaySPI, settingsStrings[displayspidev]); + _bus_instance.spi_device(DisplaySPI); buscfg.pin_dc = settingsMap[displayDC]; // Set SPI DC pin number (-1 = disable) diff --git a/src/graphics/mesh_bus_spi.cpp b/src/graphics/mesh_bus_spi.cpp deleted file mode 100644 index a9536d490..000000000 --- a/src/graphics/mesh_bus_spi.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// This code has been copied from LovyanGFX to make the SPI device selectable for touchscreens. -// Ideally this could eventually be an inherited class from BUS_SPI, -// but currently too many internal objects are set private. - -#include "configuration.h" -#if ARCH_PORTDUINO -#include "lgfx/v1/misc/pixelcopy.hpp" -#include "main.h" -#include "mesh_bus_spi.h" -#include -#include - -namespace lgfx -{ -inline namespace v1 -{ -//---------------------------------------------------------------------------- - -void Mesh_Bus_SPI::config(const config_t &config) -{ - _cfg = config; - - if (_cfg.pin_dc >= 0) { - pinMode(_cfg.pin_dc, pin_mode_t::output); - gpio_hi(_cfg.pin_dc); - } -} - -bool Mesh_Bus_SPI::init(void) -{ - dc_h(); - pinMode(_cfg.pin_dc, pin_mode_t::output); - if (SPIName != "") - PrivateSPI->begin(SPIName.c_str()); - else - PrivateSPI->begin(); - return true; -} - -void Mesh_Bus_SPI::release(void) -{ - PrivateSPI->end(); -} - -void Mesh_Bus_SPI::spi_device(HardwareSPI *newSPI, std::string newSPIName) -{ - PrivateSPI = newSPI; - SPIName = newSPIName; -} -void Mesh_Bus_SPI::beginTransaction(void) -{ - dc_h(); - SPISettings setting(_cfg.freq_write, MSBFIRST, _cfg.spi_mode); - PrivateSPI->beginTransaction(setting); -} - -void Mesh_Bus_SPI::endTransaction(void) -{ - PrivateSPI->endTransaction(); - dc_h(); -} - -void Mesh_Bus_SPI::beginRead(void) -{ - PrivateSPI->endTransaction(); - // SPISettings setting(_cfg.freq_read, BitOrder::MSBFIRST, _cfg.spi_mode, false); - SPISettings setting(_cfg.freq_read, MSBFIRST, _cfg.spi_mode); - PrivateSPI->beginTransaction(setting); -} - -void Mesh_Bus_SPI::endRead(void) -{ - PrivateSPI->endTransaction(); - beginTransaction(); -} - -void Mesh_Bus_SPI::wait(void) {} - -bool Mesh_Bus_SPI::busy(void) const -{ - return false; -} - -bool Mesh_Bus_SPI::writeCommand(uint32_t data, uint_fast8_t bit_length) -{ - dc_l(); - PrivateSPI->transfer((uint8_t *)&data, bit_length >> 3); - dc_h(); - return true; -} - -void Mesh_Bus_SPI::writeData(uint32_t data, uint_fast8_t bit_length) -{ - PrivateSPI->transfer((uint8_t *)&data, bit_length >> 3); -} - -void Mesh_Bus_SPI::writeDataRepeat(uint32_t data, uint_fast8_t bit_length, uint32_t length) -{ - const uint8_t dst_bytes = bit_length >> 3; - uint32_t limit = (dst_bytes == 3) ? 12 : 16; - auto buf = _flip_buffer.getBuffer(512); - size_t fillpos = 0; - reinterpret_cast(buf)[0] = data; - fillpos += dst_bytes; - uint32_t len; - do { - len = ((length - 1) % limit) + 1; - if (limit <= 64) - limit <<= 1; - - while (fillpos < len * dst_bytes) { - memcpy(&buf[fillpos], buf, fillpos); - fillpos += fillpos; - } - - PrivateSPI->transfer(buf, len * dst_bytes); - } while (length -= len); -} - -void Mesh_Bus_SPI::writePixels(pixelcopy_t *param, uint32_t length) -{ - const uint8_t dst_bytes = param->dst_bits >> 3; - uint32_t limit = (dst_bytes == 3) ? 12 : 16; - uint32_t len; - do { - len = ((length - 1) % limit) + 1; - if (limit <= 32) - limit <<= 1; - auto buf = _flip_buffer.getBuffer(len * dst_bytes); - param->fp_copy(buf, 0, len, param); - PrivateSPI->transfer(buf, len * dst_bytes); - } while (length -= len); -} - -void Mesh_Bus_SPI::writeBytes(const uint8_t *data, uint32_t length, bool dc, bool use_dma) -{ - if (dc) - dc_h(); - else - dc_l(); - PrivateSPI->transfer(const_cast(data), length); - if (!dc) - dc_h(); -} - -uint32_t Mesh_Bus_SPI::readData(uint_fast8_t bit_length) -{ - uint32_t res = 0; - bit_length >>= 3; - if (!bit_length) - return res; - int idx = 0; - do { - res |= PrivateSPI->transfer(0) << idx; - idx += 8; - } while (--bit_length); - return res; -} - -bool Mesh_Bus_SPI::readBytes(uint8_t *dst, uint32_t length, bool use_dma) -{ - do { - dst[0] = PrivateSPI->transfer(0); - ++dst; - } while (--length); - return true; -} - -void Mesh_Bus_SPI::readPixels(void *dst, pixelcopy_t *param, uint32_t length) -{ - uint32_t bytes = param->src_bits >> 3; - uint32_t dstindex = 0; - uint32_t len = 4; - uint8_t buf[24]; - param->src_data = buf; - do { - if (len > length) - len = length; - readBytes((uint8_t *)buf, len * bytes, true); - param->src_x = 0; - dstindex = param->fp_copy(dst, dstindex, dstindex + len, param); - length -= len; - } while (length); -} - -} // namespace v1 -} // namespace lgfx -#endif \ No newline at end of file diff --git a/src/graphics/mesh_bus_spi.h b/src/graphics/mesh_bus_spi.h deleted file mode 100644 index 903f7ad9d..000000000 --- a/src/graphics/mesh_bus_spi.h +++ /dev/null @@ -1,100 +0,0 @@ -#if ARCH_PORTDUINO -/*----------------------------------------------------------------------------/ - Lovyan GFX - Graphics library for embedded devices. - -Original Source: - https://github.com/lovyan03/LovyanGFX/ - -Licence: - [FreeBSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt) - -Author: - [lovyan03](https://twitter.com/lovyan03) - -Contributors: - [ciniml](https://github.com/ciniml) - [mongonta0716](https://github.com/mongonta0716) - [tobozo](https://github.com/tobozo) -/----------------------------------------------------------------------------*/ -#pragma once - -#include - -#include "lgfx/v1/Bus.hpp" -#include "lgfx/v1/platforms/common.hpp" - -namespace lgfx -{ -inline namespace v1 -{ -//---------------------------------------------------------------------------- - -class Mesh_Bus_SPI : public IBus -{ - public: - struct config_t { - uint32_t freq_write = 16000000; - uint32_t freq_read = 8000000; - // bool spi_3wire = true; - // bool use_lock = true; - int16_t pin_sclk = -1; - int16_t pin_miso = -1; - int16_t pin_mosi = -1; - int16_t pin_dc = -1; - uint8_t spi_mode = 0; - }; - - const config_t &config(void) const { return _cfg; } - - void config(const config_t &config); - - bus_type_t busType(void) const override { return bus_type_t::bus_spi; } - - bool init(void) override; - void release(void) override; - void spi_device(HardwareSPI *newSPI, std::string newSPIName); - - void beginTransaction(void) override; - void endTransaction(void) override; - void wait(void) override; - bool busy(void) const override; - - bool writeCommand(uint32_t data, uint_fast8_t bit_length) override; - void writeData(uint32_t data, uint_fast8_t bit_length) override; - void writeDataRepeat(uint32_t data, uint_fast8_t bit_length, uint32_t count) override; - void writePixels(pixelcopy_t *param, uint32_t length) override; - void writeBytes(const uint8_t *data, uint32_t length, bool dc, bool use_dma) override; - - void initDMA(void) {} - void flush(void) {} - void addDMAQueue(const uint8_t *data, uint32_t length) override { writeBytes(data, length, true, true); } - void execDMAQueue(void) {} - uint8_t *getDMABuffer(uint32_t length) override { return _flip_buffer.getBuffer(length); } - - void beginRead(void) override; - void endRead(void) override; - uint32_t readData(uint_fast8_t bit_length) override; - bool readBytes(uint8_t *dst, uint32_t length, bool use_dma) override; - void readPixels(void *dst, pixelcopy_t *param, uint32_t length) override; - - private: - HardwareSPI *PrivateSPI; - std::string SPIName; - __attribute__((always_inline)) inline void dc_h(void) { gpio_hi(_cfg.pin_dc); } - __attribute__((always_inline)) inline void dc_l(void) { gpio_lo(_cfg.pin_dc); } - - config_t _cfg; - FlipBuffer _flip_buffer; - bool _need_wait; - uint32_t _mask_reg_dc; - uint32_t _last_apb_freq = -1; - uint32_t _clkdiv_write; - uint32_t _clkdiv_read; - volatile uint32_t *_gpio_reg_dc_h; - volatile uint32_t *_gpio_reg_dc_l; -}; - -//---------------------------------------------------------------------------- -} // namespace v1 -} // namespace lgfx -#endif \ No newline at end of file From c14043f196f7d05060b17ff193a60c269c84a686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Thu, 25 Apr 2024 13:47:39 +0200 Subject: [PATCH 035/159] Split warning into two messages, so we know which one is the case. (#3710) --- src/mqtt/MQTT.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index da1c204b8..8a477d8ad 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -548,7 +548,10 @@ void MQTT::perhapsReportToMap() } else { if (map_position_precision == 0 || (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)) { last_report_to_map = millis(); - LOG_WARN("MQTT Map reporting is enabled, but precision is 0 or no position available.\n"); + if (map_position_precision == 0) + LOG_WARN("MQTT Map reporting is enabled, but precision is 0\n"); + if (localPosition.latitude_i == 0 && localPosition.longitude_i == 0) + LOG_WARN("MQTT Map reporting is enabled, but no position available.\n"); return; } From 30fbcabf84b92e4fe84be8fb094c8e3c9be5252c Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 25 Apr 2024 14:23:38 -0500 Subject: [PATCH 036/159] add conffiles to .deb packaging (#3722) --- .github/workflows/package_raspbian.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index dd4133dab..81ff6ee25 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -45,6 +45,7 @@ jobs: - name: build .debpkg run: | + mkdir -p .debpkg/debian mkdir -p .debpkg/usr/share/doc/meshtasticd/web mkdir -p .debpkg/usr/sbin mkdir -p .debpkg/etc/meshtasticd @@ -55,6 +56,7 @@ jobs: cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml chmod +x .debpkg/usr/sbin/meshtasticd cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service + echo "etc/meshtasticd/config.yaml" > .debpkg/debian/conffiles - uses: jiro4989/build-deb-action@v3 with: From 5806a266d38ff34a53ee5f7bf456b2f4fa344079 Mon Sep 17 00:00:00 2001 From: thebentern Date: Thu, 25 Apr 2024 20:19:54 +0000 Subject: [PATCH 037/159] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 485f55130..36607a956 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 7 +build = 8 From dfcabba0b2bda6b142108962053c7c36263dcaf3 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Sat, 27 Apr 2024 13:43:09 +1200 Subject: [PATCH 038/159] Prevent overflow when calculating timezones (#3730) --- src/gps/RTC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index 85931900f..a2cdb5b30 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -223,7 +223,7 @@ int32_t getTZOffset() now = time(NULL); gmt = gmtime(&now); gmt->tm_isdst = -1; - return (int16_t)difftime(now, mktime(gmt)); + return (int32_t)difftime(now, mktime(gmt)); } /** From f8c3f43ea61d4b6987b31e6e170b3ef56049ac9e Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Sat, 27 Apr 2024 19:17:17 +0800 Subject: [PATCH 039/159] Fix xiao_ble variant build error due to undefined BATTERY_SENSE_RESOLUTION_BITS (#3732) Define BATTERY_SENSE_RESOLUTION_BITS based on [amoroz's snippet on the Meshtastic forum](https://meshtastic.discourse.group/t/new-1w-diy-variant-xiao-nrf52840-ebyte-e22-900m30s/7904/10). Fixes following build error: ``` src/Power.cpp: In member function 'virtual uint16_t AnalogBatteryLevel::getBattVoltage()': src/Power.cpp:224:79: error: 'BATTERY_SENSE_RESOLUTION_BITS' was not declared in this scope scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / pow(2, BATTERY_SENSE_RESOLUTION_BITS)) * raw; ``` Signed-off-by: Andrew Yong --- variants/xiao_ble/variant.h | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/xiao_ble/variant.h b/variants/xiao_ble/variant.h index e2b8eb613..77af08278 100644 --- a/variants/xiao_ble/variant.h +++ b/variants/xiao_ble/variant.h @@ -181,6 +181,7 @@ static const uint8_t SCL = PIN_WIRE_SCL; #define BAT_READ \ 14 // P0_14 = 14 Reads battery voltage from divider on signal board. (PIN_VBAT is reading voltage divider on XIAO and is // program pin 32 / or P0.31) +#define BATTERY_SENSE_RESOLUTION_BITS 10 #define CHARGE_LED 23 // P0_17 = 17 D23 YELLOW CHARGE LED #define HICHG 22 // P0_13 = 13 D22 Charge-select pin for Lipo for 100 mA instead of default 50mA charge From a06a01d25ea2f5cdc75e0e5266b542af5e789389 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Sat, 27 Apr 2024 11:35:44 +0000 Subject: [PATCH 040/159] fix #if HAS_TELEMETRY when set to 0 (#3733) --- src/Power.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index d13fd6891..2658b74a4 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -184,7 +184,7 @@ class AnalogBatteryLevel : public HasBatteryLevel virtual uint16_t getBattVoltage() override { -#if defined(HAS_TELEMETRY) && !defined(ARCH_PORTDUINO) && !defined(HAS_PMU) +#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(HAS_PMU) if (hasINA()) { LOG_DEBUG("Using INA on I2C addr 0x%x for device battery voltage\n", config.power.device_battery_ina_address); return getINAVoltage(); @@ -360,7 +360,7 @@ class AnalogBatteryLevel : public HasBatteryLevel float last_read_value = (OCV[NUM_OCV_POINTS - 1] * NUM_CELLS); uint32_t last_read_time_ms = 0; -#if defined(HAS_TELEMETRY) && !defined(ARCH_PORTDUINO) +#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) uint16_t getINAVoltage() { if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) { From e66aec8223337e6580adf86028ea4f6a5c73e2cd Mon Sep 17 00:00:00 2001 From: jcyrio <50239349+jcyrio@users.noreply.github.com> Date: Sat, 27 Apr 2024 06:54:06 -0700 Subject: [PATCH 041/159] fix typo in comment (#3726) --- src/modules/CannedMessageModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index c80ccc5e7..24e5d28d1 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -239,7 +239,7 @@ int32_t CannedMessageModule::runOnce() UIFrameEvent e = {false, true}; if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED)) { - // TODO: might have some feedback of sendig state + // TODO: might have some feedback of sending state this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; e.frameChanged = true; this->currentMessageIndex = -1; From e683d8f5525b1b3efd445c296b2cce2b37f7deb5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 27 Apr 2024 08:55:04 -0500 Subject: [PATCH 042/159] Rebrand "send network ping" to more honest "try send position" with better output (#3737) --- src/ButtonThread.cpp | 7 +++++-- src/mesh/MeshService.cpp | 4 +++- src/mesh/MeshService.h | 5 +++-- src/modules/CannedMessageModule.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 206bb7239..e9717521a 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -136,9 +136,12 @@ int32_t ButtonThread::runOnce() case BUTTON_EVENT_DOUBLE_PRESSED: { LOG_BUTTON("Double press!\n"); service.refreshLocalMeshNode(); - service.sendNetworkPing(NODENUM_BROADCAST, true); + auto sentPosition = service.trySendPosition(NODENUM_BROADCAST, true); if (screen) { - screen->print("Sent ad-hoc ping\n"); + if (sentPosition) + screen->print("Sent ad-hoc position\n"); + else + screen->print("Sent ad-hoc nodeinfo\n"); screen->forceDisplay(true); // Force a new UI frame, then force an EInk update } break; diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 2c1969e30..6b8d37975 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -267,7 +267,7 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh } } -void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) +bool MeshService::trySendPosition(NodeNum dest, bool wantReplies) { meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum()); @@ -278,6 +278,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) if (positionModule) { LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel); positionModule->sendOurPosition(dest, wantReplies, node->channel); + return true; } } else { #endif @@ -286,6 +287,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel); } } + return false; } void MeshService::sendToPhone(meshtastic_MeshPacket *p) diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index 8d1434030..d777b7a01 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -108,8 +108,9 @@ class MeshService void reloadOwner(bool shouldSave = true); /// Called when the user wakes up our GUI, normally sends our latest location to the mesh (if we have it), otherwise at least - /// sends our owner - void sendNetworkPing(NodeNum dest, bool wantReplies = false); + /// sends our nodeinfo + /// returns true if we sent a position + bool trySendPosition(NodeNum dest, bool wantReplies = false); /// Send a packet into the mesh - note p must have been allocated from packetPool. We will return it to that pool after /// sending. This is the ONLY function you should use for sending messages into the mesh, because it also updates the nodedb diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 24e5d28d1..ea7d5029a 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -452,7 +452,7 @@ int32_t CannedMessageModule::runOnce() break; case 0xaf: // fn+space send network ping like double press does service.refreshLocalMeshNode(); - service.sendNetworkPing(NODENUM_BROADCAST, true); + service.trySendPosition(NODENUM_BROADCAST, true); runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; default: From 38c4d35a7bd81e5b8ecbec479e4bf5df314e9735 Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Sat, 27 Apr 2024 12:08:25 -0400 Subject: [PATCH 043/159] Add Notification on device screen following feature toggle (#3627) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update CannedMessageModule.h * Update CannedMessageModule.cpp * Update CannedMessageModule.cpp hopefully this fixes the errors on Trunk * Update CannedMessageModule.cpp Changed "Ping Broadcasted" with "Telemetry Update Sent" * tryfix: disable tempmessage again after 2 seconds * fix 2s showtime * Put spelling fix back * Fix build --------- Co-authored-by: Thomas Göttgens Co-authored-by: Ben Meadors --- src/modules/CannedMessageModule.cpp | 36 ++++++++++++++++++++++------- src/modules/CannedMessageModule.h | 6 ++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index ea7d5029a..b6267d985 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -233,14 +233,16 @@ int32_t CannedMessageModule::runOnce() { if (((!moduleConfig.canned_message.enabled) && !CANNED_MESSAGE_MODULE_ENABLE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { + temporaryMessage = ""; return INT32_MAX; } // LOG_DEBUG("Check status\n"); UIFrameEvent e = {false, true}; if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) || - (this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED)) { + (this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) || (this->runState == CANNED_MESSAGE_RUN_STATE_MESSAGE)) { // TODO: might have some feedback of sending state this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + temporaryMessage = ""; e.frameChanged = true; this->currentMessageIndex = -1; this->freetext = ""; // clear freetext @@ -434,7 +436,7 @@ int32_t CannedMessageModule::runOnce() } if (screen) screen->forceDisplay(); - runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + showTemporaryMessage("GPS Toggled"); break; // mute (switch off/toggle) external notifications on fn+m @@ -442,18 +444,21 @@ int32_t CannedMessageModule::runOnce() if (moduleConfig.external_notification.enabled == true) { if (externalNotificationModule->getMute()) { externalNotificationModule->setMute(false); - runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + showTemporaryMessage("Notifications \nEnabled"); } else { externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop externalNotificationModule->setMute(true); - runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + showTemporaryMessage("Notifications \nDisabled"); } } break; case 0xaf: // fn+space send network ping like double press does service.refreshLocalMeshNode(); - service.trySendPosition(NODENUM_BROADCAST, true); - runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + if (service.trySendPosition(NODENUM_BROADCAST, true)) { + showTemporaryMessage("Position \nUpdate Sent"); + } else { + showTemporaryMessage("Node Info \nUpdate Sent"); + } break; default: if (this->cursor == this->freetext.length()) { @@ -542,12 +547,27 @@ int CannedMessageModule::getPrevIndex() return this->currentMessageIndex - 1; } } +void CannedMessageModule::showTemporaryMessage(const String &message) +{ + temporaryMessage = message; + UIFrameEvent e = {false, true}; + e.frameChanged = true; + notifyObservers(&e); + runState = CANNED_MESSAGE_RUN_STATE_MESSAGE; + // run this loop again in 2 seconds, next iteration will clear the display + setIntervalFromNow(2000); +} void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { char buffer[50]; - if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) { + if (temporaryMessage.length() != 0) { + LOG_DEBUG("Drawing temporary message: %s", temporaryMessage.c_str()); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->setFont(FONT_MEDIUM); + display->drawString(display->getWidth() / 2 + x, 0 + y + 12, temporaryMessage); + } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) { display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(FONT_MEDIUM); String displayString; @@ -766,4 +786,4 @@ String CannedMessageModule::drawWithCursor(String text, int cursor) return result; } -#endif \ No newline at end of file +#endif diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 4802be078..faf1d80f3 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -10,6 +10,7 @@ enum cannedMessageModuleRunState { CANNED_MESSAGE_RUN_STATE_FREETEXT, CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE, CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED, + CANNED_MESSAGE_RUN_STATE_MESSAGE, CANNED_MESSAGE_RUN_STATE_ACTION_SELECT, CANNED_MESSAGE_RUN_STATE_ACTION_UP, CANNED_MESSAGE_RUN_STATE_ACTION_DOWN, @@ -51,6 +52,8 @@ class CannedMessageModule : public SinglePortModule, public Observable Date: Sat, 27 Apr 2024 11:12:52 -0500 Subject: [PATCH 044/159] Tradunkadunk --- src/modules/CannedMessageModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index b6267d985..a8b1b994b 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -455,9 +455,9 @@ int32_t CannedMessageModule::runOnce() case 0xaf: // fn+space send network ping like double press does service.refreshLocalMeshNode(); if (service.trySendPosition(NODENUM_BROADCAST, true)) { - showTemporaryMessage("Position \nUpdate Sent"); + showTemporaryMessage("Position \nUpdate Sent"); } else { - showTemporaryMessage("Node Info \nUpdate Sent"); + showTemporaryMessage("Node Info \nUpdate Sent"); } break; default: From ee4c4ae6c968502888fdb3adb256d1023b397a1b Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Apr 2024 02:15:54 +0300 Subject: [PATCH 045/159] Allow setting hopLimit for MQTT json sendtext and sendposition (#3735) * Fix channel name extraction * Allow setting hopLimit for mqtt sendtext and sendposition --- src/mqtt/MQTT.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 8a477d8ad..508830203 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -54,9 +54,9 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length) JSONObject json; json = json_value->AsObject(); - // parse the channel name from the topic string by looking for "json/" - const char *jsonSlash = "json/"; - char *ptr = strstr(topic, jsonSlash) + sizeof(jsonSlash) + 1; // set pointer to after "json/" + // parse the channel name from the topic string + // the topic has been checked above for having jsonTopic prefix, so just move past it + char *ptr = topic + jsonTopic.length(); ptr = strtok(ptr, "/") ? strtok(ptr, "/") : ptr; // if another "/" was added, parse string up to that character meshtastic_Channel sendChannel = channels.getByName(ptr); // We allow downlink JSON packets only on a channel named "mqtt" @@ -76,6 +76,8 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length) p->channel = json["channel"]->AsNumber(); if (json.find("to") != json.end() && json["to"]->IsNumber()) p->to = json["to"]->AsNumber(); + if (json.find("hopLimit") != json.end() && json["hopLimit"]->IsNumber()) + p->hop_limit = json["hopLimit"]->AsNumber(); if (jsonPayloadStr.length() <= sizeof(p->decoded.payload.bytes)) { memcpy(p->decoded.payload.bytes, jsonPayloadStr.c_str(), jsonPayloadStr.length()); p->decoded.payload.size = jsonPayloadStr.length(); @@ -105,6 +107,8 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length) p->channel = json["channel"]->AsNumber(); if (json.find("to") != json.end() && json["to"]->IsNumber()) p->to = json["to"]->AsNumber(); + if (json.find("hopLimit") != json.end() && json["hopLimit"]->IsNumber()) + p->hop_limit = json["hopLimit"]->AsNumber(); p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Position_msg, &pos); // make the Data protobuf from position @@ -907,6 +911,7 @@ bool MQTT::isValidJsonEnvelope(JSONObject &json) { // if "sender" is provided, avoid processing packets we uplinked return (json.find("sender") != json.end() ? (json["sender"]->AsString().compare(owner.id) != 0) : true) && + (json.find("hopLimit") != json.end() ? json["hopLimit"]->IsNumber() : true) && // hop limit should be a number (json.find("from") != json.end()) && json["from"]->IsNumber() && (json["from"]->AsNumber() == nodeDB->getNodeNum()) && // only accept message if the "from" is us (json.find("type") != json.end()) && json["type"]->IsString() && // should specify a type From 93f77ea7d23a1612887cef09019e1c0ed5d8cd93 Mon Sep 17 00:00:00 2001 From: David Ellefsen <93522+titan098@users.noreply.github.com> Date: Sun, 28 Apr 2024 02:50:15 +0200 Subject: [PATCH 046/159] Update TinyGPSPlus version (#3727) Co-authored-by: Ben Meadors --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index a1082a84a..e178fdb16 100644 --- a/platformio.ini +++ b/platformio.ini @@ -78,7 +78,7 @@ lib_deps = https://github.com/meshtastic/esp8266-oled-ssd1306.git#ee628ee6c9588d4c56c9e3da35f0fc9448ad54a8 ; ESP8266_SSD1306 mathertel/OneButton@^2.5.0 ; OneButton library for non-blocking button debounce https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 - https://github.com/meshtastic/TinyGPSPlus.git#964f75a72cccd6b53cd74e4add1f7a42c6f7344d + https://github.com/meshtastic/TinyGPSPlus.git#71a82db35f3b973440044c476d4bcdc673b104f4 https://github.com/meshtastic/ArduinoThread.git#1ae8778c85d0a2a729f989e0b1e7d7c4dc84eef0 nanopb/Nanopb@^0.4.7 erriez/ErriezCRC32@^1.0.1 From 18e69a0906e173cffa1049ca0954728e1b66b367 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Sun, 28 Apr 2024 19:49:26 +0800 Subject: [PATCH 047/159] Update Heltec HT-C62 variant based on HT-DEV-ESP board (#3731) * I2C is not defined in the reference schematic nor HT-DEV-ESP board, remove definition accordingly * There is no screen in the the reference schematic nor HT-DEV-ESP board, change definition accordingly * BUTTON_PIN has a 10 kOhm pullup resistor on HT-DEV-ESP, turning off redundant internal pullup should save some power * LED is connected to GPIO2 on HT-DEV-ESP and is not inverted, update definition accordingly * Remove redundant undef lines for LoRa pins Above changes were built and flashed to my [HT-DEV-ESP_V2 board purchased from Heltec's Taobao store](https://item.taobao.com/item.htm?id=521590063077). Signed-off-by: Andrew Yong --- variants/heltec_esp32c3/variant.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/variants/heltec_esp32c3/variant.h b/variants/heltec_esp32c3/variant.h index 6641f9d21..360d9bf1f 100644 --- a/variants/heltec_esp32c3/variant.h +++ b/variants/heltec_esp32c3/variant.h @@ -1,24 +1,16 @@ -#define I2C_SDA 1 -#define I2C_SCL 0 - #define BUTTON_PIN 9 -#define BUTTON_NEED_PULLUP -// LED flashes brighter +// LED pin on HT-DEV-ESP_V2 and HT-DEV-ESP_V3 // https://resource.heltec.cn/download/HT-CT62/HT-CT62_Reference_Design.pdf -#define LED_PIN 18 // LED -#define LED_INVERTED 1 +// https://resource.heltec.cn/download/HT-DEV-ESP/HT-DEV-ESP_V3_Sch.pdf +#define LED_PIN 2 // LED +#define LED_INVERTED 0 -#define HAS_SCREEN 1 +#define HAS_SCREEN 0 #define HAS_GPS 0 #undef GPS_RX_PIN #undef GPS_TX_PIN -#undef LORA_SCK -#undef LORA_MISO -#undef LORA_MOSI -#undef LORA_CS - #define USE_SX1262 #define LORA_SCK 10 #define LORA_MISO 6 From 21311bbeda61ec7ca9f052fdad37757727ef3707 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Tue, 30 Apr 2024 01:54:57 +1200 Subject: [PATCH 048/159] T-Echo touch button no longer requires "wake on tap or motion" (#3745) --- src/ButtonThread.cpp | 14 ++++++-------- src/mesh/NodeDB.cpp | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index e9717521a..4566de924 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -196,15 +196,13 @@ int32_t ButtonThread::runOnce() #ifdef BUTTON_PIN_TOUCH case BUTTON_EVENT_TOUCH_LONG_PRESSED: { LOG_BUTTON("Touch press!\n"); - if (config.display.wake_on_tap_or_motion) { - if (screen) { - // Wake if asleep - if (powerFSM.getState() == &stateDARK) - powerFSM.trigger(EVENT_PRESS); + if (screen) { + // Wake if asleep + if (powerFSM.getState() == &stateDARK) + powerFSM.trigger(EVENT_PRESS); - // Update display (legacy behaviour) - screen->forceDisplay(); - } + // Update display (legacy behaviour) + screen->forceDisplay(); } break; } diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 39422b454..249db627e 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -352,9 +352,6 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.external_notification.alert_message = true; moduleConfig.external_notification.output_ms = 100; moduleConfig.external_notification.active = true; -#endif -#ifdef TTGO_T_ECHO - config.display.wake_on_tap_or_motion = true; // Enable touch button for screen-on / refresh #endif moduleConfig.has_canned_message = true; From e51ee91c39903bc13e14f06fe4743d755f834580 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 1 May 2024 03:07:15 +0200 Subject: [PATCH 049/159] Optimization: stop relaying when reply is received (#3753) --- src/mesh/FloodingRouter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index 4cfe982d8..dd547a6f1 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -35,11 +35,10 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p) void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) { - bool isAck = - ((c && c->error_reason == meshtastic_Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK - if (isAck && p->to != getNodeNum()) { - // do not flood direct message that is ACKed - LOG_DEBUG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n"); + bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0); + if (isAckorReply && p->to != getNodeNum() && p->to != NODENUM_BROADCAST) { + // do not flood direct message that is ACKed or replied to + LOG_DEBUG("Receiving an ACK or reply not for me, but don't need to rebroadcast this direct message anymore.\n"); Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM } if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { From 3619ac87b8a78205d16de856f711abb49d83fa96 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:14:38 -0500 Subject: [PATCH 050/159] [create-pull-request] automated change (#3754) Co-authored-by: thebentern --- protobufs | 2 +- src/mesh/generated/meshtastic/apponly.pb.h | 2 +- src/mesh/generated/meshtastic/channel.pb.h | 17 +++++++++++------ src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/protobufs b/protobufs index 86640f20d..e21899aa6 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 86640f20db7b9b5be42949d18e8d96ad10d47a68 +Subproject commit e21899aa6b2b49863cfa2758e5e3b6faacf04bba diff --git a/src/mesh/generated/meshtastic/apponly.pb.h b/src/mesh/generated/meshtastic/apponly.pb.h index 54629f522..ba9f90873 100644 --- a/src/mesh/generated/meshtastic/apponly.pb.h +++ b/src/mesh/generated/meshtastic/apponly.pb.h @@ -55,7 +55,7 @@ extern const pb_msgdesc_t meshtastic_ChannelSet_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_APPONLY_PB_H_MAX_SIZE meshtastic_ChannelSet_size -#define meshtastic_ChannelSet_size 658 +#define meshtastic_ChannelSet_size 674 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/channel.pb.h b/src/mesh/generated/meshtastic/channel.pb.h index 185a47a98..d9c7d4ffa 100644 --- a/src/mesh/generated/meshtastic/channel.pb.h +++ b/src/mesh/generated/meshtastic/channel.pb.h @@ -34,6 +34,9 @@ typedef enum _meshtastic_Channel_Role { typedef struct _meshtastic_ModuleSettings { /* Bits of precision for the location sent in position packets. */ uint32_t position_precision; + /* Controls whether or not the phone / clients should mute the current channel + Useful for noisy public channels you don't necessarily want to disable */ + bool is_client_muted; } meshtastic_ModuleSettings; typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t; @@ -126,14 +129,15 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_default} -#define meshtastic_ModuleSettings_init_default {0} +#define meshtastic_ModuleSettings_init_default {0, 0} #define meshtastic_Channel_init_default {0, false, meshtastic_ChannelSettings_init_default, _meshtastic_Channel_Role_MIN} #define meshtastic_ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_zero} -#define meshtastic_ModuleSettings_init_zero {0} +#define meshtastic_ModuleSettings_init_zero {0, 0} #define meshtastic_Channel_init_zero {0, false, meshtastic_ChannelSettings_init_zero, _meshtastic_Channel_Role_MIN} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_ModuleSettings_position_precision_tag 1 +#define meshtastic_ModuleSettings_is_client_muted_tag 2 #define meshtastic_ChannelSettings_channel_num_tag 1 #define meshtastic_ChannelSettings_psk_tag 2 #define meshtastic_ChannelSettings_name_tag 3 @@ -159,7 +163,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, module_settings, 7) #define meshtastic_ChannelSettings_module_settings_MSGTYPE meshtastic_ModuleSettings #define meshtastic_ModuleSettings_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, position_precision, 1) +X(a, STATIC, SINGULAR, UINT32, position_precision, 1) \ +X(a, STATIC, SINGULAR, BOOL, is_client_muted, 2) #define meshtastic_ModuleSettings_CALLBACK NULL #define meshtastic_ModuleSettings_DEFAULT NULL @@ -182,9 +187,9 @@ extern const pb_msgdesc_t meshtastic_Channel_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_MAX_SIZE meshtastic_Channel_size -#define meshtastic_ChannelSettings_size 70 -#define meshtastic_Channel_size 85 -#define meshtastic_ModuleSettings_size 6 +#define meshtastic_ChannelSettings_size 72 +#define meshtastic_Channel_size 87 +#define meshtastic_ModuleSettings_size 8 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index 2506ec647..b8cc80633 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -306,7 +306,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ /* meshtastic_DeviceState_size depends on runtime parameters */ #define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_OEMStore_size -#define meshtastic_ChannelFile_size 702 +#define meshtastic_ChannelFile_size 718 #define meshtastic_NodeInfoLite_size 166 #define meshtastic_OEMStore_size 3346 #define meshtastic_PositionLite_size 28 From 57da37cfbca4ef5b47c346e4f2de02d00f33a726 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 1 May 2024 08:05:26 -0500 Subject: [PATCH 051/159] Position module should enforce precision for phone originated position packets (#3752) --- src/modules/PositionModule.cpp | 17 +++++++++++++++++ src/modules/PositionModule.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 658b8b5a7..7c459dc35 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -87,6 +87,23 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes return false; // Let others look at this message also if they want } +void PositionModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_Position *p) +{ + // Phone position packets need to be truncated to the channel precision + if (nodeDB->getNodeNum() == getFrom(&mp) && (precision < 32 && precision > 0)) { + LOG_DEBUG("Truncating phone position to channel precision %i\n", precision); + p->latitude_i = p->latitude_i & (UINT32_MAX << (32 - precision)); + p->longitude_i = p->longitude_i & (UINT32_MAX << (32 - precision)); + + // We want the imprecise position to be the middle of the possible location, not + p->latitude_i += (1 << (31 - precision)); + p->longitude_i += (1 << (31 - precision)); + + mp.decoded.payload.size = + pb_encode_to_bytes(mp.decoded.payload.bytes, sizeof(mp.decoded.payload.bytes), &meshtastic_Position_msg, p); + } +} + void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal) { struct timeval tv; diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index 89ff50c64..1161159f7 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -42,6 +42,8 @@ class PositionModule : public ProtobufModule, private concu */ virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Position *p) override; + virtual void alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_Position *p) override; + /** Messages can be received that have the want_response bit set. If set, this callback will be invoked * so that subclasses can (optionally) send a response back to the original sender. */ virtual meshtastic_MeshPacket *allocReply() override; From ec92f7a5a396657e6b475988d1df520ab9753cd5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 1 May 2024 08:27:43 -0500 Subject: [PATCH 052/159] Remove phone nodenum warning and empty else clause (#3756) --- src/mesh/MeshService.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 6b8d37975..66a2e6952 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -193,10 +193,7 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p) } #endif if (p.from != 0) { // We don't let phones assign nodenums to their sent messages - LOG_WARN("phone tried to pick a nodenum, we don't allow that.\n"); p.from = 0; - } else { - // p.from = nodeDB->getNodeNum(); } if (p.id == 0) From 5095efc55fc17f1c67abc4b64e715c9c2b4acf58 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 1 May 2024 13:06:42 -0500 Subject: [PATCH 053/159] Pick up support for more than 64 GPIO lines under Portduino --- arch/portduino/portduino.ini | 2 +- src/platform/portduino/PortduinoGlue.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 4857933ec..ef99c7870 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based sim environment on top of any host OS, all hardware will be simulated [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#659e49346aa33008b150dfb206b1817ddabc7132 +platform = https://github.com/meshtastic/platform-native.git#784007630ca43b4811c6637606440588bb5acf39 framework = arduino build_src_filter = diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index d86ac6677..8572f4cf2 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -76,7 +76,21 @@ void portduinoCustomInit() void portduinoSetup() { printf("Setting up Meshtastic on Portduino...\n"); - gpioInit(); + int max_GPIO = 0; + int GPIO_lines[] = {cs, + irq, + busy, + reset, + txen, + rxen, + displayDC, + displayCS, + displayBacklight, + displayBacklightPWMChannel, + displayReset, + touchscreenCS, + touchscreenIRQ, + user}; std::string gpioChipName = "gpiochip"; settingsStrings[i2cdev] = ""; @@ -245,6 +259,13 @@ void portduinoSetup() exit(EXIT_FAILURE); } + for (int i : GPIO_lines) { + if (i > max_GPIO) + max_GPIO = i; + } + + gpioInit(max_GPIO + 1); // Done here so we can inform Portduino how many GPIOs we need. + // Need to bind all the configured GPIO pins so they're not simulated if (settingsMap.count(cs) > 0 && settingsMap[cs] != RADIOLIB_NC) { if (initGPIOPin(settingsMap[cs], gpioChipName) != ERRNO_OK) { From 45c1b46bd0f03350106009bec03e4c3a6050895b Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 1 May 2024 13:20:26 -0500 Subject: [PATCH 054/159] Move native to spi_host to indicate spidev for LovyanGFX --- arch/portduino/portduino.ini | 2 +- src/graphics/TFTDisplay.cpp | 4 ++- src/main.cpp | 8 ++--- src/platform/portduino/PortduinoGlue.cpp | 46 +++++++++++++----------- src/platform/portduino/PortduinoGlue.h | 4 +-- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index ef99c7870..162411972 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -24,7 +24,7 @@ lib_deps = ${env.lib_deps} ${networking_base.lib_deps} rweather/Crypto@^0.4.0 - https://github.com/lovyan03/LovyanGFX.git#d35e60f269dfecbb18a8cb0fd07d594c2fb7e7a8 + https://github.com/lovyan03/LovyanGFX.git#5a39989aa2c9492572255b22f033843ec8900233 build_flags = ${arduino_base.build_flags} diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index b529bf0e4..fac9a5796 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -356,7 +356,7 @@ class LGFX : public lgfx::LGFX_Device _panel_instance = new lgfx::Panel_ILI9341; auto buscfg = _bus_instance.config(); buscfg.spi_mode = 0; - _bus_instance.spi_device(DisplaySPI); + buscfg.spi_host = settingsMap[displayspidev]; buscfg.pin_dc = settingsMap[displayDC]; // Set SPI DC pin number (-1 = disable) @@ -397,6 +397,8 @@ class LGFX : public lgfx::LGFX_Device touch_cfg.offset_rotation = 1; if (settingsMap[touchscreenI2CAddr] != -1) { touch_cfg.i2c_addr = settingsMap[touchscreenI2CAddr]; + } else { + touch_cfg.spi_host = settingsMap[touchscreenspidev]; } _touch_instance->config(touch_cfg); diff --git a/src/main.cpp b/src/main.cpp index 4a663a8a0..063e9b355 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -729,7 +729,7 @@ 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(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -743,7 +743,7 @@ 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(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -758,7 +758,7 @@ void setup() } else if (settingsMap[use_sx1280]) { if (!rIf) { LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { @@ -773,7 +773,7 @@ void setup() } else if (settingsMap[use_sx1268]) { if (!rIf) { LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s\n", settingsStrings[spidev].c_str()); - LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); rIf = new SX1268Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], settingsMap[busy]); if (!rIf->init()) { diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 8572f4cf2..6151da227 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -15,8 +15,6 @@ #include #include -HardwareSPI *DisplaySPI; -HardwareSPI *LoraSPI; std::map settingsMap; std::map settingsStrings; char *configPath = nullptr; @@ -173,6 +171,15 @@ void portduinoSetup() gpioChipName += std::to_string(settingsMap[gpiochip]); settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as("spidev0.0"); + if (settingsStrings[spidev].length() == 14) { + int x = settingsStrings[spidev].at(11) - '0'; + int y = settingsStrings[spidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[spidev] = x + y << 4; + settingsMap[displayspidev] = settingsMap[spidev]; + settingsMap[touchscreenspidev] = settingsMap[spidev]; + } + } } if (yamlConfig["GPIO"]) { settingsMap[user] = yamlConfig["GPIO"]["User"].as(RADIOLIB_NC); @@ -222,6 +229,14 @@ void portduinoSetup() settingsMap[displayBusFrequency] = yamlConfig["Display"]["BusFrequency"].as(40000000); if (yamlConfig["Display"]["spidev"]) { settingsStrings[displayspidev] = "/dev/" + yamlConfig["Display"]["spidev"].as("spidev0.1"); + if (settingsStrings[displayspidev].length() == 14) { + int x = settingsStrings[displayspidev].at(11) - '0'; + int y = settingsStrings[displayspidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[displayspidev] = x + y << 4; + settingsMap[touchscreenspidev] = settingsMap[displayspidev]; + } + } } } settingsMap[touchscreenModule] = no_touchscreen; @@ -241,6 +256,13 @@ void portduinoSetup() settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as(-1); if (yamlConfig["Touchscreen"]["spidev"]) { settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as(""); + if (settingsStrings[touchscreenspidev].length() == 14) { + int x = settingsStrings[touchscreenspidev].at(11) - '0'; + int y = settingsStrings[touchscreenspidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[touchscreenspidev] = x + y << 4; + } + } } } if (yamlConfig["Input"]) { @@ -319,27 +341,9 @@ void portduinoSetup() if (settingsMap[touchscreenIRQ] > 0) initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName); } - - // if we specify a touchscreen dev, that is SPI. - // else if we specify a screen dev, that is SPI - // else if we specify a LoRa dev, that is SPI. - if (settingsStrings[touchscreenspidev] != "") { - SPI.begin(settingsStrings[touchscreenspidev].c_str()); - DisplaySPI = new HardwareSPI; - DisplaySPI->begin(settingsStrings[displayspidev].c_str()); - LoraSPI = new HardwareSPI; - LoraSPI->begin(settingsStrings[spidev].c_str()); - } else if (settingsStrings[displayspidev] != "") { - SPI.begin(settingsStrings[displayspidev].c_str()); - DisplaySPI = &SPI; - LoraSPI = new HardwareSPI; - LoraSPI->begin(settingsStrings[spidev].c_str()); - } else { + if (settingsStrings[spidev] != "") { SPI.begin(settingsStrings[spidev].c_str()); - LoraSPI = &SPI; - DisplaySPI = &SPI; } - return; } diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 94cdbf2f8..995793a21 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -56,6 +56,4 @@ enum { level_error, level_warn, level_info, level_debug }; extern std::map settingsMap; extern std::map settingsStrings; -int initGPIOPin(int pinNum, std::string gpioChipname); -extern HardwareSPI *DisplaySPI; -extern HardwareSPI *LoraSPI; \ No newline at end of file +int initGPIOPin(int pinNum, std::string gpioChipname); \ No newline at end of file From 0f4ac945591545cefb6c645573b1ef0a880cc745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 2 May 2024 12:48:50 +0200 Subject: [PATCH 055/159] fix building new TWC_mesh_v4 board --- variants/TWC_mesh_v4/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/TWC_mesh_v4/platformio.ini b/variants/TWC_mesh_v4/platformio.ini index 9cf25c685..481682143 100644 --- a/variants/TWC_mesh_v4/platformio.ini +++ b/variants/TWC_mesh_v4/platformio.ini @@ -1,6 +1,6 @@ [env:TWC_mesh_v4] extends = nrf52840_base -board = TWC_mesh_v4 +board = nordic_pca10059 board_level = extra build_flags = ${nrf52840_base.build_flags} -I variants/TWC_mesh_v4 -D TWC_mesh_v4 -L".pio\libdeps\TWC_mesh_v4\BSEC2 Software Library\src\cortex-m4\fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/TWC_mesh_v4> From 5f929a80244e7f5d4fda0df4571ecb0edbe55950 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Thu, 2 May 2024 20:13:36 +0800 Subject: [PATCH 056/159] Publish fixed position updates and consider changes in only altitude as an updated point (#3758) * AdminModule: Publish fixed position updates Enabled GPS thread when fixed position is updated, to let the GPS thread run once and publish the new fixed position. Signed-off-by: Andrew Yong * GPS: Consider changes in only altitude as an updated point Signed-off-by: Andrew Yong --------- Signed-off-by: Andrew Yong --- src/gps/GPS.cpp | 2 +- src/modules/AdminModule.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 17e35a4b3..1c1aac7ad 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1467,7 +1467,7 @@ bool GPS::lookForLocation() #endif // GPS_EXTRAVERBOSE // Is this a new point or are we re-reading the previous one? - if (!reader.location.isUpdated()) + if (!reader.location.isUpdated() && !reader.altitude.isUpdated()) return false; // check if a complete GPS solution set is available for reading diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 54eb577f7..37e798b3c 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -23,6 +23,10 @@ #include "mqtt/MQTT.h" #endif +#if !MESHTASTIC_EXCLUDE_GPS +#include "GPS.h" +#endif + AdminModule *adminModule; bool hasOpenEditTransaction; @@ -217,6 +221,10 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta nodeDB->setLocalPosition(r->set_fixed_position); config.position.fixed_position = true; saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); +#if !MESHTASTIC_EXCLUDE_GPS + if (gps != nullptr) + gps->enable(); +#endif } break; } From 0527fb10ce28fb054d74c9c0848717cdb2cc15e0 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 3 May 2024 00:14:44 +1200 Subject: [PATCH 057/159] Init. battery voltage from ADC reading, instead of fixed value (#3761) --- src/Power.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Power.cpp b/src/Power.cpp index 2658b74a4..770bf4b5a 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -223,7 +223,17 @@ class AnalogBatteryLevel : public HasBatteryLevel raw = raw / BATTERY_SENSE_SAMPLES; scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / pow(2, BATTERY_SENSE_RESOLUTION_BITS)) * raw; #endif - last_read_value += (scaled - last_read_value) * 0.5; // Virtual LPF + + if (!initial_read_done) { + // Flush the smoothing filter with an ADC reading, if the reading is plausibly correct + if (scaled > last_read_value) + last_read_value = scaled; + initial_read_done = true; + } else { + // Already initialized - filter this reading + last_read_value += (scaled - last_read_value) * 0.5; // Virtual LPF + } + // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u filtered=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled), (uint32_t) // (last_read_value)); } @@ -357,6 +367,8 @@ class AnalogBatteryLevel : public HasBatteryLevel const float noBatVolt = (OCV[NUM_OCV_POINTS - 1] - 500) * NUM_CELLS; // Start value from minimum voltage for the filter to not start from 0 // that could trigger some events. + // This value is over-written by the first ADC reading, it the voltage seems reasonable. + bool initial_read_done = false; float last_read_value = (OCV[NUM_OCV_POINTS - 1] * NUM_CELLS); uint32_t last_read_time_ms = 0; From d1b6f1142909efb9e82c1983c92670bc08712bce Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Thu, 2 May 2024 14:27:25 +0800 Subject: [PATCH 058/159] Fix t-echo gps failure --- variants/t-echo/variant.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 6a5146dc0..2abeed16d 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -131,7 +131,7 @@ External serial flash WP25R1635FZUIL0 // Note DIO2 is attached internally to the module to an analog switch for TX/RX switching #define SX1262_DIO3 \ (0 + 21) // This is used as an *output* from the sx1262 and connected internally to power the tcxo, do not drive from the main - // CPU? +// CPU? #define SX126X_BUSY (0 + 17) #define SX126X_RESET (0 + 25) // Not really an E22 but TTGO seems to be trying to clone that @@ -177,13 +177,13 @@ External serial flash WP25R1635FZUIL0 #define PIN_GPS_STANDBY (32 + 2) // An output to wake GPS, low means allow sleep, high means force wake // Seems to be missing on this new board // #define PIN_GPS_PPS (32 + 4) // Pulse per second input from the GPS -#define PIN_GPS_TX (32 + 9) // This is for bits going TOWARDS the CPU -#define PIN_GPS_RX (32 + 8) // This is for bits going TOWARDS the GPS +#define GPS_TX_PIN (32 + 9) // This is for bits going TOWARDS the CPU +#define GPS_RX_PIN (32 + 8) // This is for bits going TOWARDS the GPS #define GPS_THREAD_INTERVAL 50 -#define PIN_SERIAL1_RX PIN_GPS_TX -#define PIN_SERIAL1_TX PIN_GPS_RX +#define PIN_SERIAL1_RX GPS_TX_PIN +#define PIN_SERIAL1_TX GPS_RX_PIN // PCF8563 RTC Module #define PCF8563_RTC 0x51 From 71400103b3e9f981cc1ac7f3dff4c24b663a93ab Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Thu, 2 May 2024 18:39:18 +0000 Subject: [PATCH 059/159] set USB_CDC_ON_BOOT, udate arduinoespressif32 to 2.0.15 (#3764) --- boards/tbeam-s3-core.json | 1 + variants/tbeam-s3-core/platformio.ini | 2 ++ 2 files changed, 3 insertions(+) diff --git a/boards/tbeam-s3-core.json b/boards/tbeam-s3-core.json index 4c82a2789..8d2c3eed6 100644 --- a/boards/tbeam-s3-core.json +++ b/boards/tbeam-s3-core.json @@ -7,6 +7,7 @@ "extra_flags": [ "-DBOARD_HAS_PSRAM", "-DLILYGO_TBEAM_S3_CORE", + "-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index 99d315a69..926f15a39 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -3,6 +3,8 @@ extends = esp32s3_base board = tbeam-s3-core +platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.15 + lib_deps = ${esp32s3_base.lib_deps} lewisxhe/PCF8563_Library@1.0.1 From 06e7d2b8459f86e55cae1ab5a2bb5e2a21d7b118 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 2 May 2024 13:39:28 -0500 Subject: [PATCH 060/159] Track actual GPIO values, not just the enum values (#3768) * Track actual GPIO values, not just the enum values * trunk --- src/platform/portduino/PortduinoGlue.cpp | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 6151da227..35cee2d2f 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -75,20 +75,20 @@ void portduinoSetup() { printf("Setting up Meshtastic on Portduino...\n"); int max_GPIO = 0; - int GPIO_lines[] = {cs, - irq, - busy, - reset, - txen, - rxen, - displayDC, - displayCS, - displayBacklight, - displayBacklightPWMChannel, - displayReset, - touchscreenCS, - touchscreenIRQ, - user}; + configNames GPIO_lines[] = {cs, + irq, + busy, + reset, + txen, + rxen, + displayDC, + displayCS, + displayBacklight, + displayBacklightPWMChannel, + displayReset, + touchscreenCS, + touchscreenIRQ, + user}; std::string gpioChipName = "gpiochip"; settingsStrings[i2cdev] = ""; @@ -281,9 +281,9 @@ void portduinoSetup() exit(EXIT_FAILURE); } - for (int i : GPIO_lines) { - if (i > max_GPIO) - max_GPIO = i; + for (configNames i : GPIO_lines) { + if (settingsMap[i] > max_GPIO) + max_GPIO = settingsMap[i]; } gpioInit(max_GPIO + 1); // Done here so we can inform Portduino how many GPIOs we need. From b69a1cada916bec7bf39cd970f9412e5de464cb7 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 2 May 2024 13:54:50 -0500 Subject: [PATCH 061/159] Portduino bump to pick up minor fix (#3770) --- arch/portduino/portduino.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 162411972..63f5576b6 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based sim environment on top of any host OS, all hardware will be simulated [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#784007630ca43b4811c6637606440588bb5acf39 +platform = https://github.com/meshtastic/platform-native.git#9881bf3721d610cccacf5ae8e3a07839cce75d63 framework = arduino build_src_filter = @@ -34,4 +34,4 @@ build_flags = -DPORTDUINO_LINUX_HARDWARE -lbluetooth -lgpiod - -lyaml-cpp \ No newline at end of file + -lyaml-cpp From 9501f3bda9de00db7c2804270f0f6fd366ac4ebf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 16:17:41 -0500 Subject: [PATCH 062/159] [create-pull-request] automated change (#3771) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 36607a956..a7a7fb1bd 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 8 +build = 9 From 5dfa4b837fe87e08ea71b4c8ec0b1d6d65729015 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 3 May 2024 12:11:13 +1200 Subject: [PATCH 063/159] Ensure LED is off when disabling heartbeat (#3772) --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 063e9b355..c2c824968 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -693,6 +693,12 @@ void setup() // Now that the mesh service is created, create any modules setupModules(); +#ifdef LED_PIN + // Turn LED off after boot, if heartbeat by config + if (config.device.led_heartbeat_disabled) + digitalWrite(LED_PIN, LOW ^ LED_INVERTED); +#endif + // Do this after service.init (because that clears error_code) #ifdef HAS_PMU if (!pmu_found) From d490a332a7f2e6978a24a0033a5ebb4c29b5117a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 2 May 2024 19:11:35 -0500 Subject: [PATCH 064/159] Update version.properties --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index a7a7fb1bd..36607a956 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 9 +build = 8 From 09080d76ad29dc40f450a9ba944ef4ed5f7a4f10 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 20:46:22 -0500 Subject: [PATCH 065/159] [create-pull-request] automated change (#3773) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 36607a956..a7a7fb1bd 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 3 -build = 8 +build = 9 From be0e882be1dc59e13c07e94bb0986c14846983a6 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Sat, 27 Apr 2024 18:05:39 +1200 Subject: [PATCH 066/159] exclude sensors when MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR set --- src/AccelerometerThread.h | 6 +++++- src/modules/Telemetry/AirQualityTelemetry.cpp | 4 ++++ src/modules/Telemetry/AirQualityTelemetry.h | 4 ++++ src/modules/Telemetry/EnvironmentTelemetry.cpp | 6 +++++- src/modules/Telemetry/EnvironmentTelemetry.h | 4 ++++ src/modules/Telemetry/Sensor/BME280Sensor.cpp | 5 ++++- src/modules/Telemetry/Sensor/BME280Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 4 ++++ src/modules/Telemetry/Sensor/BME680Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/BMP085Sensor.cpp | 4 ++++ src/modules/Telemetry/Sensor/BMP085Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/BMP280Sensor.cpp | 4 ++++ src/modules/Telemetry/Sensor/BMP280Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/INA219Sensor.cpp | 6 +++++- src/modules/Telemetry/Sensor/INA219Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/INA260Sensor.cpp | 6 +++++- src/modules/Telemetry/Sensor/INA260Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/INA3221Sensor.cpp | 6 +++++- src/modules/Telemetry/Sensor/INA3221Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/LPS22HBSensor.cpp | 6 +++++- src/modules/Telemetry/Sensor/LPS22HBSensor.h | 6 +++++- src/modules/Telemetry/Sensor/MCP9808Sensor.cpp | 6 +++++- src/modules/Telemetry/Sensor/MCP9808Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/SHT31Sensor.cpp | 4 ++++ src/modules/Telemetry/Sensor/SHT31Sensor.h | 4 ++++ src/modules/Telemetry/Sensor/SHTC3Sensor.cpp | 6 +++++- src/modules/Telemetry/Sensor/SHTC3Sensor.h | 6 +++++- src/modules/Telemetry/Sensor/TelemetrySensor.cpp | 4 ++++ src/modules/Telemetry/Sensor/TelemetrySensor.h | 6 +++++- src/modules/Telemetry/Sensor/VoltageSensor.h | 6 +++++- .../Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c | 4 ++++ .../Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h | 4 ++++ 32 files changed, 148 insertions(+), 21 deletions(-) diff --git a/src/AccelerometerThread.h b/src/AccelerometerThread.h index fa5acdaae..6c76c74ca 100644 --- a/src/AccelerometerThread.h +++ b/src/AccelerometerThread.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "PowerFSM.h" #include "concurrency/OSThread.h" #include "configuration.h" @@ -172,4 +174,6 @@ class AccelerometerThread : public concurrency::OSThread Adafruit_LSM6DS3TRC lsm; }; -} // namespace concurrency \ No newline at end of file +} // namespace concurrency + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index a51a7cea9..d8490c897 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "AirQualityTelemetry.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "Default.h" @@ -130,3 +132,5 @@ bool AirQualityTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) } return true; } + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/AirQualityTelemetry.h b/src/modules/Telemetry/AirQualityTelemetry.h index ab77d61e7..882fca3a6 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.h +++ b/src/modules/Telemetry/AirQualityTelemetry.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #pragma once #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "Adafruit_PM25AQI.h" @@ -35,3 +37,5 @@ class AirQualityTelemetryModule : private concurrency::OSThread, public Protobuf uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute uint32_t lastSentToMesh = 0; }; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 189ab7ed0..42570d2fa 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "EnvironmentTelemetry.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "Default.h" @@ -278,4 +280,6 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) } } return valid; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/EnvironmentTelemetry.h b/src/modules/Telemetry/EnvironmentTelemetry.h index d6cd2137f..3e3055456 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.h +++ b/src/modules/Telemetry/EnvironmentTelemetry.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #pragma once #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" @@ -42,3 +44,5 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu uint32_t lastSentToPhone = 0; uint32_t sensor_read_error_count = 0; }; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp index a30614123..5f9b4cfb4 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "BME280Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -35,4 +37,5 @@ bool BME280Sensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.barometric_pressure = bme280.readPressure() / 100.0F; return true; -} \ No newline at end of file + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.h b/src/modules/Telemetry/Sensor/BME280Sensor.h index 2034c0a82..086cb0fbc 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.h +++ b/src/modules/Telemetry/Sensor/BME280Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -14,4 +16,6 @@ class BME280Sensor : public TelemetrySensor BME280Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index e1222bba4..4cd893656 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "BME680Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "FSCommon.h" @@ -134,3 +136,5 @@ void BME680Sensor::checkStatus(String functionName) else if (bme680.sensor.status > BME68X_OK) LOG_WARN("%s BME68X code: %s\n", functionName.c_str(), String(bme680.sensor.status).c_str()); } + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.h b/src/modules/Telemetry/Sensor/BME680Sensor.h index 4b7f84cf0..8855a01d2 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.h +++ b/src/modules/Telemetry/Sensor/BME680Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -35,4 +37,6 @@ class BME680Sensor : public TelemetrySensor int32_t runTrigger(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp index b0991749b..4aac00d5b 100644 --- a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "BMP085Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -29,3 +31,5 @@ bool BMP085Sensor::getMetrics(meshtastic_Telemetry *measurement) return true; } + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BMP085Sensor.h b/src/modules/Telemetry/Sensor/BMP085Sensor.h index c4a9479b9..0f8b651ff 100644 --- a/src/modules/Telemetry/Sensor/BMP085Sensor.h +++ b/src/modules/Telemetry/Sensor/BMP085Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -14,4 +16,6 @@ class BMP085Sensor : public TelemetrySensor BMP085Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp index 408532388..5cd40b9c7 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "BMP280Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -35,3 +37,5 @@ bool BMP280Sensor::getMetrics(meshtastic_Telemetry *measurement) return true; } + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.h b/src/modules/Telemetry/Sensor/BMP280Sensor.h index 48581df8f..738f2fd65 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.h +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -14,4 +16,6 @@ class BMP280Sensor : public TelemetrySensor BMP280Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.cpp b/src/modules/Telemetry/Sensor/INA219Sensor.cpp index ecb564368..88eff39d8 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA219Sensor.cpp @@ -1,3 +1,5 @@ +#if HAS_TELEMETRY + #include "INA219Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -37,4 +39,6 @@ bool INA219Sensor::getMetrics(meshtastic_Telemetry *measurement) uint16_t INA219Sensor::getBusVoltageMv() { return lround(ina219.getBusVoltage_V() * 1000); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.h b/src/modules/Telemetry/Sensor/INA219Sensor.h index 76f4613db..66107081c 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.h +++ b/src/modules/Telemetry/Sensor/INA219Sensor.h @@ -1,3 +1,5 @@ +#if HAS_TELEMETRY + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include "VoltageSensor.h" @@ -16,4 +18,6 @@ class INA219Sensor : public TelemetrySensor, VoltageSensor virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual uint16_t getBusVoltageMv() override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.cpp b/src/modules/Telemetry/Sensor/INA260Sensor.cpp index 89b7580d2..094cb4eee 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA260Sensor.cpp @@ -1,3 +1,5 @@ +#if HAS_TELEMETRY + #include "INA260Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -32,4 +34,6 @@ bool INA260Sensor::getMetrics(meshtastic_Telemetry *measurement) uint16_t INA260Sensor::getBusVoltageMv() { return lround(ina260.readBusVoltage()); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.h b/src/modules/Telemetry/Sensor/INA260Sensor.h index 28e8944bf..b13d87966 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.h +++ b/src/modules/Telemetry/Sensor/INA260Sensor.h @@ -1,3 +1,5 @@ +#if HAS_TELEMETRY + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include "VoltageSensor.h" @@ -16,4 +18,6 @@ class INA260Sensor : public TelemetrySensor, VoltageSensor virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual uint16_t getBusVoltageMv() override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp index 3269ba47a..a12266b0a 100644 --- a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp @@ -1,3 +1,5 @@ +#if HAS_TELEMETRY + #include "INA3221Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -41,4 +43,6 @@ bool INA3221Sensor::getMetrics(meshtastic_Telemetry *measurement) uint16_t INA3221Sensor::getBusVoltageMv() { return lround(ina3221.getVoltage(INA3221_CH1) * 1000); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA3221Sensor.h b/src/modules/Telemetry/Sensor/INA3221Sensor.h index 4c82fc34d..4d894d1b7 100644 --- a/src/modules/Telemetry/Sensor/INA3221Sensor.h +++ b/src/modules/Telemetry/Sensor/INA3221Sensor.h @@ -1,3 +1,5 @@ +#if HAS_TELEMETRY + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include "VoltageSensor.h" @@ -16,4 +18,6 @@ class INA3221Sensor : public TelemetrySensor, VoltageSensor int32_t runOnce() override; bool getMetrics(meshtastic_Telemetry *measurement) override; virtual uint16_t getBusVoltageMv() override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp index 6e30113cd..5329e5264 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "LPS22HBSensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -32,4 +34,6 @@ bool LPS22HBSensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.barometric_pressure = pressure.pressure; return true; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.h b/src/modules/Telemetry/Sensor/LPS22HBSensor.h index 5b86539b1..10fa93bfc 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.h +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -15,4 +17,6 @@ class LPS22HBSensor : public TelemetrySensor LPS22HBSensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp index c1d9bfa71..f2ecce8fa 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "MCP9808Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -26,4 +28,6 @@ bool MCP9808Sensor::getMetrics(meshtastic_Telemetry *measurement) LOG_DEBUG("MCP9808Sensor::getMetrics\n"); measurement->variant.environment_metrics.temperature = mcp9808.readTempC(); return true; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.h b/src/modules/Telemetry/Sensor/MCP9808Sensor.h index c1029f8a7..f7d3311f0 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.h +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -14,4 +16,6 @@ class MCP9808Sensor : public TelemetrySensor MCP9808Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp index 35978d970..3c7030f89 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "SHT31Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -29,3 +31,5 @@ bool SHT31Sensor::getMetrics(meshtastic_Telemetry *measurement) return true; } + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.h b/src/modules/Telemetry/Sensor/SHT31Sensor.h index c6f8f1596..b2f74a8b2 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.h +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -15,3 +17,5 @@ class SHT31Sensor : public TelemetrySensor virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; }; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp index b0b5d37dc..e1a6c5015 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "SHTC3Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" @@ -30,4 +32,6 @@ bool SHTC3Sensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity; return true; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.h b/src/modules/Telemetry/Sensor/SHTC3Sensor.h index e5db417f5..dc437b38f 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.h +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -14,4 +16,6 @@ class SHTC3Sensor : public TelemetrySensor SHTC3Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp index cd8fe2566..d8df499f1 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp @@ -1,4 +1,8 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "TelemetrySensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" #include "main.h" + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.h b/src/modules/Telemetry/Sensor/TelemetrySensor.h index 7282e6dfa..d48ff2b9a 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.h +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.h @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #pragma once #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" @@ -45,4 +47,6 @@ class TelemetrySensor virtual bool isRunning() { return status > 0; } virtual bool getMetrics(meshtastic_Telemetry *measurement) = 0; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/VoltageSensor.h b/src/modules/Telemetry/Sensor/VoltageSensor.h index f2f28fb06..e3f79b833 100644 --- a/src/modules/Telemetry/Sensor/VoltageSensor.h +++ b/src/modules/Telemetry/Sensor/VoltageSensor.h @@ -1,7 +1,11 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #pragma once class VoltageSensor { public: virtual uint16_t getBusVoltageMv() = 0; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c b/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c index 1f27e6c69..0b5328306 100644 --- a/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c +++ b/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c @@ -1,3 +1,5 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "bsec_iaq.h" const uint8_t bsec_config_iaq[1974] = { @@ -80,3 +82,5 @@ const uint8_t bsec_config_iaq[1974] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 44, 1, 0, 5, 10, 5, 0, 2, 0, 10, 0, 30, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 64, 1, 100, 0, 100, 0, 100, 0, 200, 0, 200, 0, 200, 0, 64, 1, 64, 1, 64, 1, 10, 0, 0, 0, 0, 0, 21, 122, 0, 0}; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h b/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h index cdd209ae5..d693f1e6a 100644 --- a/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h +++ b/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h @@ -1,3 +1,7 @@ +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include extern const uint8_t bsec_config_iaq[1974]; + +#endif \ No newline at end of file From eaa7e21bc772d89b3ee722e6613948e82844bb28 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Mon, 29 Apr 2024 13:57:54 +1200 Subject: [PATCH 067/159] exclude AccelerometerThread when MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR is set --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c2c824968..dbd470378 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -197,7 +197,9 @@ uint32_t timeLastPowered = 0; static Periodic *ledPeriodic; static OSThread *powerFSMthread; +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR static OSThread *accelerometerThread; +#endif static OSThread *ambientLightingThread; SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0); @@ -604,7 +606,7 @@ void setup() screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64 #endif -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !(MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR) if (acc_info.type != ScanI2C::DeviceType::NONE) { config.display.wake_on_tap_or_motion = true; moduleConfig.external_notification.enabled = true; From 668b716119adfa787e114a9dddb7b31ddbf910b9 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Mon, 29 Apr 2024 13:58:21 +1200 Subject: [PATCH 068/159] move QMC5883LCompass dependency to environmental_base --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index e178fdb16..a6db1c76e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -96,7 +96,6 @@ check_flags = framework = arduino lib_deps = ${env.lib_deps} - mprograms/QMC5883LCompass@^1.2.0 end2endzone/NonBlockingRTTTL@^1.3.0 https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#5cf62b36c6f30bc72a07bdb2c11fc9a22d1e31da @@ -132,4 +131,5 @@ lib_deps = adafruit/Adafruit MPU6050@^2.2.4 adafruit/Adafruit LIS3DH@^1.2.4 https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 - adafruit/Adafruit LSM6DS@^4.7.2 \ No newline at end of file + adafruit/Adafruit LSM6DS@^4.7.2 + mprograms/QMC5883LCompass@^1.2.0 From 077ca5919a800d638cbd3c4d6adcc9327fde5a44 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Mon, 29 Apr 2024 22:10:49 +1200 Subject: [PATCH 069/159] MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR refinements --- src/AccelerometerThread.h | 3 ++- src/Power.cpp | 6 +++--- src/main.cpp | 2 +- src/modules/CannedMessageModule.cpp | 3 ++- src/modules/Modules.cpp | 2 +- src/modules/Telemetry/AirQualityTelemetry.cpp | 3 ++- src/modules/Telemetry/AirQualityTelemetry.h | 2 ++ src/modules/Telemetry/EnvironmentTelemetry.cpp | 3 ++- src/modules/Telemetry/EnvironmentTelemetry.h | 2 ++ src/modules/Telemetry/PowerTelemetry.cpp | 9 +++++++-- src/modules/Telemetry/PowerTelemetry.h | 7 +++++++ src/modules/Telemetry/Sensor/BME280Sensor.cpp | 5 +++-- src/modules/Telemetry/Sensor/BME280Sensor.h | 2 ++ src/modules/Telemetry/Sensor/BME680Sensor.cpp | 3 ++- src/modules/Telemetry/Sensor/BME680Sensor.h | 2 ++ src/modules/Telemetry/Sensor/BMP085Sensor.cpp | 3 ++- src/modules/Telemetry/Sensor/BMP085Sensor.h | 2 ++ src/modules/Telemetry/Sensor/BMP280Sensor.cpp | 3 ++- src/modules/Telemetry/Sensor/BMP280Sensor.h | 2 ++ src/modules/Telemetry/Sensor/INA219Sensor.cpp | 5 +++-- src/modules/Telemetry/Sensor/INA219Sensor.h | 4 +++- src/modules/Telemetry/Sensor/INA260Sensor.cpp | 5 +++-- src/modules/Telemetry/Sensor/INA260Sensor.h | 4 +++- src/modules/Telemetry/Sensor/INA3221Sensor.cpp | 5 +++-- src/modules/Telemetry/Sensor/INA3221Sensor.h | 4 +++- src/modules/Telemetry/Sensor/LPS22HBSensor.cpp | 3 ++- src/modules/Telemetry/Sensor/LPS22HBSensor.h | 2 ++ src/modules/Telemetry/Sensor/MCP9808Sensor.cpp | 3 ++- src/modules/Telemetry/Sensor/MCP9808Sensor.h | 2 ++ src/modules/Telemetry/Sensor/SHT31Sensor.cpp | 3 ++- src/modules/Telemetry/Sensor/SHT31Sensor.h | 2 ++ src/modules/Telemetry/Sensor/SHTC3Sensor.cpp | 3 ++- src/modules/Telemetry/Sensor/SHTC3Sensor.h | 2 ++ src/modules/Telemetry/Sensor/TelemetrySensor.cpp | 2 ++ src/modules/Telemetry/Sensor/TelemetrySensor.h | 2 ++ src/modules/Telemetry/Sensor/VoltageSensor.h | 2 ++ src/power.h | 3 ++- 37 files changed, 90 insertions(+), 30 deletions(-) diff --git a/src/AccelerometerThread.h b/src/AccelerometerThread.h index 6c76c74ca..66e5624f1 100644 --- a/src/AccelerometerThread.h +++ b/src/AccelerometerThread.h @@ -1,8 +1,9 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "PowerFSM.h" #include "concurrency/OSThread.h" -#include "configuration.h" #include "main.h" #include "power.h" diff --git a/src/Power.cpp b/src/Power.cpp index 770bf4b5a..64e310b68 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -69,7 +69,7 @@ static const uint8_t ext_chrg_detect_value = EXT_CHRG_DETECT_VALUE; #endif #endif -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) INA260Sensor ina260Sensor; INA219Sensor ina219Sensor; INA3221Sensor ina3221Sensor; @@ -184,7 +184,7 @@ class AnalogBatteryLevel : public HasBatteryLevel virtual uint16_t getBattVoltage() override { -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(HAS_PMU) +#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(HAS_PMU) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR if (hasINA()) { LOG_DEBUG("Using INA on I2C addr 0x%x for device battery voltage\n", config.power.device_battery_ina_address); return getINAVoltage(); @@ -372,7 +372,7 @@ class AnalogBatteryLevel : public HasBatteryLevel float last_read_value = (OCV[NUM_OCV_POINTS - 1] * NUM_CELLS); uint32_t last_read_time_ms = 0; -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) uint16_t getINAVoltage() { if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) { diff --git a/src/main.cpp b/src/main.cpp index dbd470378..81a129cc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -606,7 +606,7 @@ void setup() screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64 #endif -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !(MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR) +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR if (acc_info.type != ScanI2C::DeviceType::NONE) { config.display.wake_on_tap_or_motion = true; moduleConfig.external_notification.enabled = true; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index a8b1b994b..65e2c3ee1 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -431,6 +431,7 @@ int32_t CannedMessageModule::runOnce() runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; case 0x9e: // toggle GPS like triple press does +#if !MESHTASTIC_EXCLUDE_GPS if (gps != nullptr) { gps->toggleGpsMode(); } @@ -438,7 +439,7 @@ int32_t CannedMessageModule::runOnce() screen->forceDisplay(); showTemporaryMessage("GPS Toggled"); break; - +#endif // mute (switch off/toggle) external notifications on fn+m case 0xac: if (moduleConfig.external_notification.enabled == true) { diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 5ac45577e..15b356b05 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -146,7 +146,7 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY +#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !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) && \ diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index d8490c897..86d296c34 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "AirQualityTelemetry.h" @@ -8,7 +10,6 @@ #include "PowerFSM.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include "main.h" int32_t AirQualityTelemetryModule::runOnce() diff --git a/src/modules/Telemetry/AirQualityTelemetry.h b/src/modules/Telemetry/AirQualityTelemetry.h index 882fca3a6..eb0355001 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.h +++ b/src/modules/Telemetry/AirQualityTelemetry.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #pragma once diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 42570d2fa..8e2801a49 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "EnvironmentTelemetry.h" @@ -8,7 +10,6 @@ #include "PowerFSM.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include "main.h" #include "power.h" #include "sleep.h" diff --git a/src/modules/Telemetry/EnvironmentTelemetry.h b/src/modules/Telemetry/EnvironmentTelemetry.h index 3e3055456..cdd9491d4 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.h +++ b/src/modules/Telemetry/EnvironmentTelemetry.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #pragma once diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index 713f6aacb..94d47d08a 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -1,3 +1,7 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "PowerTelemetry.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "Default.h" @@ -6,7 +10,6 @@ #include "PowerFSM.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include "main.h" #include "power.h" #include "sleep.h" @@ -217,4 +220,6 @@ bool PowerTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) } } return valid; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/PowerTelemetry.h b/src/modules/Telemetry/PowerTelemetry.h index fc5b98875..3d6b686f2 100644 --- a/src/modules/Telemetry/PowerTelemetry.h +++ b/src/modules/Telemetry/PowerTelemetry.h @@ -1,4 +1,9 @@ #pragma once + +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" #include "ProtobufModule.h" @@ -41,3 +46,5 @@ class PowerTelemetryModule : private concurrency::OSThread, public ProtobufModul uint32_t lastSentToPhone = 0; uint32_t sensor_read_error_count = 0; }; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp index 5f9b4cfb4..396ba1242 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "BME280Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include #include @@ -37,5 +38,5 @@ bool BME280Sensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.barometric_pressure = bme280.readPressure() / 100.0F; return true; - +} #endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.h b/src/modules/Telemetry/Sensor/BME280Sensor.h index 086cb0fbc..eb78f79f7 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.h +++ b/src/modules/Telemetry/Sensor/BME280Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 4cd893656..77c78e587 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -1,10 +1,11 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "BME680Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "FSCommon.h" #include "TelemetrySensor.h" -#include "configuration.h" BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {} diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.h b/src/modules/Telemetry/Sensor/BME680Sensor.h index 8855a01d2..351db50ab 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.h +++ b/src/modules/Telemetry/Sensor/BME680Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp index 4aac00d5b..be17ddcc2 100644 --- a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "BMP085Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include #include diff --git a/src/modules/Telemetry/Sensor/BMP085Sensor.h b/src/modules/Telemetry/Sensor/BMP085Sensor.h index 0f8b651ff..4ba8c5af1 100644 --- a/src/modules/Telemetry/Sensor/BMP085Sensor.h +++ b/src/modules/Telemetry/Sensor/BMP085Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp index 5cd40b9c7..fbaa9faaa 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "BMP280Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include #include diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.h b/src/modules/Telemetry/Sensor/BMP280Sensor.h index 738f2fd65..da85fdc1d 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.h +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.cpp b/src/modules/Telemetry/Sensor/INA219Sensor.cpp index 88eff39d8..52aaec964 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA219Sensor.cpp @@ -1,9 +1,10 @@ -#if HAS_TELEMETRY +#include "configuration.h" + +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "INA219Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include #ifndef INA219_MULTIPLIER diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.h b/src/modules/Telemetry/Sensor/INA219Sensor.h index 66107081c..9dded067b 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.h +++ b/src/modules/Telemetry/Sensor/INA219Sensor.h @@ -1,4 +1,6 @@ -#if HAS_TELEMETRY +#include "configuration.h" + +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.cpp b/src/modules/Telemetry/Sensor/INA260Sensor.cpp index 094cb4eee..4c51c7f0d 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA260Sensor.cpp @@ -1,9 +1,10 @@ -#if HAS_TELEMETRY +#include "configuration.h" + +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "INA260Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include INA260Sensor::INA260Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_INA260, "INA260") {} diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.h b/src/modules/Telemetry/Sensor/INA260Sensor.h index b13d87966..f436b8f38 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.h +++ b/src/modules/Telemetry/Sensor/INA260Sensor.h @@ -1,4 +1,6 @@ -#if HAS_TELEMETRY +#include "configuration.h" + +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" diff --git a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp index a12266b0a..a3e8af153 100644 --- a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp @@ -1,9 +1,10 @@ -#if HAS_TELEMETRY +#include "configuration.h" + +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "INA3221Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include INA3221Sensor::INA3221Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_INA3221, "INA3221"){}; diff --git a/src/modules/Telemetry/Sensor/INA3221Sensor.h b/src/modules/Telemetry/Sensor/INA3221Sensor.h index 4d894d1b7..3b8e382ee 100644 --- a/src/modules/Telemetry/Sensor/INA3221Sensor.h +++ b/src/modules/Telemetry/Sensor/INA3221Sensor.h @@ -1,4 +1,6 @@ -#if HAS_TELEMETRY +#include "configuration.h" + +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp index 5329e5264..0bd7f145e 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "LPS22HBSensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include #include diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.h b/src/modules/Telemetry/Sensor/LPS22HBSensor.h index 10fa93bfc..955f2a1e5 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.h +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp index f2ecce8fa..9bb8947a2 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "MCP9808Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include MCP9808Sensor::MCP9808Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MCP9808, "MCP9808") {} diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.h b/src/modules/Telemetry/Sensor/MCP9808Sensor.h index f7d3311f0..05bdabf3f 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.h +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp index 3c7030f89..787372b0c 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "SHT31Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include SHT31Sensor::SHT31Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT31, "SHT31") {} diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.h b/src/modules/Telemetry/Sensor/SHT31Sensor.h index b2f74a8b2..560b22436 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.h +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp index e1a6c5015..39b9570fa 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp @@ -1,9 +1,10 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "SHTC3Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" #include SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHTC3, "SHTC3") {} diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.h b/src/modules/Telemetry/Sensor/SHTC3Sensor.h index dc437b38f..7a760292f 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.h +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "../mesh/generated/meshtastic/telemetry.pb.h" diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp index d8df499f1..1c58b37e7 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "TelemetrySensor.h" diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.h b/src/modules/Telemetry/Sensor/TelemetrySensor.h index d48ff2b9a..35cb7965d 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.h +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #pragma once diff --git a/src/modules/Telemetry/Sensor/VoltageSensor.h b/src/modules/Telemetry/Sensor/VoltageSensor.h index e3f79b833..767ffd246 100644 --- a/src/modules/Telemetry/Sensor/VoltageSensor.h +++ b/src/modules/Telemetry/Sensor/VoltageSensor.h @@ -1,3 +1,5 @@ +#include "configuration.h" + #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #pragma once diff --git a/src/power.h b/src/power.h index b94ce8f98..1fa683f8e 100644 --- a/src/power.h +++ b/src/power.h @@ -1,4 +1,5 @@ #pragma once +#include "configuration.h" #include "PowerStatus.h" #include "concurrency/OSThread.h" #ifdef ARCH_ESP32 @@ -36,7 +37,7 @@ extern RTC_NOINIT_ATTR uint64_t RTC_reg_b; #include "soc/sens_reg.h" // needed for adc pin reset #endif -#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) +#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) #include "modules/Telemetry/Sensor/INA219Sensor.h" #include "modules/Telemetry/Sensor/INA260Sensor.h" #include "modules/Telemetry/Sensor/INA3221Sensor.h" From 6c1377aa39862e6cc1726c83090c540f1087ab92 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Fri, 3 May 2024 18:59:33 +1200 Subject: [PATCH 070/159] fix case statement --- src/modules/CannedMessageModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 65e2c3ee1..f7e39fc8a 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -438,8 +438,8 @@ int32_t CannedMessageModule::runOnce() if (screen) screen->forceDisplay(); showTemporaryMessage("GPS Toggled"); - break; #endif + break; // mute (switch off/toggle) external notifications on fn+m case 0xac: if (moduleConfig.external_notification.enabled == true) { From 827dcfca4a419f386609d02d97932f559bbc091a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 3 May 2024 14:26:57 +0200 Subject: [PATCH 071/159] trunk fmt --- src/modules/CannedMessageModule.cpp | 2 +- src/modules/Telemetry/AirQualityTelemetry.cpp | 2 +- src/modules/Telemetry/EnvironmentTelemetry.cpp | 2 +- src/modules/Telemetry/PowerTelemetry.cpp | 2 +- src/modules/Telemetry/Sensor/BME280Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/BMP085Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/BMP280Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/INA219Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/INA260Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/INA3221Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/LPS22HBSensor.cpp | 2 +- src/modules/Telemetry/Sensor/MCP9808Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/SHT31Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/SHTC3Sensor.cpp | 2 +- src/modules/Telemetry/Sensor/TelemetrySensor.cpp | 2 +- src/power.h | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index f7e39fc8a..8cfea154e 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -431,7 +431,7 @@ int32_t CannedMessageModule::runOnce() runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; case 0x9e: // toggle GPS like triple press does -#if !MESHTASTIC_EXCLUDE_GPS +#if !MESHTASTIC_EXCLUDE_GPS if (gps != nullptr) { gps->toggleGpsMode(); } diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index 86d296c34..e4f31ff9f 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "AirQualityTelemetry.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "AirQualityTelemetry.h" #include "Default.h" #include "MeshService.h" #include "NodeDB.h" diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 8e2801a49..d77a45f18 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -2,9 +2,9 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "EnvironmentTelemetry.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "Default.h" +#include "EnvironmentTelemetry.h" #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index 94d47d08a..e61a4e629 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -2,12 +2,12 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "PowerTelemetry.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "Default.h" #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" +#include "PowerTelemetry.h" #include "RTC.h" #include "Router.h" #include "main.h" diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp index 396ba1242..aea6f2c3d 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "BME280Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "BME280Sensor.h" #include "TelemetrySensor.h" #include #include diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 77c78e587..f2c3804f4 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "BME680Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "BME680Sensor.h" #include "FSCommon.h" #include "TelemetrySensor.h" diff --git a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp index be17ddcc2..0c4d0b5ca 100644 --- a/src/modules/Telemetry/Sensor/BMP085Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP085Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "BMP085Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "BMP085Sensor.h" #include "TelemetrySensor.h" #include #include diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp index fbaa9faaa..8d0e4c180 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "BMP280Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "BMP280Sensor.h" #include "TelemetrySensor.h" #include #include diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.cpp b/src/modules/Telemetry/Sensor/INA219Sensor.cpp index 52aaec964..040e59575 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA219Sensor.cpp @@ -2,8 +2,8 @@ #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "INA219Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "INA219Sensor.h" #include "TelemetrySensor.h" #include diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.cpp b/src/modules/Telemetry/Sensor/INA260Sensor.cpp index 4c51c7f0d..f156a9aba 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA260Sensor.cpp @@ -2,8 +2,8 @@ #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "INA260Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "INA260Sensor.h" #include "TelemetrySensor.h" #include diff --git a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp index a3e8af153..ea2cb4ea8 100644 --- a/src/modules/Telemetry/Sensor/INA3221Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA3221Sensor.cpp @@ -2,8 +2,8 @@ #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "INA3221Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "INA3221Sensor.h" #include "TelemetrySensor.h" #include diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp index 0bd7f145e..c3c994cfa 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "LPS22HBSensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "LPS22HBSensor.h" #include "TelemetrySensor.h" #include #include diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp index 9bb8947a2..b01a19291 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "MCP9808Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "MCP9808Sensor.h" #include "TelemetrySensor.h" #include diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp index 787372b0c..aa2b5dcfc 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "SHT31Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "SHT31Sensor.h" #include "TelemetrySensor.h" #include diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp index 39b9570fa..37685fed7 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "SHTC3Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "SHTC3Sensor.h" #include "TelemetrySensor.h" #include diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp index 1c58b37e7..d6e7d1fac 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp @@ -2,9 +2,9 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "TelemetrySensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" +#include "TelemetrySensor.h" #include "main.h" #endif \ No newline at end of file diff --git a/src/power.h b/src/power.h index 1fa683f8e..8d14ed7f8 100644 --- a/src/power.h +++ b/src/power.h @@ -1,7 +1,7 @@ #pragma once -#include "configuration.h" #include "PowerStatus.h" #include "concurrency/OSThread.h" +#include "configuration.h" #ifdef ARCH_ESP32 #include #include From dc0593c5a74927e77b61b30f155b3d7fb7b9cc51 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Fri, 3 May 2024 10:24:18 +0800 Subject: [PATCH 072/159] Fix the infinite restart caused by unformatted t-echo fs file system --- src/FSCommon.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index e7760c575..6a394c021 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -212,8 +212,23 @@ void fsInit() LOG_ERROR("Filesystem mount Failed.\n"); // assert(0); This auto-formats the partition, so no need to fail here. } -#ifdef ARCH_ESP32 +#if defined(ARCH_ESP32) LOG_DEBUG("Filesystem files (%d/%d Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes()); +#elif defined(ARCH_NRF52) + /* + * 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. + * */ + 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(); + } #else LOG_DEBUG("Filesystem files:\n"); #endif From 5f90f45ac44e74f403d2c3670586c0897c7ae76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 3 May 2024 12:37:19 +0200 Subject: [PATCH 073/159] trunk fmt --- src/FSCommon.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 6a394c021..d5ca72142 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -212,17 +212,17 @@ void fsInit() LOG_ERROR("Filesystem mount Failed.\n"); // assert(0); This auto-formats the partition, so no need to fail here. } -#if defined(ARCH_ESP32) +#if defined(ARCH_ESP32) LOG_DEBUG("Filesystem files (%d/%d Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes()); #elif defined(ARCH_NRF52) /* - * 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. - * */ + * 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. + * */ Adafruit_LittleFS_Namespace::File file(FSCom); const char *filename = "/meshtastic.txt"; - if (! file.open(filename, FILE_O_WRITE) ) { + if (!file.open(filename, FILE_O_WRITE)) { LOG_DEBUG("Format ...."); FSCom.format(); FSCom.begin(); From 13ad5245381f936bea47d8b8bc0ace142b585108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 3 May 2024 15:10:57 +0200 Subject: [PATCH 074/159] make clang-format happy again. Also fix assorted variable shrouding and logic bleeps --- src/gps/GPS.cpp | 6 +++--- src/mesh/MeshService.cpp | 4 +--- src/mesh/NodeDB.cpp | 2 +- src/mesh/ProtobufModule.h | 3 +-- src/modules/NeighborInfoModule.cpp | 3 +-- src/modules/PositionModule.cpp | 2 +- src/modules/Telemetry/Sensor/RCWL9620Sensor.h | 12 ++++++------ src/platform/portduino/PortduinoGlue.cpp | 12 ++++++------ src/platform/stm32wl/LittleFS_File.cpp | 4 ++-- 9 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 1c1aac7ad..deea076b2 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -62,10 +62,10 @@ void GPS::CASChecksum(uint8_t *message, size_t length) // Iterate over the payload as a series of uint32_t's and // accumulate the cksum - uint32_t *payload = (uint32_t *)(message + 6); + uint32_t const *payload = (uint32_t *)(message + 6); for (size_t i = 0; i < (length - 10) / 4; i++) { - uint32_t p = payload[i]; - cksum += p; + uint32_t pl = payload[i]; + cksum += pl; } // Place the checksum values in the message diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 66a2e6952..ddad211a6 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -192,9 +192,7 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p) return; } #endif - if (p.from != 0) { // We don't let phones assign nodenums to their sent messages - p.from = 0; - } + p.from = 0; // We don't let phones assign nodenums to their sent messages if (p.id == 0) p.id = generatePacketId(); // If the phone didn't supply one, then pick one diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 249db627e..906356e7c 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -56,7 +56,7 @@ meshtastic_OEMStore oemStore; bool meshtastic_DeviceState_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_iter_t *field) { if (ostream) { - std::vector *vec = (std::vector *)field->pData; + std::vector const *vec = (std::vector *)field->pData; for (auto item : *vec) { if (!pb_encode_tag_for_field(ostream, field)) return false; diff --git a/src/mesh/ProtobufModule.h b/src/mesh/ProtobufModule.h index a2e89e98a..0d3da9568 100644 --- a/src/mesh/ProtobufModule.h +++ b/src/mesh/ProtobufModule.h @@ -95,12 +95,11 @@ template class ProtobufModule : protected SinglePortModule */ virtual void alterReceived(meshtastic_MeshPacket &mp) override { - auto &p = mp.decoded; - T scratch; T *decoded = NULL; if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) { memset(&scratch, 0, sizeof(scratch)); + auto &p = mp.decoded; if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) { decoded = &scratch; } else { diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index 8c8135deb..3925bea9a 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -116,9 +116,8 @@ Will be used for broadcast. */ int32_t NeighborInfoModule::runOnce() { - bool requestReplies = false; if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) { - sendNeighborInfo(NODENUM_BROADCAST, requestReplies); + sendNeighborInfo(NODENUM_BROADCAST, false); } return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_broadcast_interval_secs); } diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 7c459dc35..9986f860d 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -343,7 +343,7 @@ int32_t PositionModule::runOnce() // The minimum time (in seconds) that would pass before we are able to send a new position packet. auto smartPosition = getDistanceTraveledSinceLastSend(node->position); - uint32_t msSinceLastSend = now - lastGpsSend; + msSinceLastSend = now - lastGpsSend; if (smartPosition.hasTraveledOverThreshold && Throttle::execute( diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h index 4fb2aec2d..b78066f5c 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h @@ -5,15 +5,15 @@ class RCWL9620Sensor : public TelemetrySensor { private: - uint8_t _addr; - TwoWire *_wire; - uint8_t _scl; - uint8_t _sda; - uint8_t _speed; + uint8_t _addr = 0x57; + TwoWire *_wire = &Wire; + uint8_t _scl = -1; + uint8_t _sda = -1; + uint32_t _speed = 200000UL; protected: virtual void setup() override; - void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000L); + void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000UL); float getDistance(); public: diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 35cee2d2f..edb81261c 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -75,7 +75,7 @@ void portduinoSetup() { printf("Setting up Meshtastic on Portduino...\n"); int max_GPIO = 0; - configNames GPIO_lines[] = {cs, + const configNames GPIO_lines[] = {cs, irq, busy, reset, @@ -103,7 +103,7 @@ void portduinoSetup() std::cout << "Using " << configPath << " as config file" << std::endl; try { yamlConfig = YAML::LoadFile(configPath); - } catch (YAML::Exception e) { + } catch (YAML::Exception &e) { std::cout << "Could not open " << configPath << " because of error: " << e.what() << std::endl; exit(EXIT_FAILURE); } @@ -111,7 +111,7 @@ void portduinoSetup() std::cout << "Using local config.yaml as config file" << std::endl; try { yamlConfig = YAML::LoadFile("config.yaml"); - } catch (YAML::Exception e) { + } catch (YAML::Exception &e) { std::cout << "*** Exception " << e.what() << std::endl; exit(EXIT_FAILURE); } @@ -119,7 +119,7 @@ void portduinoSetup() std::cout << "Using /etc/meshtasticd/config.yaml as config file" << std::endl; try { yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml"); - } catch (YAML::Exception e) { + } catch (YAML::Exception &e) { std::cout << "*** Exception " << e.what() << std::endl; exit(EXIT_FAILURE); } @@ -276,7 +276,7 @@ void portduinoSetup() settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as(200); - } catch (YAML::Exception e) { + } catch (YAML::Exception &e) { std::cout << "*** Exception " << e.what() << std::endl; exit(EXIT_FAILURE); } @@ -347,7 +347,7 @@ void portduinoSetup() return; } -int initGPIOPin(int pinNum, std::string gpioChipName) +int initGPIOPin(int pinNum, const std::string& gpioChipName) { std::string gpio_name = "GPIO" + std::to_string(pinNum); try { diff --git a/src/platform/stm32wl/LittleFS_File.cpp b/src/platform/stm32wl/LittleFS_File.cpp index cffb924e1..548a3d300 100644 --- a/src/platform/stm32wl/LittleFS_File.cpp +++ b/src/platform/stm32wl/LittleFS_File.cpp @@ -186,9 +186,9 @@ int File::available(void) _fs->_lockFS(); if (!this->_is_dir) { - uint32_t size = lfs_file_size(_fs->_getFS(), _file); + uint32_t fsize = lfs_file_size(_fs->_getFS(), _file); uint32_t pos = lfs_file_tell(_fs->_getFS(), _file); - ret = size - pos; + ret = fsize - pos; } _fs->_unlockFS(); From 85e0372d26c0471fcb41db1ec470d83e7a736220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 3 May 2024 15:58:16 +0200 Subject: [PATCH 075/159] darn you, trunk. foiled my cunning plan. --- src/platform/portduino/PortduinoGlue.cpp | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index edb81261c..0b8b7e739 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -76,19 +76,19 @@ void portduinoSetup() printf("Setting up Meshtastic on Portduino...\n"); int max_GPIO = 0; const configNames GPIO_lines[] = {cs, - irq, - busy, - reset, - txen, - rxen, - displayDC, - displayCS, - displayBacklight, - displayBacklightPWMChannel, - displayReset, - touchscreenCS, - touchscreenIRQ, - user}; + irq, + busy, + reset, + txen, + rxen, + displayDC, + displayCS, + displayBacklight, + displayBacklightPWMChannel, + displayReset, + touchscreenCS, + touchscreenIRQ, + user}; std::string gpioChipName = "gpiochip"; settingsStrings[i2cdev] = ""; @@ -347,7 +347,7 @@ void portduinoSetup() return; } -int initGPIOPin(int pinNum, const std::string& gpioChipName) +int initGPIOPin(int pinNum, const std::string &gpioChipName) { std::string gpio_name = "GPIO" + std::to_string(pinNum); try { From 61216e579e4b53dd5b693e00438301b596225ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 3 May 2024 19:25:37 +0200 Subject: [PATCH 076/159] there --- src/platform/portduino/PortduinoGlue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 0b8b7e739..7c5086ac2 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -347,7 +347,7 @@ void portduinoSetup() return; } -int initGPIOPin(int pinNum, const std::string &gpioChipName) +int initGPIOPin(int pinNum, const std::string gpioChipName) { std::string gpio_name = "GPIO" + std::to_string(pinNum); try { From 70712d859cdc242b1873fa9b9622cf1c1711fb06 Mon Sep 17 00:00:00 2001 From: tuxphone <67556506+tuxphone@users.noreply.github.com> Date: Fri, 3 May 2024 22:49:22 +0200 Subject: [PATCH 077/159] Enable compiling with gccnoneeabi 12.3.1 for nRF52 targets, additional small fixes (#3778) * Fix type of nodeNum Type of nodeNum is NodeNum, not uint * typo fixed typo "resumeAdverising()" * fix missing #include "time.h" Missing include breaks compilation with gccnoneeabi 12.3.1 for nrf52 targets on windows hosts. * change type uint to unsigned int uint is not a standard type. Using uint breaks compilation with gccnoneeabi 12.3.1 for nRF52 targets on windows hosts. * fix type of channel_num Type of channel_num should be uint32_t (as this is the type of hash() and numChannels). Using uint non-standard type uint breaks compilation with gccnoneeabi 12.3.1 for nRF52 targets on windows hosts. * Update nrf52.ini Default build type should be "release" as this is the default of platformio. * Update GPS.cpp uint to unsigned int --- arch/nrf52/nrf52.ini | 2 +- src/SerialConsole.cpp | 1 + src/gps/GPS.cpp | 4 +-- src/input/TouchScreenBase.h | 1 + src/mesh/NodeDB.cpp | 2 +- src/mesh/NodeDB.h | 2 +- src/mesh/RadioInterface.cpp | 2 +- src/mqtt/JSONValue.cpp | 4 +-- src/mqtt/JSONValue.h | 2 +- src/mqtt/MQTT.cpp | 52 +++++++++++++-------------- src/platform/nrf52/NRF52Bluetooth.cpp | 2 +- src/platform/nrf52/NRF52Bluetooth.h | 2 +- src/platform/nrf52/main-nrf52.cpp | 2 +- 13 files changed, 40 insertions(+), 38 deletions(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 2505fe315..0669a31e8 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 = debug ; I'm debugging with ICE a lot now +build_type = release build_flags = ${arduino_base.build_flags} -DSERIAL_BUFFER_SIZE=1024 diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index e17c8f99e..88a336ecc 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -2,6 +2,7 @@ #include "NodeDB.h" #include "PowerFSM.h" #include "configuration.h" +#include "time.h" #ifdef RP2040_SLOW_CLOCK #define Port Serial2 diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index deea076b2..eaae049b5 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -452,7 +452,7 @@ bool GPS::setup() // Set the NEMA output messages // Ask for only RMC and GGA uint8_t fields[] = {CAS_NEMA_RMC, CAS_NEMA_GGA}; - for (uint i = 0; i < sizeof(fields); i++) { + for (unsigned int i = 0; i < sizeof(fields); i++) { // Construct a CAS-CFG-MSG packet uint8_t cas_cfg_msg_packet[] = {0x4e, fields[i], 0x01, 0x00}; msglen = makeCASPacket(0x06, 0x01, sizeof(cas_cfg_msg_packet), cas_cfg_msg_packet); @@ -1584,7 +1584,7 @@ bool GPS::hasFlow() bool GPS::whileIdle() { - uint charsInBuf = 0; + unsigned int charsInBuf = 0; bool isValid = false; if (!isAwake) { clearBuffer(); diff --git a/src/input/TouchScreenBase.h b/src/input/TouchScreenBase.h index a68c23e99..0b2002551 100644 --- a/src/input/TouchScreenBase.h +++ b/src/input/TouchScreenBase.h @@ -3,6 +3,7 @@ #include "InputBroker.h" #include "concurrency/OSThread.h" #include "mesh/NodeDB.h" +#include "time.h" typedef struct _TouchEvent { const char *source; diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 906356e7c..b693a8a2b 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -449,7 +449,7 @@ void NodeDB::resetNodes() neighborInfoModule->resetNeighbors(); } -void NodeDB::removeNodeByNum(uint nodeNum) +void NodeDB::removeNodeByNum(NodeNum nodeNum) { int newPos = 0, removed = 0; for (int i = 0; i < numMeshNodes; i++) { diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 4946672ec..e9e36cc61 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -124,7 +124,7 @@ class NodeDB */ size_t getNumOnlineMeshNodes(bool localOnly = false); - void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(), removeNodeByNum(uint nodeNum); + void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(), removeNodeByNum(NodeNum nodeNum); bool factoryReset(); diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index f5eb35cbe..cc6ccca07 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -495,7 +495,7 @@ void RadioInterface::applyModemConfig() // If user has manually specified a channel num, then use that, otherwise generate one by hashing the name const char *channelName = channels.getName(channels.getPrimaryIndex()); // channel_num is actually (channel_num - 1), since modulus (%) returns values from 0 to (numChannels - 1) - uint channel_num = (loraConfig.channel_num ? loraConfig.channel_num - 1 : hash(channelName)) % numChannels; + uint32_t channel_num = (loraConfig.channel_num ? loraConfig.channel_num - 1 : hash(channelName)) % numChannels; // Check if we use the default frequency slot RadioInterface::uses_default_frequency_slot = diff --git a/src/mqtt/JSONValue.cpp b/src/mqtt/JSONValue.cpp index a229666a9..51e0c1a3b 100644 --- a/src/mqtt/JSONValue.cpp +++ b/src/mqtt/JSONValue.cpp @@ -368,9 +368,9 @@ JSONValue::JSONValue(int m_integer_value) * * @access public * - * @param uint m_integer_value The number to use as the value + * @param unsigned int m_integer_value The number to use as the value */ -JSONValue::JSONValue(uint m_integer_value) +JSONValue::JSONValue(unsigned int m_integer_value) { type = JSONType_Number; number_value = (double)m_integer_value; diff --git a/src/mqtt/JSONValue.h b/src/mqtt/JSONValue.h index 3a50a831a..0380d324b 100644 --- a/src/mqtt/JSONValue.h +++ b/src/mqtt/JSONValue.h @@ -45,7 +45,7 @@ class JSONValue JSONValue(bool m_bool_value); JSONValue(double m_number_value); JSONValue(int m_integer_value); - JSONValue(uint m_integer_value); + JSONValue(unsigned int m_integer_value); JSONValue(const JSONArray &m_array_value); JSONValue(const JSONObject &m_object_value); JSONValue(const JSONValue &m_source); diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 508830203..95b2daa99 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -659,11 +659,11 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_Telemetry_msg, &scratch)) { decoded = &scratch; if (decoded->which_variant == meshtastic_Telemetry_device_metrics_tag) { - msgPayload["battery_level"] = new JSONValue((uint)decoded->variant.device_metrics.battery_level); + msgPayload["battery_level"] = new JSONValue((unsigned int)decoded->variant.device_metrics.battery_level); msgPayload["voltage"] = new JSONValue(decoded->variant.device_metrics.voltage); msgPayload["channel_utilization"] = new JSONValue(decoded->variant.device_metrics.channel_utilization); msgPayload["air_util_tx"] = new JSONValue(decoded->variant.device_metrics.air_util_tx); - msgPayload["uptime_seconds"] = new JSONValue((uint)decoded->variant.device_metrics.uptime_seconds); + msgPayload["uptime_seconds"] = new JSONValue((unsigned int)decoded->variant.device_metrics.uptime_seconds); } else if (decoded->which_variant == meshtastic_Telemetry_environment_metrics_tag) { msgPayload["temperature"] = new JSONValue(decoded->variant.environment_metrics.temperature); msgPayload["relative_humidity"] = new JSONValue(decoded->variant.environment_metrics.relative_humidity); @@ -710,10 +710,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_Position_msg, &scratch)) { decoded = &scratch; if ((int)decoded->time) { - msgPayload["time"] = new JSONValue((uint)decoded->time); + msgPayload["time"] = new JSONValue((unsigned int)decoded->time); } if ((int)decoded->timestamp) { - msgPayload["timestamp"] = new JSONValue((uint)decoded->timestamp); + msgPayload["timestamp"] = new JSONValue((unsigned int)decoded->timestamp); } msgPayload["latitude_i"] = new JSONValue((int)decoded->latitude_i); msgPayload["longitude_i"] = new JSONValue((int)decoded->longitude_i); @@ -721,13 +721,13 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) msgPayload["altitude"] = new JSONValue((int)decoded->altitude); } if ((int)decoded->ground_speed) { - msgPayload["ground_speed"] = new JSONValue((uint)decoded->ground_speed); + msgPayload["ground_speed"] = new JSONValue((unsigned int)decoded->ground_speed); } if (int(decoded->ground_track)) { - msgPayload["ground_track"] = new JSONValue((uint)decoded->ground_track); + msgPayload["ground_track"] = new JSONValue((unsigned int)decoded->ground_track); } if (int(decoded->sats_in_view)) { - msgPayload["sats_in_view"] = new JSONValue((uint)decoded->sats_in_view); + msgPayload["sats_in_view"] = new JSONValue((unsigned int)decoded->sats_in_view); } if ((int)decoded->PDOP) { msgPayload["PDOP"] = new JSONValue((int)decoded->PDOP); @@ -754,11 +754,11 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) memset(&scratch, 0, sizeof(scratch)); if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_Waypoint_msg, &scratch)) { decoded = &scratch; - msgPayload["id"] = new JSONValue((uint)decoded->id); + msgPayload["id"] = new JSONValue((unsigned int)decoded->id); msgPayload["name"] = new JSONValue(decoded->name); msgPayload["description"] = new JSONValue(decoded->description); - msgPayload["expire"] = new JSONValue((uint)decoded->expire); - msgPayload["locked_to"] = new JSONValue((uint)decoded->locked_to); + msgPayload["expire"] = new JSONValue((unsigned int)decoded->expire); + msgPayload["locked_to"] = new JSONValue((unsigned int)decoded->locked_to); msgPayload["latitude_i"] = new JSONValue((int)decoded->latitude_i); msgPayload["longitude_i"] = new JSONValue((int)decoded->longitude_i); jsonObj["payload"] = new JSONValue(msgPayload); @@ -775,14 +775,14 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_NeighborInfo_msg, &scratch)) { decoded = &scratch; - msgPayload["node_id"] = new JSONValue((uint)decoded->node_id); - msgPayload["node_broadcast_interval_secs"] = new JSONValue((uint)decoded->node_broadcast_interval_secs); - msgPayload["last_sent_by_id"] = new JSONValue((uint)decoded->last_sent_by_id); + msgPayload["node_id"] = new JSONValue((unsigned int)decoded->node_id); + msgPayload["node_broadcast_interval_secs"] = new JSONValue((unsigned int)decoded->node_broadcast_interval_secs); + msgPayload["last_sent_by_id"] = new JSONValue((unsigned int)decoded->last_sent_by_id); msgPayload["neighbors_count"] = new JSONValue(decoded->neighbors_count); JSONArray neighbors; for (uint8_t i = 0; i < decoded->neighbors_count; i++) { JSONObject neighborObj; - neighborObj["node_id"] = new JSONValue((uint)decoded->neighbors[i].node_id); + neighborObj["node_id"] = new JSONValue((unsigned int)decoded->neighbors[i].node_id); neighborObj["snr"] = new JSONValue((int)decoded->neighbors[i].snr); neighbors.push_back(new JSONValue(neighborObj)); } @@ -843,9 +843,9 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) memset(&scratch, 0, sizeof(scratch)); if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &meshtastic_Paxcount_msg, &scratch)) { decoded = &scratch; - msgPayload["wifi_count"] = new JSONValue((uint)decoded->wifi); - msgPayload["ble_count"] = new JSONValue((uint)decoded->ble); - msgPayload["uptime"] = new JSONValue((uint)decoded->uptime); + msgPayload["wifi_count"] = new JSONValue((unsigned int)decoded->wifi); + msgPayload["ble_count"] = new JSONValue((unsigned int)decoded->ble); + msgPayload["uptime"] = new JSONValue((unsigned int)decoded->uptime); jsonObj["payload"] = new JSONValue(msgPayload); } else { LOG_ERROR("Error decoding protobuf for Paxcount message!\n"); @@ -862,12 +862,12 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) decoded = &scratch; if (decoded->type == meshtastic_HardwareMessage_Type_GPIOS_CHANGED) { msgType = "gpios_changed"; - msgPayload["gpio_value"] = new JSONValue((uint)decoded->gpio_value); + msgPayload["gpio_value"] = new JSONValue((unsigned int)decoded->gpio_value); jsonObj["payload"] = new JSONValue(msgPayload); } else if (decoded->type == meshtastic_HardwareMessage_Type_READ_GPIOS_REPLY) { msgType = "gpios_read_reply"; - msgPayload["gpio_value"] = new JSONValue((uint)decoded->gpio_value); - msgPayload["gpio_mask"] = new JSONValue((uint)decoded->gpio_mask); + msgPayload["gpio_value"] = new JSONValue((unsigned int)decoded->gpio_value); + msgPayload["gpio_mask"] = new JSONValue((unsigned int)decoded->gpio_mask); jsonObj["payload"] = new JSONValue(msgPayload); } } else { @@ -883,11 +883,11 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) LOG_WARN("Couldn't convert encrypted payload of MeshPacket to JSON\n"); } - jsonObj["id"] = new JSONValue((uint)mp->id); - jsonObj["timestamp"] = new JSONValue((uint)mp->rx_time); - jsonObj["to"] = new JSONValue((uint)mp->to); - jsonObj["from"] = new JSONValue((uint)mp->from); - jsonObj["channel"] = new JSONValue((uint)mp->channel); + jsonObj["id"] = new JSONValue((unsigned int)mp->id); + jsonObj["timestamp"] = new JSONValue((unsigned int)mp->rx_time); + jsonObj["to"] = new JSONValue((unsigned int)mp->to); + jsonObj["from"] = new JSONValue((unsigned int)mp->from); + jsonObj["channel"] = new JSONValue((unsigned int)mp->channel); jsonObj["type"] = new JSONValue(msgType.c_str()); jsonObj["sender"] = new JSONValue(owner.id); if (mp->rx_rssi != 0) @@ -895,7 +895,7 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) if (mp->rx_snr != 0) jsonObj["snr"] = new JSONValue((float)mp->rx_snr); if (mp->hop_start != 0 && mp->hop_limit <= mp->hop_start) - jsonObj["hops_away"] = new JSONValue((uint)(mp->hop_start - mp->hop_limit)); + jsonObj["hops_away"] = new JSONValue((unsigned int)(mp->hop_start - mp->hop_limit)); // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj); diff --git a/src/platform/nrf52/NRF52Bluetooth.cpp b/src/platform/nrf52/NRF52Bluetooth.cpp index 759cbb404..39898ab25 100644 --- a/src/platform/nrf52/NRF52Bluetooth.cpp +++ b/src/platform/nrf52/NRF52Bluetooth.cpp @@ -287,7 +287,7 @@ void NRF52Bluetooth::setup() LOG_INFO("Advertising\n"); } -void NRF52Bluetooth::resumeAdverising() +void NRF52Bluetooth::resumeAdvertising() { Bluefruit.Advertising.restartOnDisconnect(true); Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms diff --git a/src/platform/nrf52/NRF52Bluetooth.h b/src/platform/nrf52/NRF52Bluetooth.h index fd27bbf04..11e18c127 100644 --- a/src/platform/nrf52/NRF52Bluetooth.h +++ b/src/platform/nrf52/NRF52Bluetooth.h @@ -8,7 +8,7 @@ class NRF52Bluetooth : BluetoothApi public: void setup(); void shutdown(); - void resumeAdverising(); + void resumeAdvertising(); void clearBonds(); bool isConnected(); int getRssi(); diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index ecffb745d..9cc52a7de 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -80,7 +80,7 @@ void setBluetoothEnable(bool enable) // We delay brownout init until after BLE because BLE starts soft device initBrownout(); } else { - nrf52Bluetooth->resumeAdverising(); + nrf52Bluetooth->resumeAdvertising(); } } } else { From 6fb7d7f2d7980a298d6d2b129a50a022058a76d2 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sun, 5 May 2024 13:49:50 +0200 Subject: [PATCH 078/159] Check if packet is not released before CC to phone --- src/mesh/MeshService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index ddad211a6..2cfb4843c 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -257,7 +257,7 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh LOG_DEBUG("Can't send status to phone"); } - if (ccToPhone) { + if (res == ERRNO_OK && ccToPhone) { // Check if p is not released in case it couldn't be sent sendToPhone(packetPool.allocCopy(*p)); } } From 0b239e618dbb6b0d34c0c0d8cb84bdffa27f9da9 Mon Sep 17 00:00:00 2001 From: caveman99 Date: Sun, 5 May 2024 15:32:28 +0000 Subject: [PATCH 079/159] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index e21899aa6..24776635e 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit e21899aa6b2b49863cfa2758e5e3b6faacf04bba +Subproject commit 24776635eea48316137b206ae8b1ddf1e218c10f diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 68d9b4707..ffc18c30b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -63,6 +63,8 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_NANO_G2_ULTRA = 18, /* LoRAType device: https://loratype.org/ */ meshtastic_HardwareModel_LORA_TYPE = 19, + /* wiphone https://www.wiphone.io/ */ + meshtastic_HardwareModel_WIPHONE = 20, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ meshtastic_HardwareModel_STATION_G1 = 25, /* RAK11310 (RP2040 + SX1262) */ @@ -151,6 +153,9 @@ typedef enum _meshtastic_HardwareModel { /* TWC_MESH_V4 Adafruit NRF52840 feather express with SX1262, SSD1306 OLED and NEO6M GPS */ meshtastic_HardwareModel_TWC_MESH_V4 = 62, + /* NRF52_PROMICRO_DIY + Promicro NRF52840 with SX1262/LLCC68, SSD1306 OLED and NEO6M GPS */ + meshtastic_HardwareModel_NRF52_PROMICRO_DIY = 63, /* ------------------------------------------------------------------------------------------------------------------------------------------ Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. ------------------------------------------------------------------------------------------------------------------------------------------ */ From 2c30923e3e70641b61fdc7795ebacd4583ca2371 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Mon, 6 May 2024 11:25:18 +1200 Subject: [PATCH 080/159] add MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR exclusion to RCWL9620 --- src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp | 9 +++++++-- src/modules/Telemetry/Sensor/RCWL9620Sensor.h | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp index 03df57efd..4f5ddf622 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -1,7 +1,10 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "RCWL9620Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RCWL9620, "RCWL9620") {} @@ -57,4 +60,6 @@ float RCWL9620Sensor::getDistance() } else { return Distance; } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h index b78066f5c..7f9486d25 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.h +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.h @@ -1,3 +1,7 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -20,4 +24,6 @@ class RCWL9620Sensor : public TelemetrySensor RCWL9620Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file From b155a5b6dccf479c1b5edbec8b3221141208588e Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Mon, 6 May 2024 12:15:49 +1200 Subject: [PATCH 081/159] rearrange includes --- src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp index 4f5ddf622..49a509d38 100644 --- a/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp +++ b/src/modules/Telemetry/Sensor/RCWL9620Sensor.cpp @@ -2,8 +2,8 @@ #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -#include "RCWL9620Sensor.h" #include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "RCWL9620Sensor.h" #include "TelemetrySensor.h" RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RCWL9620, "RCWL9620") {} From 5e9d48d0d7ba27f43106f74b15be276941b6b747 Mon Sep 17 00:00:00 2001 From: caveman99 Date: Mon, 6 May 2024 11:37:03 +0000 Subject: [PATCH 082/159] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/telemetry.pb.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/protobufs b/protobufs index 24776635e..1bfe0354d 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 24776635eea48316137b206ae8b1ddf1e218c10f +Subproject commit 1bfe0354d101a6a71ea1354ea158e59193671a0b diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index e670dd340..b6b08f2e7 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -45,7 +45,9 @@ typedef enum _meshtastic_TelemetrySensorType { /* BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280) */ meshtastic_TelemetrySensorType_BMP085 = 15, /* RCWL-9620 Doppler Radar Distance Sensor, used for water level detection */ - meshtastic_TelemetrySensorType_RCWL9620 = 16 + meshtastic_TelemetrySensorType_RCWL9620 = 16, + /* Sensirion High accuracy temperature and humidity */ + meshtastic_TelemetrySensorType_SHT4X = 17 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -152,8 +154,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_RCWL9620 -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_RCWL9620+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SHT4X +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SHT4X+1)) From 77a66e1dce961c01f11f8b6f665ee22c2ca2b204 Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Mon, 6 May 2024 07:47:34 -0400 Subject: [PATCH 083/159] Fix for EnvironmentTelemetry Screen (#3785) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update EnvironmentTelemetry.cpp * Update EnvironmentTelemetry.cpp Corrected lines I deleted by mistake * trunk fmt --------- Co-authored-by: Thomas Göttgens --- .../Telemetry/EnvironmentTelemetry.cpp | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 7ae706b3c..93184069d 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -151,45 +151,53 @@ uint32_t GetTimeSinceMeshPacket(const meshtastic_MeshPacket *mp) void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { display->setTextAlignment(TEXT_ALIGN_LEFT); - display->setFont(FONT_MEDIUM); - display->drawString(x, y, "Environment"); + display->setFont(FONT_SMALL); + if (lastMeasurementPacket == nullptr) { - display->setFont(FONT_SMALL); - display->drawString(x, y += fontHeight(FONT_MEDIUM), "No measurement"); + // If there's no valid packet, display "Environment" + display->drawString(x, y, "Environment"); + display->drawString(x, y += fontHeight(FONT_SMALL), "No measurement"); return; } + // Decode the last measurement packet meshtastic_Telemetry lastMeasurement; - uint32_t agoSecs = GetTimeSinceMeshPacket(lastMeasurementPacket); const char *lastSender = getSenderShortName(*lastMeasurementPacket); auto &p = lastMeasurementPacket->decoded; if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &lastMeasurement)) { - display->setFont(FONT_SMALL); - display->drawString(x, y += fontHeight(FONT_MEDIUM), "Measurement Error"); + display->drawString(x, y, "Measurement Error"); LOG_ERROR("Unable to decode last packet"); return; } - display->setFont(FONT_SMALL); + // Display "Env. From: ..." on its own + display->drawString(x, y, "Env. From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); + String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C"; if (moduleConfig.telemetry.environment_display_fahrenheit) { last_temp = String(CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F"; } - display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); - display->drawString(x, y += fontHeight(FONT_SMALL) - 2, + + // Continue with the remaining details + display->drawString(x, y += fontHeight(FONT_SMALL), "Temp/Hum: " + last_temp + " / " + String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%"); - if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0) + + if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0) { display->drawString(x, y += fontHeight(FONT_SMALL), "Press: " + String(lastMeasurement.variant.environment_metrics.barometric_pressure, 0) + "hPA"); - if (lastMeasurement.variant.environment_metrics.voltage != 0) + } + + if (lastMeasurement.variant.environment_metrics.voltage != 0) { display->drawString(x, y += fontHeight(FONT_SMALL), "Volt/Cur: " + String(lastMeasurement.variant.environment_metrics.voltage, 0) + "V / " + String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); - if (lastMeasurement.variant.environment_metrics.iaq != 0) + } + if (lastMeasurement.variant.environment_metrics.iaq != 0) { display->drawString(x, y += fontHeight(FONT_SMALL), "IAQ: " + String(lastMeasurement.variant.environment_metrics.iaq)); + } if (lastMeasurement.variant.environment_metrics.distance != 0) display->drawString(x, y += fontHeight(FONT_SMALL), "Water Level: " + String(lastMeasurement.variant.environment_metrics.distance, 0) + "mm"); From 353c7e07d16a73a63fde4bfeb8cce8f8875291e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 6 May 2024 13:48:57 +0200 Subject: [PATCH 084/159] Wiphone (#3793) * add wiphone, still WIP * (very preliminary) wiphone support * undo config changes * revert extensions.json * eh? --- boards/wiphone.json | 34 ++++++++++++++++++ src/graphics/TFTDisplay.cpp | 6 ++++ src/platform/esp32/architecture.h | 2 ++ variants/wiphone/pins_arduino.h | 52 +++++++++++++++++++++++++++ variants/wiphone/platformio.ini | 13 +++++++ variants/wiphone/variant.h | 58 +++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+) create mode 100644 boards/wiphone.json create mode 100644 variants/wiphone/pins_arduino.h create mode 100644 variants/wiphone/platformio.ini create mode 100644 variants/wiphone/variant.h diff --git a/boards/wiphone.json b/boards/wiphone.json new file mode 100644 index 000000000..bb01f425f --- /dev/null +++ b/boards/wiphone.json @@ -0,0 +1,34 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld", + "partitions": "default_16MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_WIPHONE14", + "-DBOARD_HAS_PSRAM", + "-mfix-esp32-psram-cache-issue", + "-mfix-esp32-psram-cache-strategy=memw" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "wiphone", + "board": "WiPhone" + }, + "connectivity": ["wifi", "bluetooth"], + "frameworks": ["arduino", "espidf"], + "name": "WIPhone Integrated 1.4", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 532480, + "maximum_size": 6553600, + "maximum_data_size": 4521984, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.wiphone.io/", + "vendor": "HackEDA" +} diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index fac9a5796..36397a826 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -8,6 +8,12 @@ #define TFT_BACKLIGHT_ON HIGH #endif +#ifdef GPIO_EXTENDER +#include +#include +extern SX1509 gpioExtender; +#endif + #ifndef TFT_MESH #define TFT_MESH COLOR565(0x67, 0xEA, 0x94) #endif diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 27088f86f..45d533a76 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -143,6 +143,8 @@ #define HW_VENDOR meshtastic_HardwareModel_STATION_G2 #elif defined(UNPHONE) #define HW_VENDOR meshtastic_HardwareModel_UNPHONE +#elif defined(WIPHONE) +#define HW_VENDOR meshtastic_HardwareModel_WIPHONE #endif // ----------------------------------------------------------------------------- diff --git a/variants/wiphone/pins_arduino.h b/variants/wiphone/pins_arduino.h new file mode 100644 index 000000000..bca9c1173 --- /dev/null +++ b/variants/wiphone/pins_arduino.h @@ -0,0 +1,52 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define EXTERNAL_NUM_INTERRUPTS 16 +#define NUM_DIGITAL_PINS 20 +#define NUM_ANALOG_INPUTS 16 + +#define analogInputToDigitalPin(p) (((p) < 20) ? (esp32_adc2gpio[(p)]) : -1) +#define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 34) + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +static const uint8_t G23 = 23; +static const uint8_t G19 = 19; +static const uint8_t G18 = 18; +static const uint8_t G3 = 3; +static const uint8_t G16 = 16; +static const uint8_t G21 = 21; +static const uint8_t G2 = 2; +static const uint8_t G12 = 12; +static const uint8_t G15 = 15; +static const uint8_t G35 = 35; +static const uint8_t G36 = 36; +static const uint8_t G25 = 25; +static const uint8_t G26 = 26; +static const uint8_t G1 = 1; +static const uint8_t G17 = 17; +static const uint8_t G22 = 22; +static const uint8_t G5 = 5; +static const uint8_t G13 = 13; +static const uint8_t G0 = 0; +static const uint8_t G34 = 34; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ diff --git a/variants/wiphone/platformio.ini b/variants/wiphone/platformio.ini new file mode 100644 index 000000000..10c0de55e --- /dev/null +++ b/variants/wiphone/platformio.ini @@ -0,0 +1,13 @@ +[env:wiphone] +extends = esp32_base +board = wiphone +monitor_filters = esp32_exception_decoder +board_build.partitions = default_16MB.csv +build_flags = + ${esp32_base.build_flags} -D WIPHONE -I variants/wiphone +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 diff --git a/variants/wiphone/variant.h b/variants/wiphone/variant.h new file mode 100644 index 000000000..b2b3ade78 --- /dev/null +++ b/variants/wiphone/variant.h @@ -0,0 +1,58 @@ +#define I2C_SDA 15 +#define I2C_SCL 25 + +#define GPIO_EXTENDER 1509 +#define EXTENDER_FLAG 0x40 +#define EXTENDER_PIN(x) (x + EXTENDER_FLAG) + +#undef RF95_SCK +#undef RF95_MISO +#undef RF95_MOSI +#undef RF95_NSS + +#define RF95_SCK 14 +#define RF95_MISO 12 +#define RF95_MOSI 13 +#define RF95_NSS 27 + +#define USE_RF95 +#define LORA_DIO0 38 +#define LORA_RESET RADIOLIB_NC +#define LORA_DIO1 RADIOLIB_NC +#define LORA_DIO2 RADIOLIB_NC + +// This board has no GPS or Screen for now +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define NO_GPS +#define HAS_GPS 0 +#define NO_SCREEN +#define HAS_SCREEN 0 + +// Default SPI1 will be mapped to the display +#define ST7789_SDA 23 +#define ST7789_SCK 18 +#define ST7789_CS 5 +#define ST7789_RS 26 +#define ST7789_BL -1 // EXTENDER_PIN(9) + +#define ST7789_RESET -1 +#define ST7789_MISO 19 +#define ST7789_BUSY -1 +#define ST7789_SPI_HOST SPI3_HOST +#define ST7789_BACKLIGHT_EN -1 // EXTENDER_PIN(9) +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 16000000 +#define TFT_HEIGHT 240 +#define TFT_WIDTH 320 +#define TFT_OFFSET_X 0 +#define TFT_OFFSET_Y 0 +#define TFT_OFFSET_ROTATION 0 +#define SCREEN_ROTATE +#define SCREEN_TRANSITION_FRAMERATE 5 + +#define I2S_MCLK_GPIO0 +#define I2S_BCK_PIN 4 // rev1.3 - 4 (wp05) +#define I2S_WS_PIN 33 +#define I2S_MOSI_PIN 21 +#define I2S_MISO_PIN 34 \ No newline at end of file From 0d57d29cbdba8d0f22646b29daeb76d7619cae92 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 6 May 2024 14:51:19 -0500 Subject: [PATCH 085/159] Send fixed position to mesh after setting it (#3803) --- src/modules/AdminModule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 37e798b3c..adf5620ba 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -221,6 +221,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta nodeDB->setLocalPosition(r->set_fixed_position); config.position.fixed_position = true; saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); + // Send our new fixed position to the mesh for good measure + positionModule->sendOurPosition(); #if !MESHTASTIC_EXCLUDE_GPS if (gps != nullptr) gps->enable(); From 2c99f11073c3b7d6f150d4fbb955580dae7e4619 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 6 May 2024 17:35:38 -0500 Subject: [PATCH 086/159] Revert "set USB_CDC_ON_BOOT, udate arduinoespressif32 to 2.0.15 (#3764)" (#3809) This reverts commit 71400103b3e9f981cc1ac7f3dff4c24b663a93ab. --- boards/tbeam-s3-core.json | 1 - variants/tbeam-s3-core/platformio.ini | 2 -- 2 files changed, 3 deletions(-) diff --git a/boards/tbeam-s3-core.json b/boards/tbeam-s3-core.json index 8d2c3eed6..4c82a2789 100644 --- a/boards/tbeam-s3-core.json +++ b/boards/tbeam-s3-core.json @@ -7,7 +7,6 @@ "extra_flags": [ "-DBOARD_HAS_PSRAM", "-DLILYGO_TBEAM_S3_CORE", - "-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index 926f15a39..99d315a69 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -3,8 +3,6 @@ extends = esp32s3_base board = tbeam-s3-core -platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.15 - lib_deps = ${esp32s3_base.lib_deps} lewisxhe/PCF8563_Library@1.0.1 From c009c0db1e7f79f5599c173961e1cddcbc05cc80 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 6 May 2024 20:56:59 -0500 Subject: [PATCH 087/159] Elimate non-text output for Portduino --- src/SerialConsole.cpp | 2 ++ src/main.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index 88a336ecc..53ece0fa3 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -51,7 +51,9 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port), con } } #endif +#if !ARCH_PORTDUINO emitRebooted(); +#endif } int32_t SerialConsole::runOnce() diff --git a/src/main.cpp b/src/main.cpp index a6c1dd9fb..b7bc4892b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -344,7 +344,7 @@ void setup() Wire.begin(I2C_SDA, I2C_SCL); #elif defined(ARCH_PORTDUINO) if (settingsStrings[i2cdev] != "") { - LOG_INFO("Using %s as I2C device.\n", settingsStrings[i2cdev]); + LOG_INFO("Using %s as I2C device.\n", settingsStrings[i2cdev].c_str()); Wire.begin(settingsStrings[i2cdev].c_str()); } else { LOG_INFO("No I2C device configured, skipping.\n"); From 76adcbb46ba2c8c57158db37a73a6d75bb4511be Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 11:57:49 +0800 Subject: [PATCH 088/159] 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 089/159] 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 090/159] 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 cbf20e4cee8f8d58eac2a6bfd7f43f8c52828ecb Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 7 May 2024 07:57:30 -0500 Subject: [PATCH 091/159] Default to new vendor ntp pool (#3819) --- 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 b693a8a2b..8cbeb8dd4 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -269,7 +269,7 @@ void NodeDB::installDefaultConfig() config.device.node_info_broadcast_secs = default_node_info_broadcast_secs; config.device.serial_enabled = true; resetRadioConfig(); - strncpy(config.network.ntp_server, "0.pool.ntp.org", 32); + strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32); // FIXME: Default to bluetooth capability of platform as default config.bluetooth.enabled = true; config.bluetooth.fixed_pin = defaultBLEPin; From 8886d2df551fd66dfe7886114f82000353ed1e47 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Tue, 7 May 2024 11:57:49 +0800 Subject: [PATCH 092/159] 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 093/159] 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 094/159] 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 f19aa49eb230fbac41192201210c79597861be4d Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Tue, 7 May 2024 16:11:41 -0400 Subject: [PATCH 095/159] add veml7700 --- platformio.ini | 5 +-- .../Telemetry/Sensor/VEML7700Sensor.cpp | 34 +++++++++++++++++++ src/modules/Telemetry/Sensor/VEML7700Sensor.h | 17 ++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/VEML7700Sensor.cpp create mode 100644 src/modules/Telemetry/Sensor/VEML7700Sensor.h diff --git a/platformio.ini b/platformio.ini index a1082a84a..d03f3243d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -80,7 +80,7 @@ lib_deps = https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 https://github.com/meshtastic/TinyGPSPlus.git#964f75a72cccd6b53cd74e4add1f7a42c6f7344d https://github.com/meshtastic/ArduinoThread.git#1ae8778c85d0a2a729f989e0b1e7d7c4dc84eef0 - nanopb/Nanopb@^0.4.7 + nanopb/Nanopb@^0.4.8 erriez/ErriezCRC32@^1.0.1 ; Used for the code analysis in PIO Home / Inspect @@ -132,4 +132,5 @@ lib_deps = adafruit/Adafruit MPU6050@^2.2.4 adafruit/Adafruit LIS3DH@^1.2.4 https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 - adafruit/Adafruit LSM6DS@^4.7.2 \ No newline at end of file + adafruit/Adafruit LSM6DS@^4.7.2 + adafruit/Adafruit VEML7700 Library@^2.1.6 \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp new file mode 100644 index 000000000..cfce1c7f1 --- /dev/null +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp @@ -0,0 +1,34 @@ +#include "VEML7700Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" +#include +#include + +VEML7700Sensor::VEML7700Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_VEML7700, "VEML7700") {} + +int32_t VEML7700Sensor::runOnce() +{ + LOG_INFO("Init sensor: %s\n", sensorName); + if (!hasSensor()) { + return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; + } + status = veml7700.begin(nodeTelemetrySensorsMap[sensorType].second); + + veml7700.setLowThreshold(10000); + veml7700.setHighThreshold(20000); + veml7700.interruptEnable(true); + + return initI2CSensor(); +} + +void VEML7700Sensor::setup() {} + +bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement) +{ + LOG_DEBUG("VEML7700Sensor::getMetrics\n"); + + measurement->variant.environment_metrics.lux = veml7700.readLux(VEML_LUX_AUTO); + + return true; +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.h b/src/modules/Telemetry/Sensor/VEML7700Sensor.h new file mode 100644 index 000000000..fac602672 --- /dev/null +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.h @@ -0,0 +1,17 @@ +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +class VEML7700Sensor : public TelemetrySensor +{ + private: + Adafruit_VEML7700 veml7700; + + protected: + virtual void setup() override; + + public: + VEML7700Sensor(); + virtual int32_t runOnce() override; + virtual bool getMetrics(meshtastic_Telemetry *measurement) override; +}; \ No newline at end of file From 23466b5a5fb2cc646350d26443f9ec996ecb1d0c Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Tue, 7 May 2024 18:07:24 -0400 Subject: [PATCH 096/159] regenerated files --- src/mesh/generated/meshtastic/apponly.pb.h | 2 +- src/mesh/generated/meshtastic/channel.pb.h | 17 +++++++++------ src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 8 +++++++ src/mesh/generated/meshtastic/telemetry.pb.h | 21 ++++++++++++------- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/mesh/generated/meshtastic/apponly.pb.h b/src/mesh/generated/meshtastic/apponly.pb.h index 54629f522..ba9f90873 100644 --- a/src/mesh/generated/meshtastic/apponly.pb.h +++ b/src/mesh/generated/meshtastic/apponly.pb.h @@ -55,7 +55,7 @@ extern const pb_msgdesc_t meshtastic_ChannelSet_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_APPONLY_PB_H_MAX_SIZE meshtastic_ChannelSet_size -#define meshtastic_ChannelSet_size 658 +#define meshtastic_ChannelSet_size 674 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/channel.pb.h b/src/mesh/generated/meshtastic/channel.pb.h index 185a47a98..d9c7d4ffa 100644 --- a/src/mesh/generated/meshtastic/channel.pb.h +++ b/src/mesh/generated/meshtastic/channel.pb.h @@ -34,6 +34,9 @@ typedef enum _meshtastic_Channel_Role { typedef struct _meshtastic_ModuleSettings { /* Bits of precision for the location sent in position packets. */ uint32_t position_precision; + /* Controls whether or not the phone / clients should mute the current channel + Useful for noisy public channels you don't necessarily want to disable */ + bool is_client_muted; } meshtastic_ModuleSettings; typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t; @@ -126,14 +129,15 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_default} -#define meshtastic_ModuleSettings_init_default {0} +#define meshtastic_ModuleSettings_init_default {0, 0} #define meshtastic_Channel_init_default {0, false, meshtastic_ChannelSettings_init_default, _meshtastic_Channel_Role_MIN} #define meshtastic_ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_zero} -#define meshtastic_ModuleSettings_init_zero {0} +#define meshtastic_ModuleSettings_init_zero {0, 0} #define meshtastic_Channel_init_zero {0, false, meshtastic_ChannelSettings_init_zero, _meshtastic_Channel_Role_MIN} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_ModuleSettings_position_precision_tag 1 +#define meshtastic_ModuleSettings_is_client_muted_tag 2 #define meshtastic_ChannelSettings_channel_num_tag 1 #define meshtastic_ChannelSettings_psk_tag 2 #define meshtastic_ChannelSettings_name_tag 3 @@ -159,7 +163,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, module_settings, 7) #define meshtastic_ChannelSettings_module_settings_MSGTYPE meshtastic_ModuleSettings #define meshtastic_ModuleSettings_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, position_precision, 1) +X(a, STATIC, SINGULAR, UINT32, position_precision, 1) \ +X(a, STATIC, SINGULAR, BOOL, is_client_muted, 2) #define meshtastic_ModuleSettings_CALLBACK NULL #define meshtastic_ModuleSettings_DEFAULT NULL @@ -182,9 +187,9 @@ extern const pb_msgdesc_t meshtastic_Channel_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_MAX_SIZE meshtastic_Channel_size -#define meshtastic_ChannelSettings_size 70 -#define meshtastic_Channel_size 85 -#define meshtastic_ModuleSettings_size 6 +#define meshtastic_ChannelSettings_size 72 +#define meshtastic_Channel_size 87 +#define meshtastic_ModuleSettings_size 8 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index 2506ec647..b8cc80633 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -306,7 +306,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ /* meshtastic_DeviceState_size depends on runtime parameters */ #define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_OEMStore_size -#define meshtastic_ChannelFile_size 702 +#define meshtastic_ChannelFile_size 718 #define meshtastic_NodeInfoLite_size 166 #define meshtastic_OEMStore_size 3346 #define meshtastic_PositionLite_size 28 diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 67b2edd15..ffc18c30b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -63,6 +63,8 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_NANO_G2_ULTRA = 18, /* LoRAType device: https://loratype.org/ */ meshtastic_HardwareModel_LORA_TYPE = 19, + /* wiphone https://www.wiphone.io/ */ + meshtastic_HardwareModel_WIPHONE = 20, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ meshtastic_HardwareModel_STATION_G1 = 25, /* RAK11310 (RP2040 + SX1262) */ @@ -148,6 +150,12 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_TD_LORAC = 60, /* CDEBYTE EoRa-S3 board using their own MM modules, clone of LILYGO T3S3 */ meshtastic_HardwareModel_CDEBYTE_EORA_S3 = 61, + /* TWC_MESH_V4 + Adafruit NRF52840 feather express with SX1262, SSD1306 OLED and NEO6M GPS */ + meshtastic_HardwareModel_TWC_MESH_V4 = 62, + /* NRF52_PROMICRO_DIY + Promicro NRF52840 with SX1262/LLCC68, SSD1306 OLED and NEO6M GPS */ + meshtastic_HardwareModel_NRF52_PROMICRO_DIY = 63, /* ------------------------------------------------------------------------------------------------------------------------------------------ Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. ------------------------------------------------------------------------------------------------------------------------------------------ */ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index e670dd340..d4efad85d 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -45,7 +45,11 @@ typedef enum _meshtastic_TelemetrySensorType { /* BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280) */ meshtastic_TelemetrySensorType_BMP085 = 15, /* RCWL-9620 Doppler Radar Distance Sensor, used for water level detection */ - meshtastic_TelemetrySensorType_RCWL9620 = 16 + meshtastic_TelemetrySensorType_RCWL9620 = 16, + /* Sensirion High accuracy temperature and humidity */ + meshtastic_TelemetrySensorType_SHT4X = 17, + /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ + meshtastic_TelemetrySensorType_VEML7700 = 18 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -82,6 +86,7 @@ typedef struct _meshtastic_EnvironmentMetrics { uint16_t iaq; /* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */ float distance; + float lux; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -152,8 +157,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_RCWL9620 -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_RCWL9620+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_VEML7700 +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_VEML7700+1)) @@ -163,12 +168,12 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -187,6 +192,7 @@ extern "C" { #define meshtastic_EnvironmentMetrics_current_tag 6 #define meshtastic_EnvironmentMetrics_iaq_tag 7 #define meshtastic_EnvironmentMetrics_distance_tag 8 +#define meshtastic_EnvironmentMetrics_lux_tag 9 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -229,7 +235,8 @@ X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \ X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ X(a, STATIC, SINGULAR, FLOAT, current, 6) \ X(a, STATIC, SINGULAR, UINT32, iaq, 7) \ -X(a, STATIC, SINGULAR, FLOAT, distance, 8) +X(a, STATIC, SINGULAR, FLOAT, distance, 8) \ +X(a, STATIC, SINGULAR, FLOAT, lux, 9) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -289,7 +296,7 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 39 +#define meshtastic_EnvironmentMetrics_size 44 #define meshtastic_PowerMetrics_size 30 #define meshtastic_Telemetry_size 79 From 73ab43c67a2a5aafbdf49eae951ffaf500a74c38 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Wed, 8 May 2024 08:45:24 +0800 Subject: [PATCH 097/159] 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 098/159] 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 099/159] 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 100/159] 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 101/159] 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 102/159] 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 103/159] 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 39336847adf18cfe1557bc5bbf2f1b46c456917d Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Wed, 8 May 2024 22:14:55 -0400 Subject: [PATCH 104/159] add veml7700 readings to protobuf and to the mqtt json + fix the readigns validator code in env telemetry --- src/configuration.h | 1 + src/detect/ScanI2C.h | 1 + src/detect/ScanI2CTwoWire.cpp | 1 + src/main.cpp | 3 +- src/mesh/generated/meshtastic/telemetry.pb.h | 17 +++- .../Telemetry/EnvironmentTelemetry.cpp | 88 ++++++++++++------- .../Telemetry/Sensor/VEML7700Sensor.cpp | 5 +- src/mqtt/MQTT.cpp | 4 + 8 files changed, 82 insertions(+), 38 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index 701e07a32..37fda2b9d 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -128,6 +128,7 @@ along with this program. If not, see . #define LPS22HB_ADDR_ALT 0x5D #define SHT31_ADDR 0x44 #define PMSA0031_ADDR 0x12 +#define VEML7700_ADDR 0x10 // ----------------------------------------------------------------------------- // ACCELEROMETER diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..5fad2f30a 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,6 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, + VEML7700, #ifdef HAS_NCP5623 NCP5623, #endif diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index ba2820a77..0b76318ce 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -324,6 +324,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port) SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found\n"); SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found at address 0x%x\n", (uint8_t)addr.address); SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found\n"); + SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700 light sensor found\n"); default: LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address); diff --git a/src/main.cpp b/src/main.cpp index f40fd0789..0a26312eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -538,6 +538,7 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658) 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::VEML7700, meshtastic_TelemetrySensorType_VEML7700) i2cScanner.reset(); @@ -1006,4 +1007,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index d4efad85d..d85855437 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -86,7 +86,12 @@ typedef struct _meshtastic_EnvironmentMetrics { uint16_t iaq; /* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */ float distance; + /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ float lux; + /* VEML7700 raw white light data digital 16-bit resolution sensor. */ + uint32_t white; + /* VEML7700 raw ALS data digital 16-bit resolution sensor. */ + uint32_t ALS; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -168,12 +173,12 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -193,6 +198,8 @@ extern "C" { #define meshtastic_EnvironmentMetrics_iaq_tag 7 #define meshtastic_EnvironmentMetrics_distance_tag 8 #define meshtastic_EnvironmentMetrics_lux_tag 9 +#define meshtastic_EnvironmentMetrics_white_tag 10 +#define meshtastic_EnvironmentMetrics_ALS_tag 11 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -236,7 +243,9 @@ X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ X(a, STATIC, SINGULAR, FLOAT, current, 6) \ X(a, STATIC, SINGULAR, UINT32, iaq, 7) \ X(a, STATIC, SINGULAR, FLOAT, distance, 8) \ -X(a, STATIC, SINGULAR, FLOAT, lux, 9) +X(a, STATIC, SINGULAR, FLOAT, lux, 9) \ +X(a, STATIC, SINGULAR, UINT32, white, 10) \ +X(a, STATIC, SINGULAR, UINT32, ALS, 11) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -296,7 +305,7 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 44 +#define meshtastic_EnvironmentMetrics_size 56 #define meshtastic_PowerMetrics_size 30 #define meshtastic_Telemetry_size 79 diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 189ab7ed0..657d309ba 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -23,6 +23,7 @@ #include "Sensor/MCP9808Sensor.h" #include "Sensor/SHT31Sensor.h" #include "Sensor/SHTC3Sensor.h" +#include "Sensor/VEML7700Sensor.h" BMP085Sensor bmp085Sensor; BMP280Sensor bmp280Sensor; @@ -32,6 +33,7 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; +VEML7700Sensor veml7700Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true @@ -90,6 +92,8 @@ int32_t EnvironmentTelemetryModule::runOnce() result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) result = ina260Sensor.runOnce(); + if (veml7700Sensor.hasSensor()) + result = veml7700Sensor.runOnce(); } return result; } else { @@ -192,10 +196,11 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, " - "temperature=%f, voltage=%f\n", + "temperature=%f, voltage=%f, lux=%f, iaq=%i\n", sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, - t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage); + t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage, + t->variant.environment_metrics.lux, t->variant.environment_metrics.iaq); #endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) @@ -210,44 +215,65 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) { meshtastic_Telemetry m; - bool valid = false; + bool valid = true; + bool hasSensor = false; m.time = getTime(); m.which_variant = meshtastic_Telemetry_environment_metrics_tag; - m.variant.environment_metrics.barometric_pressure = 0; - m.variant.environment_metrics.current = 0; - m.variant.environment_metrics.gas_resistance = 0; - m.variant.environment_metrics.relative_humidity = 0; - m.variant.environment_metrics.temperature = 0; - m.variant.environment_metrics.voltage = 0; - - if (sht31Sensor.hasSensor()) - valid = sht31Sensor.getMetrics(&m); - if (lps22hbSensor.hasSensor()) - valid = lps22hbSensor.getMetrics(&m); - if (shtc3Sensor.hasSensor()) - valid = shtc3Sensor.getMetrics(&m); - if (bmp085Sensor.hasSensor()) - valid = bmp085Sensor.getMetrics(&m); - if (bmp280Sensor.hasSensor()) - valid = bmp280Sensor.getMetrics(&m); - if (bme280Sensor.hasSensor()) - valid = bme280Sensor.getMetrics(&m); - if (bme680Sensor.hasSensor()) - valid = bme680Sensor.getMetrics(&m); - if (mcp9808Sensor.hasSensor()) - valid = mcp9808Sensor.getMetrics(&m); - if (ina219Sensor.hasSensor()) + if (sht31Sensor.hasSensor()) { + valid = valid && sht31Sensor.getMetrics(&m); + hasSensor = true; + } + if (lps22hbSensor.hasSensor()) { + valid = valid && lps22hbSensor.getMetrics(&m); + hasSensor = true; + } + if (shtc3Sensor.hasSensor()) { + valid = valid && shtc3Sensor.getMetrics(&m); + hasSensor = true; + } + if (bmp085Sensor.hasSensor()) { + valid = valid && bmp085Sensor.getMetrics(&m); + hasSensor = true; + } + if (bmp280Sensor.hasSensor()) { + valid = valid && bmp280Sensor.getMetrics(&m); + hasSensor = true; + } + if (bme280Sensor.hasSensor()) { + valid = valid && bme280Sensor.getMetrics(&m); + hasSensor = true; + } + if (bme680Sensor.hasSensor()) { + valid = valid && bme680Sensor.getMetrics(&m); + hasSensor = true; + } + if (mcp9808Sensor.hasSensor()) { + valid = valid && mcp9808Sensor.getMetrics(&m); + hasSensor = true; + } + if (ina219Sensor.hasSensor()) { valid = ina219Sensor.getMetrics(&m); - if (ina260Sensor.hasSensor()) - valid = ina260Sensor.getMetrics(&m); + hasSensor = true; + } + if (ina260Sensor.hasSensor()) { + valid = valid && ina260Sensor.getMetrics(&m); + hasSensor = true; + } + if (veml7700Sensor.hasSensor()) { + valid = valid && veml7700Sensor.getMetrics(&m); + hasSensor = true; + } + + valid = valid && hasSensor; if (valid) { LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, " - "voltage=%f\n", + "voltage=%f, lux=%f, iaq=%i\n", m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, - m.variant.environment_metrics.temperature, m.variant.environment_metrics.voltage); + m.variant.environment_metrics.temperature, m.variant.environment_metrics.voltage, + m.variant.environment_metrics.lux, m.variant.environment_metrics.iaq); sensor_read_error_count = 0; diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp index cfce1c7f1..5e1376849 100644 --- a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp @@ -26,9 +26,10 @@ void VEML7700Sensor::setup() {} bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement) { - LOG_DEBUG("VEML7700Sensor::getMetrics\n"); - measurement->variant.environment_metrics.lux = veml7700.readLux(VEML_LUX_AUTO); + measurement->variant.environment_metrics.white = veml7700.readWhite(); + measurement->variant.environment_metrics.ALS = veml7700.readALS(); + return true; } \ No newline at end of file diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index da1c204b8..59f1002fc 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -664,6 +664,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) msgPayload["gas_resistance"] = new JSONValue(decoded->variant.environment_metrics.gas_resistance); msgPayload["voltage"] = new JSONValue(decoded->variant.environment_metrics.voltage); msgPayload["current"] = new JSONValue(decoded->variant.environment_metrics.current); + msgPayload["lux"] = new JSONValue(decoded->variant.environment_metrics.lux); + msgPayload["white"] = new JSONValue((uint)decoded->variant.environment_metrics.white); + msgPayload["ALS"] = new JSONValue((uint)decoded->variant.environment_metrics.ALS); + msgPayload["iaq"] = new JSONValue((uint)decoded->variant.environment_metrics.iaq); } else if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) { msgPayload["voltage_ch1"] = new JSONValue(decoded->variant.power_metrics.ch1_voltage); msgPayload["current_ch1"] = new JSONValue(decoded->variant.power_metrics.ch1_current); From 5e160b21c78927dd36134a4c6d5f7b08a0603565 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 10 May 2024 01:14:58 +1200 Subject: [PATCH 105/159] 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 106/159] 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 107/159] 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 108/159] 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 109/159] 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 110/159] 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 111/159] [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 112/159] .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 113/159] 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 114/159] 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 115/159] 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 116/159] 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 117/159] 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 118/159] 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 119/159] 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 120/159] 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 121/159] 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 122/159] 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 123/159] 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 124/159] 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 125/159] 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 126/159] 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; From 77e76bc92b8a7ea0816eea23f39b6e59a1e035d0 Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Tue, 14 May 2024 16:42:23 -0400 Subject: [PATCH 127/159] Fix VEML7700Sensor readings and update protobuf and MQTT JSON --- src/mesh/generated/meshtastic/telemetry.pb.h | 18 +++++------ .../Telemetry/Sensor/VEML7700Sensor.cpp | 31 +++++++++++++++++-- src/modules/Telemetry/Sensor/VEML7700Sensor.h | 5 +++ src/mqtt/MQTT.cpp | 3 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index d85855437..fb1a84c44 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -88,10 +88,8 @@ typedef struct _meshtastic_EnvironmentMetrics { float distance; /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ float lux; - /* VEML7700 raw white light data digital 16-bit resolution sensor. */ - uint32_t white; - /* VEML7700 raw ALS data digital 16-bit resolution sensor. */ - uint32_t ALS; + /* VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. */ + float white_lux; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -173,12 +171,12 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -198,8 +196,7 @@ extern "C" { #define meshtastic_EnvironmentMetrics_iaq_tag 7 #define meshtastic_EnvironmentMetrics_distance_tag 8 #define meshtastic_EnvironmentMetrics_lux_tag 9 -#define meshtastic_EnvironmentMetrics_white_tag 10 -#define meshtastic_EnvironmentMetrics_ALS_tag 11 +#define meshtastic_EnvironmentMetrics_white_lux_tag 10 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -244,8 +241,7 @@ X(a, STATIC, SINGULAR, FLOAT, current, 6) \ X(a, STATIC, SINGULAR, UINT32, iaq, 7) \ X(a, STATIC, SINGULAR, FLOAT, distance, 8) \ X(a, STATIC, SINGULAR, FLOAT, lux, 9) \ -X(a, STATIC, SINGULAR, UINT32, white, 10) \ -X(a, STATIC, SINGULAR, UINT32, ALS, 11) +X(a, STATIC, SINGULAR, FLOAT, white_lux, 10) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -305,7 +301,7 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 56 +#define meshtastic_EnvironmentMetrics_size 49 #define meshtastic_PowerMetrics_size 30 #define meshtastic_Telemetry_size 79 diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp index 5e1376849..1870cb3f9 100644 --- a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp @@ -24,11 +24,38 @@ int32_t VEML7700Sensor::runOnce() void VEML7700Sensor::setup() {} +/*! + * @brief Copmute lux from ALS reading. + * @param rawALS raw ALS register value + * @param corrected if true, apply non-linear correction + * @return lux value + */ +float VEML7700Sensor::computeLux(uint16_t rawALS, bool corrected) { + float lux = getResolution() * rawALS; + if (corrected) + lux = (((6.0135e-13 * lux - 9.3924e-9) * lux + 8.1488e-5) * lux + 1.0023) * + lux; + return lux; +} + +/*! + * @brief Determines resolution for current gain and integration time + * settings. + */ +float VEML7700Sensor::getResolution(void) { + return MAX_RES * (IT_MAX / veml7700.getIntegrationTimeValue()) * + (GAIN_MAX / veml7700.getGainValue()); +} + bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement) { + int16_t white; measurement->variant.environment_metrics.lux = veml7700.readLux(VEML_LUX_AUTO); - measurement->variant.environment_metrics.white = veml7700.readWhite(); - measurement->variant.environment_metrics.ALS = veml7700.readALS(); + white = veml7700.readWhite(true); + measurement->variant.environment_metrics.white_lux = computeLux(white, white > 100); + LOG_INFO("white lux %f, als lux %f\n", + measurement->variant.environment_metrics.white_lux, + measurement->variant.environment_metrics.lux); return true; diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.h b/src/modules/Telemetry/Sensor/VEML7700Sensor.h index fac602672..9c7a584d9 100644 --- a/src/modules/Telemetry/Sensor/VEML7700Sensor.h +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.h @@ -5,7 +5,12 @@ class VEML7700Sensor : public TelemetrySensor { private: + const float MAX_RES = 0.0036; + const float GAIN_MAX = 2; + const float IT_MAX = 800; Adafruit_VEML7700 veml7700; + float computeLux(uint16_t rawALS, bool corrected); + float getResolution(void); protected: virtual void setup() override; diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 59f1002fc..e91eade35 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -665,8 +665,7 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) msgPayload["voltage"] = new JSONValue(decoded->variant.environment_metrics.voltage); msgPayload["current"] = new JSONValue(decoded->variant.environment_metrics.current); msgPayload["lux"] = new JSONValue(decoded->variant.environment_metrics.lux); - msgPayload["white"] = new JSONValue((uint)decoded->variant.environment_metrics.white); - msgPayload["ALS"] = new JSONValue((uint)decoded->variant.environment_metrics.ALS); + msgPayload["white_lux"] = new JSONValue(decoded->variant.environment_metrics.white_lux); msgPayload["iaq"] = new JSONValue((uint)decoded->variant.environment_metrics.iaq); } else if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) { msgPayload["voltage_ch1"] = new JSONValue(decoded->variant.power_metrics.ch1_voltage); From 022e1f472d2690e68bc3a8246070acdee128d8b9 Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Tue, 14 May 2024 17:00:33 -0400 Subject: [PATCH 128/159] Updated protobufs submodule --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index eade2c6be..71f3d68db 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit eade2c6befb65a9c46c5d28ae1e8e24c37a1a3d0 +Subproject commit 71f3d68db56fb335c78211443b6cff3d661adb03 From 0aa449bca943528e2fc00f9ddeeaf4631334b011 Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Tue, 14 May 2024 18:47:20 -0400 Subject: [PATCH 129/159] Fix unnecessary code block removal in EnvironmentTelemetryModule --- src/modules/Telemetry/EnvironmentTelemetry.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 53a415af5..77d292849 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -220,8 +220,6 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac t->variant.environment_metrics.temperature, t->variant.environment_metrics.lux); LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f\n", sender, t->variant.environment_metrics.voltage, t->variant.environment_metrics.iaq, t->variant.environment_metrics.distance); - -#endif #endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) From 49a9aa3e36f4010fbe71d451046efcdce9f4ea5e Mon Sep 17 00:00:00 2001 From: mverch67 Date: Wed, 15 May 2024 08:10:52 +0200 Subject: [PATCH 130/159] fix native compilation for linux PCs --- src/platform/portduino/PortduinoGlue.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 4077a27bc..89ac806dd 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -283,7 +283,7 @@ void portduinoSetup() } for (configNames i : GPIO_lines) { - if (settingsMap[i] > max_GPIO) + if (settingsMap.count(i) && settingsMap[i] > max_GPIO) max_GPIO = settingsMap[i]; } @@ -342,6 +342,7 @@ void portduinoSetup() if (settingsMap[touchscreenIRQ] > 0) initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName); } + if (settingsStrings[spidev] != "") { SPI.begin(settingsStrings[spidev].c_str()); } @@ -350,6 +351,7 @@ void portduinoSetup() int initGPIOPin(int pinNum, const std::string gpioChipName) { +#ifdef PORTDUINO_LINUX_HARDWARE std::string gpio_name = "GPIO" + std::to_string(pinNum); try { GPIOPin *csPin; @@ -362,4 +364,7 @@ int initGPIOPin(int pinNum, const std::string gpioChipName) std::cout << "Warning, cannot claim pin " << gpio_name << (p ? p.__cxa_exception_type()->name() : "null") << std::endl; return ERRNO_DISABLED; } +#else + return ERRNO_OK; +#endif } \ No newline at end of file From 78a1b6a9a827462b5486844f5ccd57ba0408db40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 15 May 2024 09:59:46 +0200 Subject: [PATCH 131/159] unrelated change, i just noticed this problem... --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 5641e1f63..ff704c931 100644 --- a/platformio.ini +++ b/platformio.ini @@ -134,5 +134,5 @@ lib_deps = adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 adafruit/Adafruit VEML7700 Library@^2.1.6 - https://github.com/adafruit/Adafruit_SHT4X#1.0.4 + adafruit/Adafruit SHT4x Library@^1.0.4 From 33812a208283aa192a85c5e3e98054b1c2de1c2d Mon Sep 17 00:00:00 2001 From: mverch67 Date: Wed, 15 May 2024 11:18:39 +0200 Subject: [PATCH 132/159] update portduino-framework --- arch/portduino/portduino.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 63f5576b6..be374df32 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based sim environment on top of any host OS, all hardware will be simulated [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#9881bf3721d610cccacf5ae8e3a07839cce75d63 +platform = https://github.com/meshtastic/platform-native.git#f5ec3c031b0fcd89c0523de9e43eef3a92d59292 framework = arduino build_src_filter = From 64dc6cc215a24707b7cd68770a1a589eddfe06e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 15 May 2024 12:24:42 +0200 Subject: [PATCH 133/159] trunk fmt --- src/main.cpp | 1 - .../Telemetry/EnvironmentTelemetry.cpp | 25 +++++++++---------- .../Telemetry/Sensor/VEML7700Sensor.cpp | 24 ++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 03c116ede..f14d08188 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -544,7 +544,6 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) - i2cScanner.reset(); #ifdef HAS_SDCARD diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index e35c2a51a..d0a9890dd 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -246,54 +246,53 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) if (sht31Sensor.hasSensor()) { valid = valid && sht31Sensor.getMetrics(&m); hasSensor = true; - } + } if (lps22hbSensor.hasSensor()) { valid = valid && lps22hbSensor.getMetrics(&m); hasSensor = true; - } + } if (shtc3Sensor.hasSensor()) { valid = valid && shtc3Sensor.getMetrics(&m); hasSensor = true; - } + } if (bmp085Sensor.hasSensor()) { valid = valid && bmp085Sensor.getMetrics(&m); hasSensor = true; - } + } if (bmp280Sensor.hasSensor()) { valid = valid && bmp280Sensor.getMetrics(&m); hasSensor = true; - } + } if (bme280Sensor.hasSensor()) { valid = valid && bme280Sensor.getMetrics(&m); hasSensor = true; - } + } if (bme680Sensor.hasSensor()) { valid = valid && bme680Sensor.getMetrics(&m); hasSensor = true; - } + } if (mcp9808Sensor.hasSensor()) { valid = valid && mcp9808Sensor.getMetrics(&m); hasSensor = true; - } + } if (ina219Sensor.hasSensor()) { valid = valid && ina219Sensor.getMetrics(&m); hasSensor = true; - } + } if (ina260Sensor.hasSensor()) { valid = valid && ina260Sensor.getMetrics(&m); hasSensor = true; - } + } if (veml7700Sensor.hasSensor()) { valid = valid && veml7700Sensor.getMetrics(&m); hasSensor = true; - } - if (rcwl9620Sensor.hasSensor()){ + } + if (rcwl9620Sensor.hasSensor()) { valid = valid && rcwl9620Sensor.getMetrics(&m); hasSensor = true; } valid = valid && hasSensor; - if (valid) { LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, " "lux=%f\n", diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp index 1870cb3f9..1abe8339f 100644 --- a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp @@ -30,21 +30,21 @@ void VEML7700Sensor::setup() {} * @param corrected if true, apply non-linear correction * @return lux value */ -float VEML7700Sensor::computeLux(uint16_t rawALS, bool corrected) { - float lux = getResolution() * rawALS; - if (corrected) - lux = (((6.0135e-13 * lux - 9.3924e-9) * lux + 8.1488e-5) * lux + 1.0023) * - lux; - return lux; +float VEML7700Sensor::computeLux(uint16_t rawALS, bool corrected) +{ + float lux = getResolution() * rawALS; + if (corrected) + lux = (((6.0135e-13 * lux - 9.3924e-9) * lux + 8.1488e-5) * lux + 1.0023) * lux; + return lux; } /*! * @brief Determines resolution for current gain and integration time * settings. */ -float VEML7700Sensor::getResolution(void) { - return MAX_RES * (IT_MAX / veml7700.getIntegrationTimeValue()) * - (GAIN_MAX / veml7700.getGainValue()); +float VEML7700Sensor::getResolution(void) +{ + return MAX_RES * (IT_MAX / veml7700.getIntegrationTimeValue()) * (GAIN_MAX / veml7700.getGainValue()); } bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement) @@ -53,10 +53,8 @@ bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.lux = veml7700.readLux(VEML_LUX_AUTO); white = veml7700.readWhite(true); measurement->variant.environment_metrics.white_lux = computeLux(white, white > 100); - LOG_INFO("white lux %f, als lux %f\n", - measurement->variant.environment_metrics.white_lux, - measurement->variant.environment_metrics.lux); - + LOG_INFO("white lux %f, als lux %f\n", measurement->variant.environment_metrics.white_lux, + measurement->variant.environment_metrics.lux); return true; } \ No newline at end of file From 419820f4836d4b26a38180c39e59fb100722133e Mon Sep 17 00:00:00 2001 From: caveman99 <25002+caveman99@users.noreply.github.com> Date: Wed, 15 May 2024 12:47:31 +0000 Subject: [PATCH 134/159] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/telemetry.pb.h | 32 +++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/protobufs b/protobufs index 1bfe0354d..bee9ddc71 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1bfe0354d101a6a71ea1354ea158e59193671a0b +Subproject commit bee9ddc71677e974568a5a95362d78acac6bb974 diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index b6b08f2e7..7748dd6b3 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -47,7 +47,17 @@ typedef enum _meshtastic_TelemetrySensorType { /* RCWL-9620 Doppler Radar Distance Sensor, used for water level detection */ meshtastic_TelemetrySensorType_RCWL9620 = 16, /* Sensirion High accuracy temperature and humidity */ - meshtastic_TelemetrySensorType_SHT4X = 17 + meshtastic_TelemetrySensorType_SHT4X = 17, + /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ + meshtastic_TelemetrySensorType_VEML7700 = 18, + /* MLX90632 non-contact IR temperature sensor. */ + meshtastic_TelemetrySensorType_MLX90632 = 19, + /* TI OPT3001 Ambient Light Sensor */ + meshtastic_TelemetrySensorType_OPT3001 = 20, + /* Lite On LTR-390UV-01 UV Light Sensor */ + meshtastic_TelemetrySensorType_LTR390UV = 21, + /* AMS TSL25911FN RGB Light Sensor */ + meshtastic_TelemetrySensorType_TSL25911FN = 22 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -84,6 +94,10 @@ typedef struct _meshtastic_EnvironmentMetrics { uint16_t iaq; /* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */ float distance; + /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ + float lux; + /* VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. */ + float white_lux; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -154,8 +168,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SHT4X -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SHT4X+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_TSL25911FN +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_TSL25911FN+1)) @@ -165,12 +179,12 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -189,6 +203,8 @@ extern "C" { #define meshtastic_EnvironmentMetrics_current_tag 6 #define meshtastic_EnvironmentMetrics_iaq_tag 7 #define meshtastic_EnvironmentMetrics_distance_tag 8 +#define meshtastic_EnvironmentMetrics_lux_tag 9 +#define meshtastic_EnvironmentMetrics_white_lux_tag 10 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -231,7 +247,9 @@ X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \ X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ X(a, STATIC, SINGULAR, FLOAT, current, 6) \ X(a, STATIC, SINGULAR, UINT32, iaq, 7) \ -X(a, STATIC, SINGULAR, FLOAT, distance, 8) +X(a, STATIC, SINGULAR, FLOAT, distance, 8) \ +X(a, STATIC, SINGULAR, FLOAT, lux, 9) \ +X(a, STATIC, SINGULAR, FLOAT, white_lux, 10) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -291,7 +309,7 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 39 +#define meshtastic_EnvironmentMetrics_size 49 #define meshtastic_PowerMetrics_size 30 #define meshtastic_Telemetry_size 79 From bd9156de24196ce99b6bdda8a0c615565c31cea0 Mon Sep 17 00:00:00 2001 From: Ken McGuire Date: Wed, 15 May 2024 11:12:46 -0600 Subject: [PATCH 135/159] GPS Chechsum failures (#3900) * Portduino multiple logging levels * Fixes based on GPSFan work * Fix derped logic * Correct size field for AID message * Reformat to add comments, beginning of GPS rework * Update PM2 message for Neo-6 * Correct ECO mode logic as ECO mode is only for Neo-6 * Cleanup ubx.h add a few more comments * GPS rework, changes for M8 and stub for M10 * Add VALSET commands for u-blox M10 receivers * Add VALSET commands for u-blox M10 receivers tweak M8 commands add comments for VALSET configuration commands * Add commands to init M10 receivers, tweak the M8 init sequence, this is a WIP as there are still some issues during init. Add M10 version of PMREQ. * Add wakeup source of uartrx to PMREQ_10 The M10 does not respond to commands when asleep, may need to do this for the M8 as well * Enable NMEA messages on USB port. Normally, it is a good idea to disable messages on unused ports. Native Linux needs to be able to use GNSS modules connected via via either serial or USB. In the future I2C connections may be required, but are not enabled for now. * Save the config for all u-blox receiver types. The M10 supports this command in addition to saving using the VALSET commands for the RAM & BBR layers. * Address Issue #3779 RAK12500 GPS Checksum failures Remove NMEA sentences that are not processed by TinyGPS++ or Meshtastic. --------- Co-authored-by: Jonathan Bennett Co-authored-by: Ben Meadors --- src/gps/GPS.cpp | 3 +++ src/gps/ubx.h | 31 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index eaae049b5..4335244f0 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -472,6 +472,9 @@ bool GPS::setup() // Turn off GSV messages, we don't really care about which and where the sats are, maybe someday. _serial_gps->write("$CFGMSG,0,3,0\r\n"); delay(250); + // Turn off GSA messages, TinyGPS++ doesn't use this message. + _serial_gps->write("$CFGMSG,0,2,0\r\n"); + delay(250); // Turn off NOTICE __TXT messages, these may provide Unicore some info but we don't care. _serial_gps->write("$CFGMSG,6,0,0\r\n"); delay(250); diff --git a/src/gps/ubx.h b/src/gps/ubx.h index 5b2cb24ce..0a382a8a3 100644 --- a/src/gps/ubx.h +++ b/src/gps/ubx.h @@ -206,14 +206,14 @@ const uint8_t GPS::_message_GLL[] = { 0x00 // Reserved }; -// Enable GSA. GSA - GPS DOP and active satellites, used for detailing the satellites used in the positioning and +// Disable GSA. GSA - GPS DOP and active satellites, used for detailing the satellites used in the positioning and // the DOP (Dilution of Precision) const uint8_t GPS::_message_GSA[] = { 0xF0, 0x02, // NMEA ID for GSA 0x00, // Rate for DDC - 0x01, // Rate for UART1 + 0x00, // Rate for UART1 0x00, // Rate for UART2 - 0x01, // Rate for USB usefull for native linux + 0x00, // Rate for USB usefull for native linux 0x00, // Rate for SPI 0x00 // Reserved }; @@ -402,23 +402,28 @@ const uint8_t GPS::_message_VALSET_DISABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, // BBR layer config message: // b5 62 06 8a 09 00 00 02 00 00 07 00 92 20 06 5a 58 -// Turn NMEA GSA, GGA, RMC messages on: -// Ram layer config message: -// b5 62 06 8a 13 00 00 01 00 00 c0 00 91 20 01 bb 00 91 20 01 ac 00 91 20 01 e1 3b - -// BBR layer config message: -// b5 62 06 8a 13 00 00 02 00 00 c0 00 91 20 01 bb 00 91 20 01 ac 00 91 20 01 e2 4d +// Turn NMEA GGA, RMC messages on: +// Layer config messages: +// RAM: +// b5 62 06 8a 0e 00 00 01 00 00 bb 00 91 20 01 ac 00 91 20 01 6a 8f +// BBR: +// b5 62 06 8a 0e 00 00 02 00 00 bb 00 91 20 01 ac 00 91 20 01 6b 9c +// FLASH: +// b5 62 06 8a 0e 00 00 04 00 00 bb 00 91 20 01 ac 00 91 20 01 6d b6 +// Doing this for the FLASH layer isn't really required since we save the config to flash later const uint8_t GPS::_message_VALSET_DISABLE_TXT_INFO_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x92, 0x20, 0x03}; const uint8_t GPS::_message_VALSET_DISABLE_TXT_INFO_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x07, 0x00, 0x92, 0x20, 0x03}; -const uint8_t GPS::_message_VALSET_ENABLE_NMEA_RAM[] = {0x00, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x91, 0x20, 0x01, 0xbb, - 0x00, 0x91, 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01}; -const uint8_t GPS::_message_VALSET_ENABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, 0xc0, 0x00, 0x91, 0x20, 0x01, 0xbb, - 0x00, 0x91, 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01}; + +const uint8_t GPS::_message_VALSET_ENABLE_NMEA_RAM[] = {0x00, 0x01, 0x00, 0x00, 0xbb, 0x00, 0x91, + 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01}; +const uint8_t GPS::_message_VALSET_ENABLE_NMEA_BBR[] = {0x00, 0x02, 0x00, 0x00, 0xbb, 0x00, 0x91, + 0x20, 0x01, 0xac, 0x00, 0x91, 0x20, 0x01}; const uint8_t GPS::_message_VALSET_DISABLE_SBAS_RAM[] = {0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x31, 0x10, 0x00, 0x05, 0x00, 0x31, 0x10, 0x00}; const uint8_t GPS::_message_VALSET_DISABLE_SBAS_BBR[] = {0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x31, 0x10, 0x00, 0x05, 0x00, 0x31, 0x10, 0x00}; + /* Operational issues with the M10: From 9e8ca69a11ee8ad2b53f16fb2f3eeeba7f76bef6 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Wed, 15 May 2024 22:24:25 +0200 Subject: [PATCH 136/159] bin: remove unused import in buildinfo.py This was originally added in b1c30f06509459e5afc5291de067b1946ae4ddd5 and it now do nothing since 361556a6a7913104c513c8f8029efe090267bb9f because it now use readprops. --- bin/buildinfo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/buildinfo.py b/bin/buildinfo.py index 6b123c9cf..5aecad1bd 100755 --- a/bin/buildinfo.py +++ b/bin/buildinfo.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 -import configparser import sys + from readprops import readProps - -verObj = readProps('version.properties') +verObj = readProps("version.properties") propName = sys.argv[1] print(f"{verObj[propName]}") From e08c808c3fc7e16aab2e12904764bf0aa0c39137 Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Wed, 15 May 2024 17:06:23 -0400 Subject: [PATCH 137/159] fix log line --- src/modules/Telemetry/EnvironmentTelemetry.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index d0a9890dd..a3f63b0aa 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -218,12 +218,12 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, " - "temperature=%f, lux=%f\n", + "temperature=%f\n", sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, - t->variant.environment_metrics.temperature, t->variant.environment_metrics.lux); - LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f\n", sender, t->variant.environment_metrics.voltage, - t->variant.environment_metrics.iaq, t->variant.environment_metrics.distance); + t->variant.environment_metrics.temperature); + LOG_INFO("(Received from %s): voltage=%f, IAQ=%d, distance=%f, lux=%f\n", sender, t->variant.environment_metrics.voltage, + t->variant.environment_metrics.iaq, t->variant.environment_metrics.distance, t->variant.environment_metrics.lux); #endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) @@ -294,13 +294,12 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) valid = valid && hasSensor; if (valid) { - LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, " - "lux=%f\n", + LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f\n", m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, - m.variant.environment_metrics.temperature, m.variant.environment_metrics.lux); - LOG_INFO("(Sending): voltage=%f, IAQ=%d, distance=%f\n", m.variant.environment_metrics.voltage, - m.variant.environment_metrics.iaq, m.variant.environment_metrics.distance); + m.variant.environment_metrics.temperature); + LOG_INFO("(Sending): voltage=%f, IAQ=%d, distance=%f, lux=%f\n", m.variant.environment_metrics.voltage, + m.variant.environment_metrics.iaq, m.variant.environment_metrics.distance, m.variant.environment_metrics.lux); sensor_read_error_count = 0; From ce25381f678e5838a8ca80b74f4ccb5b8311cdb4 Mon Sep 17 00:00:00 2001 From: Jorge Castillo Date: Wed, 15 May 2024 17:13:28 -0400 Subject: [PATCH 138/159] fix unrelated change --- platformio.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index ff704c931..0f2907dee 100644 --- a/platformio.ini +++ b/platformio.ini @@ -134,5 +134,4 @@ lib_deps = adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 adafruit/Adafruit VEML7700 Library@^2.1.6 - adafruit/Adafruit SHT4x Library@^1.0.4 - + https://github.com/adafruit/Adafruit_SHT4X#1.0.4 \ No newline at end of file From eaa7fcf3dcdaa1f4b4a1a814052c509d34b314bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 00:23:03 +0200 Subject: [PATCH 139/159] Revert "Updated protobufs submodule" This reverts commit 022e1f472d2690e68bc3a8246070acdee128d8b9. --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 71f3d68db..eade2c6be 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 71f3d68db56fb335c78211443b6cff3d661adb03 +Subproject commit eade2c6befb65a9c46c5d28ae1e8e24c37a1a3d0 From 79628c73cda35d798b854cc68dec245a82cc5481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 00:23:51 +0200 Subject: [PATCH 140/159] tryfix proto conflict --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index eade2c6be..71f3d68db 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit eade2c6befb65a9c46c5d28ae1e8e24c37a1a3d0 +Subproject commit 71f3d68db56fb335c78211443b6cff3d661adb03 From 6dbc85810209c16a60736da16b52bd42fdb95f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 00:26:01 +0200 Subject: [PATCH 141/159] Revert "tryfix proto conflict" This reverts commit 79628c73cda35d798b854cc68dec245a82cc5481. --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 71f3d68db..eade2c6be 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 71f3d68db56fb335c78211443b6cff3d661adb03 +Subproject commit eade2c6befb65a9c46c5d28ae1e8e24c37a1a3d0 From 3342395a0b783fee59abbb5ef1291985ce5967e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 01:04:38 +0200 Subject: [PATCH 142/159] fix generated files --- src/mesh/generated/meshtastic/telemetry.pb.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index ecb353ff6..f4a79398f 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -49,7 +49,15 @@ typedef enum _meshtastic_TelemetrySensorType { /* Sensirion High accuracy temperature and humidity */ meshtastic_TelemetrySensorType_SHT4X = 17, /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ - meshtastic_TelemetrySensorType_VEML7700 = 18 + meshtastic_TelemetrySensorType_VEML7700 = 18, + /* MLX90632 non-contact IR temperature sensor. */ + meshtastic_TelemetrySensorType_MLX90632 = 19, + /* TI OPT3001 Ambient Light Sensor */ + meshtastic_TelemetrySensorType_OPT3001 = 20, + /* Lite On LTR-390UV-01 UV Light Sensor */ + meshtastic_TelemetrySensorType_LTR390UV = 21, + /* AMS TSL25911FN RGB Light Sensor */ + meshtastic_TelemetrySensorType_TSL25911FN = 22 } meshtastic_TelemetrySensorType; /* Struct definitions */ From 53dea44983bf1a2ee9bec096b2f3cf74167ffe3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 01:08:52 +0200 Subject: [PATCH 143/159] Revert "Merge pull request #3898 from meshtastic/create-pull-request/patch" This reverts commit 938aba481a9faed90aae4ddac636513dc7d594ff, reversing changes made to 7810e59b0c3fe392c75ed6222558d1d12a1dc201. --- protobufs | 2 +- src/mesh/generated/meshtastic/telemetry.pb.h | 32 +++++--------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/protobufs b/protobufs index bee9ddc71..1bfe0354d 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit bee9ddc71677e974568a5a95362d78acac6bb974 +Subproject commit 1bfe0354d101a6a71ea1354ea158e59193671a0b diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index 7748dd6b3..b6b08f2e7 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -47,17 +47,7 @@ typedef enum _meshtastic_TelemetrySensorType { /* RCWL-9620 Doppler Radar Distance Sensor, used for water level detection */ meshtastic_TelemetrySensorType_RCWL9620 = 16, /* Sensirion High accuracy temperature and humidity */ - meshtastic_TelemetrySensorType_SHT4X = 17, - /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ - meshtastic_TelemetrySensorType_VEML7700 = 18, - /* MLX90632 non-contact IR temperature sensor. */ - meshtastic_TelemetrySensorType_MLX90632 = 19, - /* TI OPT3001 Ambient Light Sensor */ - meshtastic_TelemetrySensorType_OPT3001 = 20, - /* Lite On LTR-390UV-01 UV Light Sensor */ - meshtastic_TelemetrySensorType_LTR390UV = 21, - /* AMS TSL25911FN RGB Light Sensor */ - meshtastic_TelemetrySensorType_TSL25911FN = 22 + meshtastic_TelemetrySensorType_SHT4X = 17 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -94,10 +84,6 @@ typedef struct _meshtastic_EnvironmentMetrics { uint16_t iaq; /* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */ float distance; - /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ - float lux; - /* VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. */ - float white_lux; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -168,8 +154,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_TSL25911FN -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_TSL25911FN+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SHT4X +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SHT4X+1)) @@ -179,12 +165,12 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -203,8 +189,6 @@ extern "C" { #define meshtastic_EnvironmentMetrics_current_tag 6 #define meshtastic_EnvironmentMetrics_iaq_tag 7 #define meshtastic_EnvironmentMetrics_distance_tag 8 -#define meshtastic_EnvironmentMetrics_lux_tag 9 -#define meshtastic_EnvironmentMetrics_white_lux_tag 10 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -247,9 +231,7 @@ X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \ X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ X(a, STATIC, SINGULAR, FLOAT, current, 6) \ X(a, STATIC, SINGULAR, UINT32, iaq, 7) \ -X(a, STATIC, SINGULAR, FLOAT, distance, 8) \ -X(a, STATIC, SINGULAR, FLOAT, lux, 9) \ -X(a, STATIC, SINGULAR, FLOAT, white_lux, 10) +X(a, STATIC, SINGULAR, FLOAT, distance, 8) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -309,7 +291,7 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 49 +#define meshtastic_EnvironmentMetrics_size 39 #define meshtastic_PowerMetrics_size 30 #define meshtastic_Telemetry_size 79 From fe2356ae871afd3c8b2c5399e55cd37a423ed5c9 Mon Sep 17 00:00:00 2001 From: caveman99 <25002+caveman99@users.noreply.github.com> Date: Wed, 15 May 2024 23:12:12 +0000 Subject: [PATCH 144/159] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/telemetry.pb.h | 32 +++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/protobufs b/protobufs index 1bfe0354d..bee9ddc71 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1bfe0354d101a6a71ea1354ea158e59193671a0b +Subproject commit bee9ddc71677e974568a5a95362d78acac6bb974 diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index b6b08f2e7..7748dd6b3 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -47,7 +47,17 @@ typedef enum _meshtastic_TelemetrySensorType { /* RCWL-9620 Doppler Radar Distance Sensor, used for water level detection */ meshtastic_TelemetrySensorType_RCWL9620 = 16, /* Sensirion High accuracy temperature and humidity */ - meshtastic_TelemetrySensorType_SHT4X = 17 + meshtastic_TelemetrySensorType_SHT4X = 17, + /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ + meshtastic_TelemetrySensorType_VEML7700 = 18, + /* MLX90632 non-contact IR temperature sensor. */ + meshtastic_TelemetrySensorType_MLX90632 = 19, + /* TI OPT3001 Ambient Light Sensor */ + meshtastic_TelemetrySensorType_OPT3001 = 20, + /* Lite On LTR-390UV-01 UV Light Sensor */ + meshtastic_TelemetrySensorType_LTR390UV = 21, + /* AMS TSL25911FN RGB Light Sensor */ + meshtastic_TelemetrySensorType_TSL25911FN = 22 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -84,6 +94,10 @@ typedef struct _meshtastic_EnvironmentMetrics { uint16_t iaq; /* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */ float distance; + /* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ + float lux; + /* VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. */ + float white_lux; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -154,8 +168,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SHT4X -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SHT4X+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_TSL25911FN +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_TSL25911FN+1)) @@ -165,12 +179,12 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0} -#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0} #define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -189,6 +203,8 @@ extern "C" { #define meshtastic_EnvironmentMetrics_current_tag 6 #define meshtastic_EnvironmentMetrics_iaq_tag 7 #define meshtastic_EnvironmentMetrics_distance_tag 8 +#define meshtastic_EnvironmentMetrics_lux_tag 9 +#define meshtastic_EnvironmentMetrics_white_lux_tag 10 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -231,7 +247,9 @@ X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \ X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ X(a, STATIC, SINGULAR, FLOAT, current, 6) \ X(a, STATIC, SINGULAR, UINT32, iaq, 7) \ -X(a, STATIC, SINGULAR, FLOAT, distance, 8) +X(a, STATIC, SINGULAR, FLOAT, distance, 8) \ +X(a, STATIC, SINGULAR, FLOAT, lux, 9) \ +X(a, STATIC, SINGULAR, FLOAT, white_lux, 10) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -291,7 +309,7 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 39 +#define meshtastic_EnvironmentMetrics_size 49 #define meshtastic_PowerMetrics_size 30 #define meshtastic_Telemetry_size 79 From 0c9eadc507de3790525cbaf895632ff957970a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 01:16:05 +0200 Subject: [PATCH 145/159] Resync --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index eade2c6be..bee9ddc71 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit eade2c6befb65a9c46c5d28ae1e8e24c37a1a3d0 +Subproject commit bee9ddc71677e974568a5a95362d78acac6bb974 From c18b4920aedc9a91d39d477b57cefaa662c246ff Mon Sep 17 00:00:00 2001 From: caveman99 <25002+caveman99@users.noreply.github.com> Date: Wed, 15 May 2024 23:28:03 +0000 Subject: [PATCH 146/159] [create-pull-request] automated change --- src/mesh/generated/meshtastic/telemetry.pb.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index 6c7779710..7748dd6b3 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -168,7 +168,6 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET - #define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_TSL25911FN #define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_TSL25911FN+1)) @@ -178,7 +177,6 @@ extern "C" { - /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0} #define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -319,4 +317,4 @@ extern const pb_msgdesc_t meshtastic_Telemetry_msg; } /* extern "C" */ #endif -#endif \ No newline at end of file +#endif From 1d42a6c48fb471329feccf8628a76e26a5bcb018 Mon Sep 17 00:00:00 2001 From: Henrik Witt-Hansen Date: Thu, 16 May 2024 01:54:51 +0200 Subject: [PATCH 147/159] Fix static ip assignment on wifi for rp2040 (#3896) by rearranging the arguments to match the expected input order. The lwip library makes an internal reorder or the arguments depending on the netmask to work with both ESP and Arduino platforms. The input order was incorrect when running on an rp2040 device. Co-authored-by: Henrik Witt-Hansen Co-authored-by: Ben Meadors --- src/mesh/wifi/WiFiAPClient.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 1de4d7669..a259d161b 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -225,10 +225,16 @@ bool initWifi() WiFi.mode(WIFI_STA); WiFi.setHostname(ourHost); + if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) { +#ifndef ARCH_RP2040 WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet, config.network.ipv4_config.dns); +#else + WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.gateway, + config.network.ipv4_config.subnet); +#endif } #ifndef ARCH_RP2040 WiFi.onEvent(WiFiEvent); From 04837b33027be04dfd44f45128e7ad0c9396510e Mon Sep 17 00:00:00 2001 From: Jorropo Date: Thu, 16 May 2024 02:37:35 +0200 Subject: [PATCH 148/159] bin: remove unused imports from platformio-custom.py --- bin/platformio-custom.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index e03a35e3a..651677af2 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -1,13 +1,12 @@ -import subprocess -import configparser -import traceback import sys from os.path import join + from readprops import readProps Import("env") platform = env.PioPlatform() + def esp32_create_combined_bin(source, target, env): # this sub is borrowed from ESPEasy build toolchain. It's licensed under GPL V3 # https://github.com/letscontrolit/ESPEasy/blob/mega/tools/pio/post_esp32.py @@ -20,8 +19,8 @@ def esp32_create_combined_bin(source, target, env): firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") chip = env.get("BOARD_MCU") flash_size = env.BoardConfig().get("upload.flash_size") - flash_freq = env.BoardConfig().get("build.f_flash", '40m') - flash_freq = flash_freq.replace('000000L', 'm') + flash_freq = env.BoardConfig().get("build.f_flash", "40m") + flash_freq = flash_freq.replace("000000L", "m") flash_mode = env.BoardConfig().get("build.flash_mode", "dio") memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi") if flash_mode == "qio" or flash_mode == "qout": @@ -51,23 +50,27 @@ def esp32_create_combined_bin(source, target, env): print(f" - {hex(app_offset)} | {firmware_name}") cmd += [hex(app_offset), firmware_name] - print('Using esptool.py arguments: %s' % ' '.join(cmd)) + print("Using esptool.py arguments: %s" % " ".join(cmd)) esptool.main(cmd) -if (platform.name == "espressif32"): + +if platform.name == "espressif32": sys.path.append(join(platform.get_package_dir("tool-esptoolpy"))) import esptool - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) + + env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) Import("projenv") prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" verObj = readProps(prefsLoc) -print("Using meshtastic platformio-custom.py, firmware version " + verObj['long']) +print("Using meshtastic platformio-custom.py, firmware version " + verObj["long"]) # General options that are passed to the C and C++ compilers -projenv.Append(CCFLAGS=[ - "-DAPP_VERSION=" + verObj['long'], - "-DAPP_VERSION_SHORT=" + verObj['short'] -]) +projenv.Append( + CCFLAGS=[ + "-DAPP_VERSION=" + verObj["long"], + "-DAPP_VERSION_SHORT=" + verObj["short"], + ] +) From 51d2795b269df7d3150810017bca55b10b1c8969 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 May 2024 07:46:47 -0500 Subject: [PATCH 149/159] Fix TBeam Supreme woes (and upgrade platform) --- boards/tbeam-s3-core.json | 1 + variants/tbeam-s3-core/pins_arduino.h | 8 -------- variants/tbeam-s3-core/platformio.ini | 2 ++ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/boards/tbeam-s3-core.json b/boards/tbeam-s3-core.json index 4c82a2789..8d2c3eed6 100644 --- a/boards/tbeam-s3-core.json +++ b/boards/tbeam-s3-core.json @@ -7,6 +7,7 @@ "extra_flags": [ "-DBOARD_HAS_PSRAM", "-DLILYGO_TBEAM_S3_CORE", + "-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_MODE=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" diff --git a/variants/tbeam-s3-core/pins_arduino.h b/variants/tbeam-s3-core/pins_arduino.h index 24edb7d9f..22ed814ff 100644 --- a/variants/tbeam-s3-core/pins_arduino.h +++ b/variants/tbeam-s3-core/pins_arduino.h @@ -6,14 +6,6 @@ #define USB_VID 0x303a #define USB_PID 0x1001 -#define EXTERNAL_NUM_INTERRUPTS 46 -#define NUM_DIGITAL_PINS 48 -#define NUM_ANALOG_INPUTS 20 - -#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; diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index e50d506b9..c71802255 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -4,6 +4,8 @@ extends = esp32s3_base board = tbeam-s3-core board_check = true +platform = platformio/espressif32@6.7.0 + lib_deps = ${esp32s3_base.lib_deps} lewisxhe/PCF8563_Library@1.0.1 From d95e3acab37660c545322df23f8a41eb378e8fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 15:52:22 +0200 Subject: [PATCH 150/159] implements #3885 --- src/modules/esp32/PaxcounterModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/esp32/PaxcounterModule.cpp b/src/modules/esp32/PaxcounterModule.cpp index b9fdfcb63..e6712871d 100644 --- a/src/modules/esp32/PaxcounterModule.cpp +++ b/src/modules/esp32/PaxcounterModule.cpp @@ -93,8 +93,8 @@ int32_t PaxcounterModule::runOnce() configuration.wificounter = 1; configuration.wifi_channel_map = WIFI_CHANNEL_ALL; configuration.wifi_channel_switch_interval = 50; - configuration.wifi_rssi_threshold = -80; - configuration.ble_rssi_threshold = -80; + configuration.wifi_rssi_threshold = Default::getConfiguredOrDefault(moduleConfig.paxcounter.wifi_threshold, -80); + configuration.ble_rssi_threshold = Default::getConfiguredOrDefault(moduleConfig.paxcounter.ble_threshold, -80); libpax_update_config(&configuration); // internal processing initialization From fce281f54cb89652a62a41ce51f7d6985208a60a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 01:40:50 +0200 Subject: [PATCH 151/159] update sensor libs --- platformio.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 0f2907dee..c6efc740d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -118,7 +118,7 @@ lib_deps = adafruit/Adafruit BMP280 Library@^2.6.8 adafruit/Adafruit BMP085 Library@^1.2.4 adafruit/Adafruit BME280 Library@^2.2.2 - https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.5.2400 + https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.7.2502 boschsensortec/BME68x Sensor Library@^1.1.40407 adafruit/Adafruit MCP9808 Library@^2.0.0 https://github.com/KodinLanewave/INA3221@^1.0.0 @@ -130,8 +130,8 @@ lib_deps = adafruit/Adafruit PM25 AQI Sensor@^1.0.6 adafruit/Adafruit MPU6050@^2.2.4 adafruit/Adafruit LIS3DH@^1.2.4 - https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 + lewisxhe/SensorLib@^0.2.0 adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 adafruit/Adafruit VEML7700 Library@^2.1.6 - https://github.com/adafruit/Adafruit_SHT4X#1.0.4 \ No newline at end of file + adafruit/Adafruit SHT4x Library@^1.0.4 \ No newline at end of file From d02e12a4245dafa9508c1b8a993dd9e9acdbe576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 15:08:59 +0200 Subject: [PATCH 152/159] fix include path --- variants/Dongle_nRF52840-pca10059-v1/platformio.ini | 2 +- variants/MakePython_nRF52840_eink/platformio.ini | 2 +- variants/MakePython_nRF52840_oled/platformio.ini | 2 +- variants/TWC_mesh_v4/platformio.ini | 2 +- variants/canaryone/platformio.ini | 2 +- variants/diy/platformio.ini | 4 ++-- variants/feather_diy/platformio.ini | 2 +- variants/lora_relay_v1/platformio.ini | 2 +- variants/lora_relay_v2/platformio.ini | 2 +- variants/monteops_hw1/platformio.ini | 2 +- variants/nano-g2-ultra/platformio.ini | 2 +- variants/pca10056-rc-clock/platformio.ini | 2 +- variants/rak10701/platformio.ini | 2 +- variants/rak11310/platformio.ini | 2 +- variants/rak4631/platformio.ini | 2 +- variants/rak4631_epaper/platformio.ini | 2 +- variants/rak4631_epaper_onrxtx/platformio.ini | 2 +- variants/rp2040-lora/platformio.ini | 2 +- variants/rpipico-slowclock/platformio.ini | 2 +- variants/rpipico/platformio.ini | 2 +- variants/rpipicow/platformio.ini | 2 +- variants/senselora_rp2040/platformio.ini | 2 +- variants/t-echo/platformio.ini | 2 +- variants/xiao_ble/platformio.ini | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/variants/Dongle_nRF52840-pca10059-v1/platformio.ini b/variants/Dongle_nRF52840-pca10059-v1/platformio.ini index 2d14f1ca1..c87f83d39 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/platformio.ini +++ b/variants/Dongle_nRF52840-pca10059-v1/platformio.ini @@ -2,7 +2,7 @@ extends = nrf52840_base board = nordic_pca10059 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" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" -DEINK_DISPLAY_MODEL=GxEPD2_420_M01 -DEINK_WIDTH=300 -DEINK_HEIGHT=400 diff --git a/variants/MakePython_nRF52840_eink/platformio.ini b/variants/MakePython_nRF52840_eink/platformio.ini index f421466ec..b11b54c7d 100644 --- a/variants/MakePython_nRF52840_eink/platformio.ini +++ b/variants/MakePython_nRF52840_eink/platformio.ini @@ -3,7 +3,7 @@ board_level = extra extends = nrf52840_base board = nordic_pca10059 build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_eink -D PRIVATE_HW - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" -D PIN_EINK_EN build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_eink> lib_deps = diff --git a/variants/MakePython_nRF52840_oled/platformio.ini b/variants/MakePython_nRF52840_oled/platformio.ini index e0ddb1377..0146385e0 100644 --- a/variants/MakePython_nRF52840_oled/platformio.ini +++ b/variants/MakePython_nRF52840_oled/platformio.ini @@ -3,7 +3,7 @@ board_level = extra extends = nrf52840_base board = nordic_pca10059 build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_oled -D PRIVATE_HW - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_oled> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/TWC_mesh_v4/platformio.ini b/variants/TWC_mesh_v4/platformio.ini index 481682143..4fb382334 100644 --- a/variants/TWC_mesh_v4/platformio.ini +++ b/variants/TWC_mesh_v4/platformio.ini @@ -2,7 +2,7 @@ extends = nrf52840_base board = nordic_pca10059 board_level = extra -build_flags = ${nrf52840_base.build_flags} -I variants/TWC_mesh_v4 -D TWC_mesh_v4 -L".pio\libdeps\TWC_mesh_v4\BSEC2 Software Library\src\cortex-m4\fpv4-sp-d16-hard" +build_flags = ${nrf52840_base.build_flags} -I variants/TWC_mesh_v4 -D TWC_mesh_v4 -L".pio\libdeps\TWC_mesh_v4\bsec2\src\cortex-m4\fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/TWC_mesh_v4> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/canaryone/platformio.ini b/variants/canaryone/platformio.ini index 4917f52c7..5e01c3763 100644 --- a/variants/canaryone/platformio.ini +++ b/variants/canaryone/platformio.ini @@ -6,7 +6,7 @@ debug_tool = jlink # add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling. build_flags = ${nrf52840_base.build_flags} -Ivariants/canaryone - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/canaryone> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index 94d59553d..adc10de44 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -53,7 +53,7 @@ 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" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/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} @@ -69,7 +69,7 @@ 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" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/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} diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini index 47c864b8e..82dbb317c 100644 --- a/variants/feather_diy/platformio.ini +++ b/variants/feather_diy/platformio.ini @@ -3,7 +3,7 @@ extends = nrf52840_base board = adafruit_feather_nrf52840 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" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/lora_relay_v1/platformio.ini b/variants/lora_relay_v1/platformio.ini index 8660bf64a..435d256c5 100644 --- a/variants/lora_relay_v1/platformio.ini +++ b/variants/lora_relay_v1/platformio.ini @@ -15,7 +15,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v1 -DTFT_DC=ST7735_RS -DTFT_RST=ST7735_RESET -DSPI_FREQUENCY=27000000 - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v1> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/lora_relay_v2/platformio.ini b/variants/lora_relay_v2/platformio.ini index cd2109f00..3598466d5 100644 --- a/variants/lora_relay_v2/platformio.ini +++ b/variants/lora_relay_v2/platformio.ini @@ -17,7 +17,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v2 -DSPI_FREQUENCY=27000000 -DTFT_WR=ST7735_SDA -DTFT_SCLK=ST7735_SCK - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v2> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/monteops_hw1/platformio.ini b/variants/monteops_hw1/platformio.ini index f9d260e74..551419abc 100644 --- a/variants/monteops_hw1/platformio.ini +++ b/variants/monteops_hw1/platformio.ini @@ -3,7 +3,7 @@ extends = nrf52840_base board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/monteops_hw1 -D MONTEOPS_HW1 - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/monteops_hw1> + + + lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/nano-g2-ultra/platformio.ini b/variants/nano-g2-ultra/platformio.ini index 2b011e032..913b38e3f 100644 --- a/variants/nano-g2-ultra/platformio.ini +++ b/variants/nano-g2-ultra/platformio.ini @@ -5,7 +5,7 @@ board = nano-g2-ultra debug_tool = jlink build_flags = ${nrf52840_base.build_flags} -Ivariants/nano-g2-ultra -D NANO_G2_ULTRA - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nano-g2-ultra> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/pca10056-rc-clock/platformio.ini b/variants/pca10056-rc-clock/platformio.ini index 0467b1417..f8cff4d73 100644 --- a/variants/pca10056-rc-clock/platformio.ini +++ b/variants/pca10056-rc-clock/platformio.ini @@ -5,5 +5,5 @@ extends = nrf52840_base board = nrf52840_dk_modified # add our variants files to the include and src paths build_flags = ${nrf52_base.build_flags} -Ivariants/pca10056-rc-clock - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/pca10056-rc-clock> \ No newline at end of file diff --git a/variants/rak10701/platformio.ini b/variants/rak10701/platformio.ini index ae43b1906..75e29bca0 100644 --- a/variants/rak10701/platformio.ini +++ b/variants/rak10701/platformio.ini @@ -4,7 +4,7 @@ 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" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/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. -DEINK_DISPLAY_MODEL=GxEPD2_213_BN -DEINK_WIDTH=250 diff --git a/variants/rak11310/platformio.ini b/variants/rak11310/platformio.ini index 6495278bf..e1bd2b1b0 100644 --- a/variants/rak11310/platformio.ini +++ b/variants/rak11310/platformio.ini @@ -8,7 +8,7 @@ build_flags = ${rp2040_base.build_flags} -DRAK11310 -Ivariants/rak11310 -DDEBUG_RP2040_PORT=Serial - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} debug_build_flags = ${rp2040_base.build_flags} diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 115e96967..f64811429 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -4,7 +4,7 @@ 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" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/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. -DEINK_DISPLAY_MODEL=GxEPD2_213_BN -DEINK_WIDTH=250 diff --git a/variants/rak4631_epaper/platformio.ini b/variants/rak4631_epaper/platformio.ini index ced732d94..1ca9a2157 100644 --- a/variants/rak4631_epaper/platformio.ini +++ b/variants/rak4631_epaper/platformio.ini @@ -3,7 +3,7 @@ extends = nrf52840_base board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_epaper -D RAK_4631 - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" -DEINK_DISPLAY_MODEL=GxEPD2_213_BN -DEINK_WIDTH=250 -DEINK_HEIGHT=122 diff --git a/variants/rak4631_epaper_onrxtx/platformio.ini b/variants/rak4631_epaper_onrxtx/platformio.ini index c4a13ec82..e0a0a5a58 100644 --- a/variants/rak4631_epaper_onrxtx/platformio.ini +++ b/variants/rak4631_epaper_onrxtx/platformio.ini @@ -4,7 +4,7 @@ board_level = extra extends = nrf52840_base board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_epaper -D RAK_4631 - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" -D PIN_EINK_EN=34 -D EINK_DISPLAY_MODEL=GxEPD2_213_BN -D EINK_WIDTH=250 diff --git a/variants/rp2040-lora/platformio.ini b/variants/rp2040-lora/platformio.ini index a1d6bea9d..8499f6f3c 100644 --- a/variants/rp2040-lora/platformio.ini +++ b/variants/rp2040-lora/platformio.ini @@ -9,7 +9,7 @@ build_flags = ${rp2040_base.build_flags} -Ivariants/rp2040-lora -DDEBUG_RP2040_PORT=Serial -DHW_SPI1_DEVICE - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} debug_build_flags = ${rp2040_base.build_flags} diff --git a/variants/rpipico-slowclock/platformio.ini b/variants/rpipico-slowclock/platformio.ini index 0b94eb9c6..c21994249 100644 --- a/variants/rpipico-slowclock/platformio.ini +++ b/variants/rpipico-slowclock/platformio.ini @@ -19,7 +19,7 @@ build_flags = ${rp2040_base.build_flags} -Ivariants/rpipico-slowclock -DDEBUG_RP2040_PORT=Serial2 -DHW_SPI1_DEVICE - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" -g -DNO_USB lib_deps = diff --git a/variants/rpipico/platformio.ini b/variants/rpipico/platformio.ini index 9537694ec..e4b9e479f 100644 --- a/variants/rpipico/platformio.ini +++ b/variants/rpipico/platformio.ini @@ -9,7 +9,7 @@ build_flags = ${rp2040_base.build_flags} -Ivariants/rpipico -DDEBUG_RP2040_PORT=Serial -DHW_SPI1_DEVICE - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} debug_build_flags = ${rp2040_base.build_flags} diff --git a/variants/rpipicow/platformio.ini b/variants/rpipicow/platformio.ini index 91ec964d9..2600b4b38 100644 --- a/variants/rpipicow/platformio.ini +++ b/variants/rpipicow/platformio.ini @@ -8,7 +8,7 @@ build_flags = ${rp2040_base.build_flags} -DRPI_PICO -Ivariants/rpipicow -DHW_SPI1_DEVICE - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" -fexceptions # for exception handling in MQTT build_src_filter = ${rp2040_base.build_src_filter} + lib_deps = diff --git a/variants/senselora_rp2040/platformio.ini b/variants/senselora_rp2040/platformio.ini index 3b3253ee8..c719bd261 100644 --- a/variants/senselora_rp2040/platformio.ini +++ b/variants/senselora_rp2040/platformio.ini @@ -8,6 +8,6 @@ build_flags = ${rp2040_base.build_flags} -DSENSELORA_RP2040 -Ivariants/senselora_rp2040 -DDEBUG_RP2040_PORT=Serial - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} \ No newline at end of file diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index aa8177b33..5b295c96a 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -8,7 +8,7 @@ debug_tool = jlink # add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling. build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DGPS_POWER_TOGGLE - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" -DEINK_DISPLAY_MODEL=GxEPD2_154_D67 -DEINK_WIDTH=200 -DEINK_HEIGHT=200 diff --git a/variants/xiao_ble/platformio.ini b/variants/xiao_ble/platformio.ini index c52e2c644..8e9a663a9 100644 --- a/variants/xiao_ble/platformio.ini +++ b/variants/xiao_ble/platformio.ini @@ -4,7 +4,7 @@ extends = nrf52840_base board = xiao_ble_sense board_level = extra build_flags = ${nrf52840_base.build_flags} -Ivariants/xiao_ble -Dxiao_ble -D EBYTE_E22 - -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" build_src_filter = ${nrf52_base.build_src_filter} +<../variants/xiao_ble> lib_deps = ${nrf52840_base.lib_deps} From 57575f8e491270655585d2428a9210ca9393b616 Mon Sep 17 00:00:00 2001 From: rcarteraz Date: Thu, 16 May 2024 08:11:46 -0700 Subject: [PATCH 153/159] remove has screen = 0 --- variants/heltec_wsl_v3/variant.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/variants/heltec_wsl_v3/variant.h b/variants/heltec_wsl_v3/variant.h index d3a009ade..917ea7fb9 100644 --- a/variants/heltec_wsl_v3/variant.h +++ b/variants/heltec_wsl_v3/variant.h @@ -3,8 +3,6 @@ #define LED_PIN LED -#define HAS_SCREEN 0 - #define VEXT_ENABLE Vext // active low, powers the oled display and the lora antenna boost #define BUTTON_PIN 0 From 4087bd93a91137f6a14c9561b5dc565be5cdd640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 17:35:14 +0200 Subject: [PATCH 154/159] Axe trunk from check We run that anyway as a separate job No need to run it in the matrix. --- .github/workflows/main_matrix.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 7affd8fc1..d329e693a 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -55,11 +55,6 @@ jobs: - name: Build base id: base uses: ./.github/actions/setup-base - - - name: Trunk Check - if: ${{ github.event_name != 'workflow_dispatch' }} - uses: trunk-io/trunk-action@v1 - - name: Check ${{ matrix.board }} run: bin/check-all.sh ${{ matrix.board }} From 0976705f2580edc50f2b8ae4a64fd5fc2611c8f2 Mon Sep 17 00:00:00 2001 From: caveman99 <25002+caveman99@users.noreply.github.com> Date: Thu, 16 May 2024 17:43:23 +0000 Subject: [PATCH 155/159] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/localonly.pb.h | 2 +- src/mesh/generated/meshtastic/module_config.pb.h | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/protobufs b/protobufs index bee9ddc71..5cfadd148 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit bee9ddc71677e974568a5a95362d78acac6bb974 +Subproject commit 5cfadd14890b7723a1fe6e7683f711911154b010 diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index b8cc80633..a5cbc42a5 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -308,7 +308,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; #define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_OEMStore_size #define meshtastic_ChannelFile_size 718 #define meshtastic_NodeInfoLite_size 166 -#define meshtastic_OEMStore_size 3346 +#define meshtastic_OEMStore_size 3368 #define meshtastic_PositionLite_size 28 #ifdef __cplusplus diff --git a/src/mesh/generated/meshtastic/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h index 1799f49da..1b8123ef5 100644 --- a/src/mesh/generated/meshtastic/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -182,7 +182,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_LOCALONLY_PB_H_MAX_SIZE meshtastic_LocalModuleConfig_size #define meshtastic_LocalConfig_size 537 -#define meshtastic_LocalModuleConfig_size 663 +#define meshtastic_LocalModuleConfig_size 685 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/module_config.pb.h b/src/mesh/generated/meshtastic/module_config.pb.h index ffda48704..f3c48ee6d 100644 --- a/src/mesh/generated/meshtastic/module_config.pb.h +++ b/src/mesh/generated/meshtastic/module_config.pb.h @@ -188,6 +188,10 @@ typedef struct _meshtastic_ModuleConfig_PaxcounterConfig { /* Enable the Paxcounter Module */ bool enabled; uint32_t paxcounter_update_interval; + /* WiFi RSSI threshold. Defaults to -80 */ + int32_t wifi_threshold; + /* BLE RSSI threshold. Defaults to -80 */ + int32_t ble_threshold; } meshtastic_ModuleConfig_PaxcounterConfig; /* Serial Config */ @@ -467,7 +471,7 @@ extern "C" { #define meshtastic_ModuleConfig_NeighborInfoConfig_init_default {0, 0} #define meshtastic_ModuleConfig_DetectionSensorConfig_init_default {0, 0, 0, 0, "", 0, 0, 0} #define meshtastic_ModuleConfig_AudioConfig_init_default {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} -#define meshtastic_ModuleConfig_PaxcounterConfig_init_default {0, 0} +#define meshtastic_ModuleConfig_PaxcounterConfig_init_default {0, 0, 0, 0} #define meshtastic_ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN, 0} #define meshtastic_ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0} @@ -483,7 +487,7 @@ extern "C" { #define meshtastic_ModuleConfig_NeighborInfoConfig_init_zero {0, 0} #define meshtastic_ModuleConfig_DetectionSensorConfig_init_zero {0, 0, 0, 0, "", 0, 0, 0} #define meshtastic_ModuleConfig_AudioConfig_init_zero {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} -#define meshtastic_ModuleConfig_PaxcounterConfig_init_zero {0, 0} +#define meshtastic_ModuleConfig_PaxcounterConfig_init_zero {0, 0, 0, 0} #define meshtastic_ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN, 0} #define meshtastic_ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0} @@ -526,6 +530,8 @@ extern "C" { #define meshtastic_ModuleConfig_AudioConfig_i2s_sck_tag 7 #define meshtastic_ModuleConfig_PaxcounterConfig_enabled_tag 1 #define meshtastic_ModuleConfig_PaxcounterConfig_paxcounter_update_interval_tag 2 +#define meshtastic_ModuleConfig_PaxcounterConfig_wifi_threshold_tag 3 +#define meshtastic_ModuleConfig_PaxcounterConfig_ble_threshold_tag 4 #define meshtastic_ModuleConfig_SerialConfig_enabled_tag 1 #define meshtastic_ModuleConfig_SerialConfig_echo_tag 2 #define meshtastic_ModuleConfig_SerialConfig_rxd_tag 3 @@ -695,7 +701,9 @@ X(a, STATIC, SINGULAR, UINT32, i2s_sck, 7) #define meshtastic_ModuleConfig_PaxcounterConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, enabled, 1) \ -X(a, STATIC, SINGULAR, UINT32, paxcounter_update_interval, 2) +X(a, STATIC, SINGULAR, UINT32, paxcounter_update_interval, 2) \ +X(a, STATIC, SINGULAR, INT32, wifi_threshold, 3) \ +X(a, STATIC, SINGULAR, INT32, ble_threshold, 4) #define meshtastic_ModuleConfig_PaxcounterConfig_CALLBACK NULL #define meshtastic_ModuleConfig_PaxcounterConfig_DEFAULT NULL @@ -836,7 +844,7 @@ extern const pb_msgdesc_t meshtastic_RemoteHardwarePin_msg; #define meshtastic_ModuleConfig_MQTTConfig_size 254 #define meshtastic_ModuleConfig_MapReportSettings_size 12 #define meshtastic_ModuleConfig_NeighborInfoConfig_size 8 -#define meshtastic_ModuleConfig_PaxcounterConfig_size 8 +#define meshtastic_ModuleConfig_PaxcounterConfig_size 30 #define meshtastic_ModuleConfig_RangeTestConfig_size 10 #define meshtastic_ModuleConfig_RemoteHardwareConfig_size 96 #define meshtastic_ModuleConfig_SerialConfig_size 28 From f3cf9a5e719930408b35ac24b86b1065e8c5c180 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 17 May 2024 08:37:09 +1200 Subject: [PATCH 156/159] Adjust refresh for Heltec Wireless Paper V1.1 (#3913) --- src/graphics/EInkDynamicDisplay.h | 1 + variants/heltec_wireless_paper/platformio.ini | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/graphics/EInkDynamicDisplay.h b/src/graphics/EInkDynamicDisplay.h index 8f3ce205a..9e131dca7 100644 --- a/src/graphics/EInkDynamicDisplay.h +++ b/src/graphics/EInkDynamicDisplay.h @@ -109,6 +109,7 @@ class EInkDynamicDisplay : public EInkDisplay, protected concurrency::NotifiedWo refreshTypes currentConfig = FULL; // Which refresh type is GxEPD2 currently configured for // Optional - track ghosting, pixel by pixel + // May 2024: no longer used by any display. Kept for possible future use. #ifdef EINK_LIMIT_GHOSTING_PX void countGhostPixels(); // Count any pixels which have moved from black to white since last full-refresh void checkExcessiveGhosting(); // Check if ghosting exceeds defined limit diff --git a/variants/heltec_wireless_paper/platformio.ini b/variants/heltec_wireless_paper/platformio.ini index d7aac5e22..afbbd8be9 100644 --- a/variants/heltec_wireless_paper/platformio.ini +++ b/variants/heltec_wireless_paper/platformio.ini @@ -12,12 +12,12 @@ build_flags = -D EINK_LIMIT_FASTREFRESH=10 ; How many consecutive fast-refreshes are permitted -D EINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates -D EINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates - -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated +; -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. -D EINK_HASQUIRK_GHOSTING ; Display model is identified as "prone to ghosting" -D EINK_HASQUIRK_WEAKFASTREFRESH ; Pixels set with fast-refresh are easy to clear, disrupted by sunlight lib_deps = ${esp32s3_base.lib_deps} - https://github.com/meshtastic/GxEPD2#55f618961db45a23eff0233546430f1e5a80f63a + https://github.com/meshtastic/GxEPD2#b202ebfec6a4821e098cf7a625ba0f6f2400292d lewisxhe/PCF8563_Library@^1.0.1 upload_speed = 115200 \ No newline at end of file From b4a7e78d182f72e4b9c1309ea55afd24d1f5edc9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 May 2024 17:27:36 -0500 Subject: [PATCH 157/159] Don't reboot for certain config prefs and make accelerometer thread re-entrant (#3889) * Don't reboot for certain config prefs and make accelerometer thread re-entrant * WHOOPS * Don't reboot for LED heartbeat and button press * Remove TZ --- src/AccelerometerThread.h | 89 ++++++++++++++++++++----------------- src/main.cpp | 6 +-- src/main.h | 5 +++ src/modules/AdminModule.cpp | 47 +++++++++++++++++++- 4 files changed, 99 insertions(+), 48 deletions(-) diff --git a/src/AccelerometerThread.h b/src/AccelerometerThread.h index 66e5624f1..ad40cd9bd 100644 --- a/src/AccelerometerThread.h +++ b/src/AccelerometerThread.h @@ -1,3 +1,4 @@ +#pragma once #include "configuration.h" #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR @@ -14,13 +15,10 @@ #include #include -SensorBMA423 bmaSensor; -bool BMA_IRQ = false; - #define ACCELEROMETER_CHECK_INTERVAL_MS 100 #define ACCELEROMETER_CLICK_THRESHOLD 40 -int readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len) +static inline int readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len) { Wire.beginTransmission(address); Wire.write(reg); @@ -33,7 +31,7 @@ int readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len) return 0; // Pass } -int writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len) +static inline int writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len) { Wire.beginTransmission(address); Wire.write(reg); @@ -41,8 +39,6 @@ int writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len) return (0 != Wire.endTransmission()); } -namespace concurrency -{ class AccelerometerThread : public concurrency::OSThread { public: @@ -53,14 +49,55 @@ class AccelerometerThread : public concurrency::OSThread disable(); return; } + acceleremoter_type = type; if (!config.display.wake_on_tap_or_motion && !config.device.double_tap_as_button_press) { LOG_DEBUG("AccelerometerThread disabling due to no interested configurations\n"); disable(); return; } + init(); + } - acceleremoter_type = type; + void start() + { + init(); + setIntervalFromNow(0); + }; + + protected: + int32_t runOnce() override + { + canSleep = true; // Assume we should not keep the board awake + + if (acceleremoter_type == ScanI2C::DeviceType::MPU6050 && mpu.getMotionInterruptStatus()) { + wakeScreen(); + } else if (acceleremoter_type == ScanI2C::DeviceType::LIS3DH && lis.getClick() > 0) { + uint8_t click = lis.getClick(); + if (!config.device.double_tap_as_button_press) { + wakeScreen(); + } + + if (config.device.double_tap_as_button_press && (click & 0x20)) { + buttonPress(); + return 500; + } + } else if (acceleremoter_type == ScanI2C::DeviceType::BMA423 && bmaSensor.readIrqStatus() != DEV_WIRE_NONE) { + if (bmaSensor.isTilt() || bmaSensor.isDoubleTap()) { + wakeScreen(); + return 500; + } + } else if (acceleremoter_type == ScanI2C::DeviceType::LSM6DS3 && lsm.shake()) { + wakeScreen(); + return 500; + } + + return ACCELEROMETER_CHECK_INTERVAL_MS; + } + + private: + void init() + { LOG_DEBUG("AccelerometerThread initializing\n"); if (acceleremoter_type == ScanI2C::DeviceType::MPU6050 && mpu.begin(accelerometer_found.address)) { @@ -123,38 +160,6 @@ class AccelerometerThread : public concurrency::OSThread // Duration is number of occurances needed to trigger, higher threshold is less sensitive } } - - protected: - int32_t runOnce() override - { - canSleep = true; // Assume we should not keep the board awake - - if (acceleremoter_type == ScanI2C::DeviceType::MPU6050 && mpu.getMotionInterruptStatus()) { - wakeScreen(); - } else if (acceleremoter_type == ScanI2C::DeviceType::LIS3DH && lis.getClick() > 0) { - uint8_t click = lis.getClick(); - if (!config.device.double_tap_as_button_press) { - wakeScreen(); - } - - if (config.device.double_tap_as_button_press && (click & 0x20)) { - buttonPress(); - return 500; - } - } else if (acceleremoter_type == ScanI2C::DeviceType::BMA423 && bmaSensor.readIrqStatus() != DEV_WIRE_NONE) { - if (bmaSensor.isTilt() || bmaSensor.isDoubleTap()) { - wakeScreen(); - return 500; - } - } else if (acceleremoter_type == ScanI2C::DeviceType::LSM6DS3 && lsm.shake()) { - wakeScreen(); - return 500; - } - - return ACCELEROMETER_CHECK_INTERVAL_MS; - } - - private: void wakeScreen() { if (powerFSM.getState() == &stateDARK) { @@ -173,8 +178,8 @@ class AccelerometerThread : public concurrency::OSThread Adafruit_MPU6050 mpu; Adafruit_LIS3DH lis; Adafruit_LSM6DS3TRC lsm; + SensorBMA423 bmaSensor; + bool BMA_IRQ = false; }; -} // namespace concurrency - #endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f14d08188..64ff92dd7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -94,9 +94,10 @@ NRF52Bluetooth *nrf52Bluetooth; #include "PowerFSMThread.h" -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #include "AccelerometerThread.h" #include "AmbientLightingThread.h" +AccelerometerThread *accelerometerThread; #endif #ifdef HAS_I2S @@ -197,9 +198,6 @@ uint32_t timeLastPowered = 0; static Periodic *ledPeriodic; static OSThread *powerFSMthread; -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR -static OSThread *accelerometerThread; -#endif static OSThread *ambientLightingThread; SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0); diff --git a/src/main.h b/src/main.h index bb812b7b6..db05a4734 100644 --- a/src/main.h +++ b/src/main.h @@ -53,6 +53,11 @@ extern Adafruit_DRV2605 drv; extern AudioThread *audioThread; #endif +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR +#include "AccelerometerThread.h" +extern AccelerometerThread *accelerometerThread; +#endif + extern bool isVibrating; extern int TCPPort; // set by Portduino diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index adf5620ba..c9416a9b5 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -26,6 +26,9 @@ #if !MESHTASTIC_EXCLUDE_GPS #include "GPS.h" #endif +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR +#include "AccelerometerThread.h" +#endif AdminModule *adminModule; bool hasOpenEditTransaction; @@ -221,12 +224,12 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta nodeDB->setLocalPosition(r->set_fixed_position); config.position.fixed_position = true; saveChanges(SEGMENT_DEVICESTATE | SEGMENT_CONFIG, false); - // Send our new fixed position to the mesh for good measure - positionModule->sendOurPosition(); #if !MESHTASTIC_EXCLUDE_GPS if (gps != nullptr) gps->enable(); #endif + // Send our new fixed position to the mesh for good measure + positionModule->sendOurPosition(); } break; } @@ -352,6 +355,26 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) case meshtastic_Config_device_tag: LOG_INFO("Setting config: Device\n"); config.has_device = true; +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + if (config.device.double_tap_as_button_press == false && c.payload_variant.device.double_tap_as_button_press == true) { + accelerometerThread->start(); + } +#endif +#ifdef LED_PIN + // Turn LED off if heartbeat by config + if (c.payload_variant.device.led_heartbeat_disabled) { + digitalWrite(LED_PIN, LOW ^ LED_INVERTED); + } +#endif + if (config.device.button_gpio == c.payload_variant.device.button_gpio && + config.device.buzzer_gpio == c.payload_variant.device.buzzer_gpio && + config.device.debug_log_enabled == c.payload_variant.device.debug_log_enabled && + config.device.serial_enabled == c.payload_variant.device.serial_enabled && + config.device.role == c.payload_variant.device.role && + config.device.disable_triple_click == c.payload_variant.device.disable_triple_click && + config.device.rebroadcast_mode == c.payload_variant.device.rebroadcast_mode) { + requiresReboot = false; + } config.device = c.payload_variant.device; // If we're setting router role for the first time, install its intervals if (existingRole != c.payload_variant.device.role) @@ -371,6 +394,16 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) case meshtastic_Config_power_tag: LOG_INFO("Setting config: Power\n"); config.has_power = true; + // Really just the adc override is the only thing that can change without a reboot + if (config.power.device_battery_ina_address == c.payload_variant.power.device_battery_ina_address && + config.power.is_power_saving == c.payload_variant.power.is_power_saving && + config.power.ls_secs == c.payload_variant.power.ls_secs && + config.power.min_wake_secs == c.payload_variant.power.min_wake_secs && + config.power.on_battery_shutdown_after_secs == c.payload_variant.power.on_battery_shutdown_after_secs && + config.power.sds_secs == c.payload_variant.power.sds_secs && + config.power.wait_bluetooth_secs == c.payload_variant.power.wait_bluetooth_secs) { + requiresReboot = false; + } config.power = c.payload_variant.power; break; case meshtastic_Config_network_tag: @@ -381,6 +414,16 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) case meshtastic_Config_display_tag: LOG_INFO("Setting config: Display\n"); config.has_display = true; + if (config.display.screen_on_secs == c.payload_variant.display.screen_on_secs && + config.display.flip_screen == c.payload_variant.display.flip_screen && + config.display.oled == c.payload_variant.display.oled) { + requiresReboot = false; + } +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + if (config.display.wake_on_tap_or_motion == false && c.payload_variant.display.wake_on_tap_or_motion == true) { + accelerometerThread->start(); + } +#endif config.display = c.payload_variant.display; break; case meshtastic_Config_lora_tag: From 314d2e2da191246754be6df0867237c0656b2e27 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 17 May 2024 02:34:18 -0500 Subject: [PATCH 158/159] debconf expects absolute paths. --- .github/workflows/package_raspbian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index 367f90c56..43c79a8c2 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -57,7 +57,7 @@ jobs: cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml chmod +x .debpkg/usr/sbin/meshtasticd cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service - echo "etc/meshtasticd/config.yaml" > .debpkg/debian/conffiles + echo "/etc/meshtasticd/config.yaml" > .debpkg/debian/conffiles - uses: jiro4989/build-deb-action@v3 with: From a2284e3d5242d9e5cb484a6dc349b8129598e2cc Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 17 May 2024 03:32:11 -0500 Subject: [PATCH 159/159] DEBIAN is case sensitive --- .github/workflows/package_raspbian.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index 43c79a8c2..f6e40052e 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -46,7 +46,7 @@ jobs: - name: build .debpkg run: | - mkdir -p .debpkg/debian + mkdir -p .debpkg/DEBIAN mkdir -p .debpkg/usr/share/doc/meshtasticd/web mkdir -p .debpkg/usr/sbin mkdir -p .debpkg/etc/meshtasticd @@ -57,7 +57,8 @@ jobs: cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml chmod +x .debpkg/usr/sbin/meshtasticd cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service - echo "/etc/meshtasticd/config.yaml" > .debpkg/debian/conffiles + echo "/etc/meshtasticd/config.yaml" > .debpkg/DEBIAN/conffiles + chmod +x .debpkg/DEBIAN/conffiles - uses: jiro4989/build-deb-action@v3 with: