From 52df85c3386f83df0374a41abf797f1dc21ca907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 24 May 2023 02:44:30 +0200 Subject: [PATCH 01/15] tryfix cppcheck errors also ignore temporary files --- .gitignore | 1 + src/mesh/TypedQueue.h | 2 +- src/modules/AdminModule.cpp | 8 +------- suppressions.txt | 3 +++ 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index be3ca3397..89f8ee065 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ __pycache__ venv/ release/ .vscode/extensions.json +/compile_commands.json diff --git a/src/mesh/TypedQueue.h b/src/mesh/TypedQueue.h index 721eec2c0..c08f9183b 100644 --- a/src/mesh/TypedQueue.h +++ b/src/mesh/TypedQueue.h @@ -74,7 +74,7 @@ template class TypedQueue concurrency::OSThread *reader = NULL; public: - TypedQueue(int maxElements) {} + explicit TypedQueue(int maxElements) {} int numFree() { return 1; } // Always claim 1 free, because we can grow to any size diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 28177cb63..7634ab14e 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -553,9 +553,8 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r { meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; - meshtastic_DeviceConnectionStatus conn; + meshtastic_DeviceConnectionStatus conn = meshtastic_DeviceConnectionStatus_init_zero; - conn.wifi = {0}; #if HAS_WIFI conn.has_wifi = true; conn.wifi.has_status = true; @@ -571,11 +570,8 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r conn.wifi.status.is_mqtt_connected = mqtt && mqtt->connected(); conn.wifi.status.is_syslog_connected = false; // FIXME wire this up } -#else - conn.has_wifi = false; #endif - conn.ethernet = {0}; #if HAS_ETHERNET conn.has_ethernet = true; conn.ethernet.has_status = true; @@ -587,8 +583,6 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r } else { conn.ethernet.status.is_connected = false; } -#else - conn.has_ethernet = false; #endif #if HAS_BLUETOOTH diff --git a/suppressions.txt b/suppressions.txt index 0dd5198ec..e2af9aeef 100644 --- a/suppressions.txt +++ b/suppressions.txt @@ -36,6 +36,7 @@ cstyleCast // ignore stuff that is not ours *:.pio/* *:*/libdeps/* +*:*/generated/* noExplicitConstructor:*/mqtt/* postfixOperator:*/mqtt/* @@ -44,3 +45,5 @@ missingOverride virtualCallInConstructor passedByValue:*/RedirectablePrint.h + +internalAstError:*/CrossPlatformCryptoEngine.cpp From e5b049d2e2d304e3f0823d73fbb93653ba66b4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 24 May 2023 02:48:48 +0200 Subject: [PATCH 02/15] trunk --- src/modules/AdminModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 7634ab14e..ae254e7f7 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -553,7 +553,7 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r { meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; - meshtastic_DeviceConnectionStatus conn = meshtastic_DeviceConnectionStatus_init_zero; + meshtastic_DeviceConnectionStatus conn = meshtastic_DeviceConnectionStatus_init_zero; #if HAS_WIFI conn.has_wifi = true; From f8cba0e7f283f5934ee602c27c0f8d9311a831cc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 24 May 2023 07:04:07 -0500 Subject: [PATCH 03/15] Remove pegged commit hash since 3.2.1 is released --- arch/rp2040/rp2040.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 9d102be02..3ecbd9106 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -2,7 +2,7 @@ [rp2040_base] platform = https://github.com/maxgerhardt/platform-raspberrypi.git#0c33219f53faa035e188925ea1324f472e8b93d2 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#652f9f9eda0d77efeafebc7c1ff5cd45defc71bf +#platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#652f9f9eda0d77efeafebc7c1ff5cd45defc71bf board_build.core = earlephilhower board_build.filesystem_size = 0.5m From 2728e86aabba1afdd38c80c8d0ce5773a41ccad0 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 24 May 2023 07:08:22 -0500 Subject: [PATCH 04/15] No longer are you extras, my friends --- variants/rak11310/platformio.ini | 1 - variants/rpipico/platformio.ini | 1 - 2 files changed, 2 deletions(-) diff --git a/variants/rak11310/platformio.ini b/variants/rak11310/platformio.ini index c4ff35d4e..b64c19f5d 100644 --- a/variants/rak11310/platformio.ini +++ b/variants/rak11310/platformio.ini @@ -1,7 +1,6 @@ [env:rak11310] extends = rp2040_base board = wiscore_rak11300 -board_level = extra upload_protocol = picotool # add our variants files to the include and src paths diff --git a/variants/rpipico/platformio.ini b/variants/rpipico/platformio.ini index c9852a4b3..be051095d 100644 --- a/variants/rpipico/platformio.ini +++ b/variants/rpipico/platformio.ini @@ -1,7 +1,6 @@ [env:pico] extends = rp2040_base board = rpipico -board_level = extra upload_protocol = picotool # add our variants files to the include and src paths From 1ae77d198dc3f9b647416820c3bf33d644e2b5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 24 May 2023 14:16:05 +0200 Subject: [PATCH 05/15] fix onebutton deprection warning (#2512) --- src/ButtonThread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 0a8b2afa5..d8e781a6c 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -51,7 +51,7 @@ class ButtonThread : public concurrency::OSThread pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT_PULLUP_SENSE); #endif userButton.attachClick(userButtonPressed); - userButton.setClickTicks(300); + userButton.setClickMs(300); userButton.attachDuringLongPress(userButtonPressedLong); userButton.attachDoubleClick(userButtonDoublePressed); userButton.attachMultiClick(userButtonMultiPressed); From 59b1adf12fa39d4a733393af6916191b600332bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 24 May 2023 17:29:50 +0200 Subject: [PATCH 06/15] Move to our own logging system (#2513) --- src/Power.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index c3a34d620..685181e3f 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -6,7 +6,6 @@ #include "main.h" #include "sleep.h" #include "utils.h" -static const char *TAG = "ADCmod"; #ifdef DEBUG_HEAP_MQTT #include "mqtt/MQTT.h" @@ -292,11 +291,11 @@ bool Power::analogInit() esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, width, DEFAULT_VREF, adc_characs); // show ADC characterization base if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) { - ESP_LOGI(TAG, "ADC characterization based on Two Point values stored in eFuse"); + LOG_INFO("ADCmod: ADC characterization based on Two Point values stored in eFuse\n"); } else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) { - ESP_LOGI(TAG, "ADC characterization based on reference voltage stored in eFuse"); + LOG_INFO("ADCmod: ADC characterization based on reference voltage stored in eFuse\n"); } else { - ESP_LOGI(TAG, "ADC characterization based on default reference voltage"); + LOG_INFO("ADCmod: ADC characterization based on default reference voltage\n"); } #endif // ARCH_ESP32 From f2cf0ed3154c156b8c6cbccbc6a043758dbbff56 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 24 May 2023 14:09:37 -0500 Subject: [PATCH 07/15] Platform packages version (#2515) * I think something is wrong here * Use tag on repo --- arch/rp2040/rp2040.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 3ecbd9106..1ed83f3b0 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -2,7 +2,7 @@ [rp2040_base] platform = https://github.com/maxgerhardt/platform-raspberrypi.git#0c33219f53faa035e188925ea1324f472e8b93d2 extends = arduino_base -#platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#652f9f9eda0d77efeafebc7c1ff5cd45defc71bf +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#3.2.1 board_build.core = earlephilhower board_build.filesystem_size = 0.5m From e943fc6b8a65c7c2112e23aad8b69c2ae2704b05 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 25 May 2023 06:48:35 -0500 Subject: [PATCH 08/15] Remove RP2040 check until we can make it behave --- .github/workflows/main_matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index bbc7fdf84..caf04fff6 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -33,7 +33,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core - board: tlora-t3s3-v1 - - board: rak11310 + #- board: rak11310 runs-on: ubuntu-latest steps: From a5831637667bcd09989a8cd163a0e0e8ff410007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 25 May 2023 14:35:45 +0200 Subject: [PATCH 09/15] fix BSEC2 BME680 Sensor Readings --- platformio.ini | 2 +- .../Telemetry/EnvironmentTelemetry.cpp | 84 ++++++++++--------- src/modules/Telemetry/EnvironmentTelemetry.h | 1 + src/modules/Telemetry/Sensor/BME680Sensor.cpp | 49 +++++++++-- src/modules/Telemetry/Sensor/BME680Sensor.h | 26 +++--- .../Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c | 82 ++++++++++++++++++ .../Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h | 3 + 7 files changed, 186 insertions(+), 61 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c create mode 100644 src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h diff --git a/platformio.ini b/platformio.ini index 498a05b97..156eb0076 100644 --- a/platformio.ini +++ b/platformio.ini @@ -102,7 +102,7 @@ lib_deps = adafruit/Adafruit Unified Sensor@^1.1.9 adafruit/Adafruit BMP280 Library@^2.6.6 adafruit/Adafruit BME280 Library@^2.2.2 - boschsensortec/BSEC2 Software Library@^1.3.2200 + https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.5.2400 boschsensortec/BME68x Sensor Library@^1.1.40407 adafruit/Adafruit MCP9808 Library@^2.0.0 adafruit/Adafruit INA260 Library@^1.5.0 diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index bf0ca6182..2590e1650 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -52,7 +52,7 @@ SHT31Sensor sht31Sensor; int32_t EnvironmentTelemetryModule::runOnce() { - int32_t result = INT32_MAX; + uint32_t result = UINT32_MAX; /* Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. @@ -98,8 +98,12 @@ int32_t EnvironmentTelemetryModule::runOnce() return result; } else { // if we somehow got to a second run of this module with measurement disabled, then just wait forever - if (!moduleConfig.telemetry.environment_measurement_enabled) - return result; + if (!moduleConfig.telemetry.environment_measurement_enabled) { + return disable(); + } else { + if (bme680Sensor.hasSensor()) + result = bme680Sensor.runTrigger(); + } uint32_t now = millis(); if (((lastSentToMesh == 0) || @@ -107,13 +111,14 @@ int32_t EnvironmentTelemetryModule::runOnce() airTime->isTxAllowedAirUtil()) { sendTelemetry(); lastSentToMesh = now; - } else if (service.isToPhoneQueueEmpty()) { + } else if (((lastSentToPhone == 0) || ((now - lastSentToPhone) >= sendToPhoneIntervalMs)) && + (service.isToPhoneQueueEmpty())) { // Just send to phone when it's not our time to send to mesh yet // Only send while queue is empty (phone assumed connected) sendTelemetry(NODENUM_BROADCAST, true); } } - return sendToPhoneIntervalMs; + return min(sendToPhoneIntervalMs, result); } bool EnvironmentTelemetryModule::wantUIFrame() @@ -205,6 +210,7 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) { meshtastic_Telemetry m; + bool valid = false; m.time = getTime(); m.which_variant = meshtastic_Telemetry_environment_metrics_tag; @@ -216,50 +222,52 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) m.variant.environment_metrics.voltage = 0; if (sht31Sensor.hasSensor()) - sht31Sensor.getMetrics(&m); + valid = sht31Sensor.getMetrics(&m); if (lps22hbSensor.hasSensor()) - lps22hbSensor.getMetrics(&m); + valid = lps22hbSensor.getMetrics(&m); if (shtc3Sensor.hasSensor()) - shtc3Sensor.getMetrics(&m); + valid = shtc3Sensor.getMetrics(&m); if (bmp280Sensor.hasSensor()) - bmp280Sensor.getMetrics(&m); + valid = bmp280Sensor.getMetrics(&m); if (bme280Sensor.hasSensor()) - bme280Sensor.getMetrics(&m); + valid = bme280Sensor.getMetrics(&m); if (bme680Sensor.hasSensor()) - bme680Sensor.getMetrics(&m); + valid = bme680Sensor.getMetrics(&m); if (mcp9808Sensor.hasSensor()) - mcp9808Sensor.getMetrics(&m); + valid = mcp9808Sensor.getMetrics(&m); if (ina219Sensor.hasSensor()) - ina219Sensor.getMetrics(&m); + valid = ina219Sensor.getMetrics(&m); if (ina260Sensor.hasSensor()) - ina260Sensor.getMetrics(&m); + valid = ina260Sensor.getMetrics(&m); - LOG_INFO( - "(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, voltage=%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); + if (valid) { + LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, " + "voltage=%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); - sensor_read_error_count = 0; + sensor_read_error_count = 0; - meshtastic_MeshPacket *p = allocDataProtobuf(m); - p->to = dest; - p->decoded.want_response = false; - if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR) - p->priority = meshtastic_MeshPacket_Priority_RELIABLE; - else - p->priority = meshtastic_MeshPacket_Priority_MIN; - // release previous packet before occupying a new spot - if (lastMeasurementPacket != nullptr) - packetPool.release(lastMeasurementPacket); + meshtastic_MeshPacket *p = allocDataProtobuf(m); + p->to = dest; + p->decoded.want_response = false; + if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR) + p->priority = meshtastic_MeshPacket_Priority_RELIABLE; + else + p->priority = meshtastic_MeshPacket_Priority_MIN; + // release previous packet before occupying a new spot + if (lastMeasurementPacket != nullptr) + packetPool.release(lastMeasurementPacket); - lastMeasurementPacket = packetPool.allocCopy(*p); - if (phoneOnly) { - LOG_INFO("Sending packet to phone\n"); - service.sendToPhone(p); - } else { - LOG_INFO("Sending packet to mesh\n"); - service.sendToMesh(p, RX_SRC_LOCAL, true); + lastMeasurementPacket = packetPool.allocCopy(*p); + if (phoneOnly) { + LOG_INFO("Sending packet to phone\n"); + service.sendToPhone(p); + } else { + LOG_INFO("Sending packet to mesh\n"); + service.sendToMesh(p, RX_SRC_LOCAL, true); + } } - return true; + return valid; } diff --git a/src/modules/Telemetry/EnvironmentTelemetry.h b/src/modules/Telemetry/EnvironmentTelemetry.h index 3340f8751..d6cd2137f 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.h +++ b/src/modules/Telemetry/EnvironmentTelemetry.h @@ -39,5 +39,6 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu meshtastic_MeshPacket *lastMeasurementPacket; uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute uint32_t lastSentToMesh = 0; + uint32_t lastSentToPhone = 0; uint32_t sensor_read_error_count = 0; }; diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 6e28aac06..5b32645e6 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -6,21 +6,41 @@ BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {} +int32_t BME680Sensor::runTrigger() +{ + if (!bme680.run()) { + checkStatus("runTrigger"); + } + return 35; +} + int32_t BME680Sensor::runOnce() { - LOG_INFO("Init sensor: %s with the BSEC Library\n", sensorName); + if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - bme680.begin(nodeTelemetrySensorsMap[sensorType], Wire); + if (!bme680.begin(nodeTelemetrySensorsMap[sensorType], Wire)) + checkStatus("begin"); + if (bme680.status == BSEC_OK) { - bme680.setConfig(Default_H2S_NonH2S_config); - loadState(); - bme680.updateSubscription(sensorList, 13, BSEC_SAMPLE_RATE_LP); status = 1; + if (!bme680.setConfig(bsec_config_iaq)) { + checkStatus("setConfig"); + status = 0; + } + loadState(); + if (!bme680.updateSubscription(sensorList, ARRAY_LEN(sensorList), BSEC_SAMPLE_RATE_LP)) { + checkStatus("updateSubscription"); + status = 0; + } + LOG_INFO("Init sensor: %s with the BSEC Library version %d.%d.%d.%d \n", sensorName, bme680.version.major, + bme680.version.minor, bme680.version.major_bugfix, bme680.version.minor_bugfix); } else { status = 0; } + if (status == 0) + LOG_DEBUG("BME680Sensor::runOnce: bme680.status %d\n", bme680.status); return initI2CSensor(); } @@ -29,8 +49,8 @@ void BME680Sensor::setup() {} bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement) { - bme680.run(); - + if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0) + return false; measurement->variant.environment_metrics.temperature = bme680.getData(BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE).signal; measurement->variant.environment_metrics.relative_humidity = bme680.getData(BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY).signal; @@ -106,4 +126,17 @@ void BME680Sensor::updateState() #else LOG_ERROR("ERROR: Filesystem not implemented\n"); #endif -} \ No newline at end of file +} + +void BME680Sensor::checkStatus(String functionName) +{ + if (bme680.status < BSEC_OK) + LOG_ERROR("%s BSEC2 code: %s\n", functionName.c_str(), String(bme680.status).c_str()); + else if (bme680.status > BSEC_OK) + LOG_WARN("%s BSEC2 code: %s\n", functionName.c_str(), String(bme680.status).c_str()); + + if (bme680.sensor.status < BME68X_OK) + LOG_ERROR("%s BME68X code: %s\n", functionName.c_str(), String(bme680.sensor.status).c_str()); + else if (bme680.sensor.status > BME68X_OK) + LOG_WARN("%s BME68X code: %s\n", functionName.c_str(), String(bme680.sensor.status).c_str()); +} diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.h b/src/modules/Telemetry/Sensor/BME680Sensor.h index 6b45a76f4..06e24b1a9 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.h +++ b/src/modules/Telemetry/Sensor/BME680Sensor.h @@ -4,7 +4,7 @@ #define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // That's 6 hours worth of millis() -#include "config/Default_H2S_NonH2S/Default_H2S_NonH2S.h" +#include "bme680_iaq_33v_3s_4d/bsec_iaq.h" class BME680Sensor : virtual public TelemetrySensor { @@ -17,24 +17,22 @@ class BME680Sensor : virtual public TelemetrySensor uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0}; uint8_t accuracy = 0; uint16_t stateUpdateCounter = 0; - bsec_virtual_sensor_t sensorList[13] = {BSEC_OUTPUT_IAQ, - BSEC_OUTPUT_STATIC_IAQ, - BSEC_OUTPUT_CO2_EQUIVALENT, - BSEC_OUTPUT_BREATH_VOC_EQUIVALENT, - BSEC_OUTPUT_RAW_TEMPERATURE, - BSEC_OUTPUT_RAW_PRESSURE, - BSEC_OUTPUT_RAW_HUMIDITY, - BSEC_OUTPUT_RAW_GAS, - BSEC_OUTPUT_STABILIZATION_STATUS, - BSEC_OUTPUT_RUN_IN_STATUS, - BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE, - BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY, - BSEC_OUTPUT_GAS_PERCENTAGE}; + bsecSensor sensorList[9] = {BSEC_OUTPUT_IAQ, + BSEC_OUTPUT_RAW_TEMPERATURE, + BSEC_OUTPUT_RAW_PRESSURE, + BSEC_OUTPUT_RAW_HUMIDITY, + BSEC_OUTPUT_RAW_GAS, + BSEC_OUTPUT_STABILIZATION_STATUS, + BSEC_OUTPUT_RUN_IN_STATUS, + BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE, + BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY}; void loadState(); void updateState(); + void checkStatus(String functionName); public: BME680Sensor(); + int32_t runTrigger(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; }; \ 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 new file mode 100644 index 000000000..1f27e6c69 --- /dev/null +++ b/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.c @@ -0,0 +1,82 @@ +#include "bsec_iaq.h" + +const uint8_t bsec_config_iaq[1974] = { + 0, 0, 4, 2, 189, 1, 0, 0, 0, 0, 0, 0, 158, 7, 0, 0, 176, 0, 1, 0, 0, 192, 168, 71, 64, + 49, 119, 76, 0, 0, 97, 69, 0, 0, 97, 69, 137, 65, 0, 191, 205, 204, 204, 190, 0, 0, 64, 191, 225, 122, + 148, 190, 10, 0, 3, 0, 0, 0, 96, 64, 23, 183, 209, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 205, 204, 204, 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 82, 73, 157, 188, 95, 41, 203, 61, 118, 224, + 108, 63, 155, 230, 125, 63, 191, 14, 124, 63, 0, 0, 160, 65, 0, 0, 32, 66, 0, 0, 160, 65, 0, 0, 32, + 66, 0, 0, 32, 66, 0, 0, 160, 65, 0, 0, 32, 66, 0, 0, 160, 65, 8, 0, 2, 0, 236, 81, 133, 66, + 16, 0, 3, 0, 10, 215, 163, 60, 10, 215, 35, 59, 10, 215, 35, 59, 13, 0, 5, 0, 0, 0, 0, 0, 100, + 35, 41, 29, 86, 88, 0, 9, 0, 229, 208, 34, 62, 0, 0, 0, 0, 0, 0, 0, 0, 218, 27, 156, 62, 225, + 11, 67, 64, 0, 0, 160, 64, 0, 0, 0, 0, 0, 0, 0, 0, 94, 75, 72, 189, 93, 254, 159, 64, 66, 62, + 160, 191, 0, 0, 0, 0, 0, 0, 0, 0, 33, 31, 180, 190, 138, 176, 97, 64, 65, 241, 99, 190, 0, 0, 0, + 0, 0, 0, 0, 0, 167, 121, 71, 61, 165, 189, 41, 192, 184, 30, 189, 64, 12, 0, 10, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 13, 5, 11, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, + 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 10, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, + 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 88, 1, 254, + 0, 2, 1, 5, 48, 117, 100, 0, 44, 1, 112, 23, 151, 7, 132, 3, 197, 0, 92, 4, 144, 1, 64, 1, 64, + 1, 144, 1, 48, 117, 48, 117, 48, 117, 48, 117, 100, 0, 100, 0, 100, 0, 48, 117, 48, 117, 48, 117, 100, 0, + 100, 0, 48, 117, 48, 117, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 100, 0, 100, 0, 100, 0, 100, 0, 48, + 117, 48, 117, 48, 117, 100, 0, 100, 0, 100, 0, 48, 117, 48, 117, 100, 0, 100, 0, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, + 1, 44, 1, 44, 1, 44, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 112, 23, 112, 23, 112, 23, 112, 23, + 8, 7, 8, 7, 8, 7, 8, 7, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 112, 23, 112, 23, 112, 23, 112, 23, 255, 255, 255, 255, + 220, 5, 220, 5, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 220, 5, 220, 5, 220, 5, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 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}; 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 new file mode 100644 index 000000000..cdd209ae5 --- /dev/null +++ b/src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h @@ -0,0 +1,3 @@ +#include + +extern const uint8_t bsec_config_iaq[1974]; From f3af3c1c33eb2e34c204f35d2cb5f1a89e93002e Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Thu, 25 May 2023 14:31:49 +0200 Subject: [PATCH 10/15] RP2040: Reverse dmac assignment src.id[0] and src.id[1] that are used for Bluetooth name seem not unique --- src/platform/rp2040/main-rp2040.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/platform/rp2040/main-rp2040.cpp b/src/platform/rp2040/main-rp2040.cpp index af200f961..5e24bf03c 100644 --- a/src/platform/rp2040/main-rp2040.cpp +++ b/src/platform/rp2040/main-rp2040.cpp @@ -21,10 +21,10 @@ void getMacAddr(uint8_t *dmac) { pico_unique_board_id_t src; pico_get_unique_board_id(&src); - dmac[5] = src.id[0]; - dmac[4] = src.id[1]; - dmac[3] = src.id[2]; - dmac[2] = src.id[3]; - dmac[1] = src.id[4]; - dmac[0] = src.id[5]; -} + dmac[5] = src.id[7]; + dmac[4] = src.id[6]; + dmac[3] = src.id[5]; + dmac[2] = src.id[4]; + dmac[1] = src.id[3]; + dmac[0] = src.id[2]; +} \ No newline at end of file From 7475c8647ceebe93bf0ef056373a93183aa8b480 Mon Sep 17 00:00:00 2001 From: code8buster Date: Fri, 26 May 2023 11:16:40 +0000 Subject: [PATCH 11/15] 2.5dB could be a more appropriate attenuation for heltec ADCs (#2511) Co-authored-by: Ben Meadors --- src/Power.cpp | 5 ++++- variants/heltec_v3/variant.h | 1 + variants/heltec_wsl_v3/variant.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Power.cpp b/src/Power.cpp index 685181e3f..2969c3277 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -30,8 +30,11 @@ RTC_NOINIT_ATTR uint64_t RTC_reg_b; #endif // BAT_MEASURE_ADC_UNIT esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); - +#ifndef ADC_ATTENUATION static const adc_atten_t atten = ADC_ATTEN_DB_11; +#else +static const adc_atten_t atten = ADC_ATTENUATION; +#endif #endif // BATTERY_PIN && ARCH_ESP32 #ifdef HAS_PMU diff --git a/variants/heltec_v3/variant.h b/variants/heltec_v3/variant.h index 16ee6d712..d9fc0b4c2 100644 --- a/variants/heltec_v3/variant.h +++ b/variants/heltec_v3/variant.h @@ -9,6 +9,7 @@ #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 USE_SX1262 diff --git a/variants/heltec_wsl_v3/variant.h b/variants/heltec_wsl_v3/variant.h index 38b38e759..0ecc5bea7 100644 --- a/variants/heltec_wsl_v3/variant.h +++ b/variants/heltec_wsl_v3/variant.h @@ -10,6 +10,7 @@ #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 USE_SX1262 From f18b8328a200403702c918d3685b3a4dc8510657 Mon Sep 17 00:00:00 2001 From: thebentern Date: Fri, 26 May 2023 12:50:22 +0000 Subject: [PATCH 12/15] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 32b1f1a72..d24ec7999 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 1 -build = 13 +build = 14 From 1b35cc018f95bf8ad13fae9c2cdf5f412e39d9c0 Mon Sep 17 00:00:00 2001 From: lewishe Date: Sat, 27 May 2023 10:17:37 +0800 Subject: [PATCH 13/15] Fix t-beam-s3-core display not working --- src/Power.cpp | 127 +++++++++++++++++++++++++------------------------- src/sleep.cpp | 26 +++++------ 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 2969c3277..5f7425610 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -606,82 +606,81 @@ bool Power::axpChipInit() } else if (PMU->getChipModel() == XPOWERS_AXP2101) { /*The alternative version of T-Beam 1.1 differs from T-Beam V1.1 in that it uses an AXP2101 power chip*/ -#if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) - // Unuse power channel - PMU->disablePowerOutput(XPOWERS_DCDC2); - PMU->disablePowerOutput(XPOWERS_DCDC3); - PMU->disablePowerOutput(XPOWERS_DCDC4); - PMU->disablePowerOutput(XPOWERS_DCDC5); - PMU->disablePowerOutput(XPOWERS_ALDO1); - PMU->disablePowerOutput(XPOWERS_ALDO4); - PMU->disablePowerOutput(XPOWERS_BLDO1); - PMU->disablePowerOutput(XPOWERS_BLDO2); - PMU->disablePowerOutput(XPOWERS_DLDO1); - PMU->disablePowerOutput(XPOWERS_DLDO2); + if (HW_VENDOR == meshtastic_HardwareModel_TBEAM){ + // Unuse power channel + PMU->disablePowerOutput(XPOWERS_DCDC2); + PMU->disablePowerOutput(XPOWERS_DCDC3); + PMU->disablePowerOutput(XPOWERS_DCDC4); + PMU->disablePowerOutput(XPOWERS_DCDC5); + PMU->disablePowerOutput(XPOWERS_ALDO1); + PMU->disablePowerOutput(XPOWERS_ALDO4); + PMU->disablePowerOutput(XPOWERS_BLDO1); + PMU->disablePowerOutput(XPOWERS_BLDO2); + PMU->disablePowerOutput(XPOWERS_DLDO1); + PMU->disablePowerOutput(XPOWERS_DLDO2); - // GNSS RTC PowerVDD 3300mV - PMU->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300); - PMU->enablePowerOutput(XPOWERS_VBACKUP); + // GNSS RTC PowerVDD 3300mV + PMU->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300); + PMU->enablePowerOutput(XPOWERS_VBACKUP); - // ESP32 VDD 3300mV - // ! No need to set, automatically open , Don't close it - // PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300); - // PMU->setProtectedChannel(XPOWERS_DCDC1); + // ESP32 VDD 3300mV + // ! No need to set, automatically open , Don't close it + // PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300); + // PMU->setProtectedChannel(XPOWERS_DCDC1); - // LoRa VDD 3300mV - PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); - PMU->enablePowerOutput(XPOWERS_ALDO2); + // LoRa VDD 3300mV + PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO2); - // GNSS VDD 3300mV - PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); - PMU->enablePowerOutput(XPOWERS_ALDO3); + // GNSS VDD 3300mV + PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO3); -#elif (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) - // t-beam s3 core - /** - * gnss module power channel - * The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during - * initialization - */ - PMU->setPowerChannelVoltage(XPOWERS_ALDO4, 3300); - PMU->enablePowerOutput(XPOWERS_ALDO4); + }else if(HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE){ + // t-beam s3 core + /** + * gnss module power channel + * The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during + * initialization + */ + PMU->setPowerChannelVoltage(XPOWERS_ALDO4, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO4); - // lora radio power channel - PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); - PMU->enablePowerOutput(XPOWERS_ALDO3); + // lora radio power channel + PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO3); - // m.2 interface - PMU->setPowerChannelVoltage(XPOWERS_DCDC3, 3300); - PMU->enablePowerOutput(XPOWERS_DCDC3); + // m.2 interface + PMU->setPowerChannelVoltage(XPOWERS_DCDC3, 3300); + PMU->enablePowerOutput(XPOWERS_DCDC3); - /** - * ALDO2 cannot be turned off. - * It is a necessary condition for sensor communication. - * It must be turned on to properly access the sensor and screen - * It is also responsible for the power supply of PCF8563 - */ - PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); - PMU->enablePowerOutput(XPOWERS_ALDO2); + /** + * ALDO2 cannot be turned off. + * It is a necessary condition for sensor communication. + * It must be turned on to properly access the sensor and screen + * It is also responsible for the power supply of PCF8563 + */ + PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO2); - // 6-axis , magnetometer ,bme280 , oled screen power channel - PMU->setPowerChannelVoltage(XPOWERS_ALDO1, 3300); - PMU->enablePowerOutput(XPOWERS_ALDO1); + // 6-axis , magnetometer ,bme280 , oled screen power channel + PMU->setPowerChannelVoltage(XPOWERS_ALDO1, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO1); - // sdcard power channle - PMU->setPowerChannelVoltage(XPOWERS_BLDO1, 3300); - PMU->enablePowerOutput(XPOWERS_BLDO1); + // sdcard power channle + PMU->setPowerChannelVoltage(XPOWERS_BLDO1, 3300); + PMU->enablePowerOutput(XPOWERS_BLDO1); - // PMU->setPowerChannelVoltage(XPOWERS_DCDC4, 3300); - // PMU->enablePowerOutput(XPOWERS_DCDC4); + // PMU->setPowerChannelVoltage(XPOWERS_DCDC4, 3300); + // PMU->enablePowerOutput(XPOWERS_DCDC4); - // not use channel - PMU->disablePowerOutput(XPOWERS_DCDC2); // not elicited - PMU->disablePowerOutput(XPOWERS_DCDC5); // not elicited - PMU->disablePowerOutput(XPOWERS_DLDO1); // Invalid power channel, it does not exist - PMU->disablePowerOutput(XPOWERS_DLDO2); // Invalid power channel, it does not exist - PMU->disablePowerOutput(XPOWERS_VBACKUP); - -#endif + // not use channel + PMU->disablePowerOutput(XPOWERS_DCDC2); // not elicited + PMU->disablePowerOutput(XPOWERS_DCDC5); // not elicited + PMU->disablePowerOutput(XPOWERS_DLDO1); // Invalid power channel, it does not exist + PMU->disablePowerOutput(XPOWERS_DLDO2); // Invalid power channel, it does not exist + PMU->disablePowerOutput(XPOWERS_VBACKUP); + } // disable all axp chip interrupt PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ); diff --git a/src/sleep.cpp b/src/sleep.cpp index 6dcf385b7..0b689f38b 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -103,13 +103,13 @@ void setGPSPower(bool on) if (pmu_found && PMU) { uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { -#if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) - // t-beam v1.2 GNSS power channel - on ? PMU->enablePowerOutput(XPOWERS_ALDO3) : PMU->disablePowerOutput(XPOWERS_ALDO3); -#elif (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) - // t-beam-s3-core GNSS power channel - on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4); -#endif + if (HW_VENDOR == meshtastic_HardwareModel_TBEAM){ + // t-beam v1.2 GNSS power channel + on ? PMU->enablePowerOutput(XPOWERS_ALDO3) : PMU->disablePowerOutput(XPOWERS_ALDO3); + }else if(HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE){ + // t-beam-s3-core GNSS power channel + on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4); + } } else if (model == XPOWERS_AXP192) { // t-beam v1.1 GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_LDO3) : PMU->disablePowerOutput(XPOWERS_LDO3); @@ -252,12 +252,12 @@ void doDeepSleep(uint32_t msecToWake) uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { -#if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) - // t-beam v1.2 radio power channel - PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel -#elif (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) - PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel -#endif + if (HW_VENDOR == meshtastic_HardwareModel_TBEAM){ + // t-beam v1.2 radio power channel + PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel + }else if(HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE){ + PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel + } } else if (model == XPOWERS_AXP192) { // t-beam v1.1 radio power channel PMU->disablePowerOutput(XPOWERS_LDO2); // lora radio power channel From fbcd6743fd3adc1b708125fb892f0a3dceb9b22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 27 May 2023 10:03:02 +0200 Subject: [PATCH 14/15] trunk fmt --- src/Power.cpp | 4 ++-- src/sleep.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 5f7425610..d4dd97528 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -606,7 +606,7 @@ bool Power::axpChipInit() } else if (PMU->getChipModel() == XPOWERS_AXP2101) { /*The alternative version of T-Beam 1.1 differs from T-Beam V1.1 in that it uses an AXP2101 power chip*/ - if (HW_VENDOR == meshtastic_HardwareModel_TBEAM){ + if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) { // Unuse power channel PMU->disablePowerOutput(XPOWERS_DCDC2); PMU->disablePowerOutput(XPOWERS_DCDC3); @@ -636,7 +636,7 @@ bool Power::axpChipInit() PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); PMU->enablePowerOutput(XPOWERS_ALDO3); - }else if(HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE){ + } else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) { // t-beam s3 core /** * gnss module power channel diff --git a/src/sleep.cpp b/src/sleep.cpp index 0b689f38b..5331eaf75 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -103,10 +103,10 @@ void setGPSPower(bool on) if (pmu_found && PMU) { uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { - if (HW_VENDOR == meshtastic_HardwareModel_TBEAM){ + if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) { // t-beam v1.2 GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_ALDO3) : PMU->disablePowerOutput(XPOWERS_ALDO3); - }else if(HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE){ + } else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) { // t-beam-s3-core GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4); } @@ -252,10 +252,10 @@ void doDeepSleep(uint32_t msecToWake) uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { - if (HW_VENDOR == meshtastic_HardwareModel_TBEAM){ + if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) { // t-beam v1.2 radio power channel PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel - }else if(HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE){ + } else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) { PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel } } else if (model == XPOWERS_AXP192) { From f3b7f7251c53c725c90a66a9195947984a4bd76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 15 May 2023 17:17:14 +0200 Subject: [PATCH 15/15] Add variant an plumbing for #2468 --- src/graphics/Screen.cpp | 10 ++++---- src/graphics/Screen.h | 2 +- src/graphics/TFTDisplay.cpp | 2 +- src/graphics/images.h | 2 +- variants/picomputer-s3/pins_arduino.h | 37 +++++++++++++++++++++++++++ variants/picomputer-s3/platformio.ini | 27 +++++++++++++++++++ variants/picomputer-s3/variant.h | 24 +++++++++++++++++ 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 variants/picomputer-s3/pins_arduino.h create mode 100644 variants/picomputer-s3/platformio.ini create mode 100644 variants/picomputer-s3/variant.h diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 072a9d14d..9d666d986 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -101,7 +101,7 @@ static uint16_t displayWidth, displayHeight; #define SCREEN_WIDTH displayWidth #define SCREEN_HEIGHT displayHeight -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) // The screen is bigger so use bigger fonts #define FONT_SMALL ArialMT_Plain_16 // Height: 19 #define FONT_MEDIUM ArialMT_Plain_24 // Height: 28 @@ -491,7 +491,7 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no { char usersString[20]; snprintf(usersString, sizeof(usersString), "%d/%d", nodeStatus->getNumOnline(), nodeStatus->getNumTotal()); -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x, y + 3, 8, 8, imgUser); #else display->drawFastImage(x, y, 8, 8, imgUser); @@ -1487,7 +1487,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 #ifdef ARCH_ESP32 if (millis() - storeForwardModule->lastHeartbeat > (storeForwardModule->heartbeatInterval * 1200)) { // no heartbeat, overlap a bit -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgQuestionL1); display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, @@ -1497,7 +1497,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 imgQuestion); #endif } else { -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 16, 8, imgSFL1); display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 16, 8, @@ -1509,7 +1509,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 } #endif } else { -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgInfoL1); display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 992a73285..a9ddc3316 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -380,7 +380,7 @@ class Screen : public concurrency::OSThread SH1106Wire dispdev; #elif defined(USE_SSD1306) SSD1306Wire dispdev; -#elif defined(ST7735_CS) || defined(ILI9341_DRIVER) +#elif defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(USE_ST7789) TFTDisplay dispdev; #elif defined(USE_EINK) EInkDisplay dispdev; diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 8c07a4204..ed4367d42 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -1,6 +1,6 @@ #include "configuration.h" -#if defined(ST7735_CS) || defined(ILI9341_DRIVER) +#if defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(USE_ST7789) #include "SPILock.h" #include "TFTDisplay.h" #include diff --git a/src/graphics/images.h b/src/graphics/images.h index b1818e32c..6b7c91862 100644 --- a/src/graphics/images.h +++ b/src/graphics/images.h @@ -14,7 +14,7 @@ const uint8_t imgUser[] PROGMEM = {0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3 const uint8_t imgPositionEmpty[] PROGMEM = {0x20, 0x30, 0x28, 0x24, 0x42, 0xFF}; const uint8_t imgPositionSolid[] PROGMEM = {0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF}; -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) const uint8_t imgQuestionL1[] PROGMEM = {0xff, 0x01, 0x01, 0x32, 0x7b, 0x49, 0x49, 0x6f, 0x26, 0x01, 0x01, 0xff}; const uint8_t imgQuestionL2[] PROGMEM = {0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f}; const uint8_t imgInfoL1[] PROGMEM = {0xff, 0x01, 0x01, 0x01, 0x1e, 0x7f, 0x1e, 0x01, 0x01, 0x01, 0x01, 0xff}; diff --git a/variants/picomputer-s3/pins_arduino.h b/variants/picomputer-s3/pins_arduino.h new file mode 100644 index 000000000..ee0e34ebf --- /dev/null +++ b/variants/picomputer-s3/pins_arduino.h @@ -0,0 +1,37 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#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; + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 12; +static const uint8_t SCL = 14; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 39; +static const uint8_t SCK = 21; +static const uint8_t MOSI = 38; +static const uint8_t SS = 17; + +//#define SPI_MOSI (11) +//#define SPI_SCK (14) +//#define SPI_MISO (2) +//#define SPI_CS (13) + +//#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/variants/picomputer-s3/platformio.ini b/variants/picomputer-s3/platformio.ini new file mode 100644 index 000000000..0cb58f23c --- /dev/null +++ b/variants/picomputer-s3/platformio.ini @@ -0,0 +1,27 @@ +[env:picomputer_s3] +extends = esp32s3_base +board = bpi_picow_esp32_s3 +board_level = extra +;OpenOCD flash method +;upload_protocol = esp-builtin +;Normal method +upload_protocol = esptool + +build_flags = + ${esp32_base.build_flags} + -D PRIVATE_HW + -I variants/picomputer-s3 + -DST7789_DRIVER + -DUSER_SETUP_LOADED + -DTFT_SDA_READ + -DTFT_MOSI=19 + -DTFT_MISO=-1 + -DTFT_SCLK=18 + -DTFT_CS=21 + -DTFT_DC=16 + -DTFT_BL=20 + -DDISABLE_ALL_LIBRARY_WARNINGS + +lib_deps = + ${esp32_base.lib_deps} + bodmer/TFT_eSPI@^2.4.76 \ No newline at end of file diff --git a/variants/picomputer-s3/variant.h b/variants/picomputer-s3/variant.h new file mode 100644 index 000000000..cbb8fe65e --- /dev/null +++ b/variants/picomputer-s3/variant.h @@ -0,0 +1,24 @@ +#define HAS_GPS 0 +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +#define USE_ST7789 + +#define LED_PIN 48 // If defined we will blink this LED + +#define BUTTON_PIN 0 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +#define USE_RF95 // RFM95/SX127x + +#define RF95_SCK 10 +#define RF95_MISO 12 +#define RF95_MOSI 11 +#define RF95_NSS 13 +#define LORA_RESET RADIOLIB_NC + +// per SX1276_Receive_Interrupt/utilities.h +#define LORA_DIO0 28 +#define LORA_DIO1 RADIOLIB_NC +#define LORA_DIO2 RADIOLIB_NC \ No newline at end of file