From e543b61dd8850e300c193167cb45bcb95da0856b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 2 Sep 2024 10:23:31 +0200 Subject: [PATCH] trunk fmt --- src/detect/ScanI2CTwoWire.cpp | 4 +-- src/modules/Telemetry/Sensor/BMP3XXSensor.cpp | 28 ++++++++----------- src/modules/Telemetry/Sensor/BMP3XXSensor.h | 16 +++++------ 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 76ca42b7f..21e7ca8ac 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -268,7 +268,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) break; default: registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1); // GET_ID - switch(registerValue) { + switch (registerValue) { case 0x50: // BMP-388 should be 0x50 LOG_INFO("BMP-388 sensor found at address 0x%x\n", (uint8_t)addr.address); type = BMP_3XX; @@ -279,7 +279,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) type = BMP_280; break; } - break; + break; } break; #ifndef HAS_NCP5623 diff --git a/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp b/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp index d948cfe38..399610613 100644 --- a/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP3XXSensor.cpp @@ -4,15 +4,14 @@ #include "BMP3XXSensor.h" -BMP3XXSensor::BMP3XXSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP3XX, "BMP3XX"){} +BMP3XXSensor::BMP3XXSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP3XX, "BMP3XX") {} void BMP3XXSensor::setup() {} int32_t BMP3XXSensor::runOnce() { LOG_INFO("Init sensor: %s\n", sensorName); - if (!hasSensor()) - { + if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } @@ -29,8 +28,7 @@ int32_t BMP3XXSensor::runOnce() bmp3xx->setOutputDataRate(BMP3_ODR_25_HZ); // take a couple of initial readings to settle the sensor filters - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { bmp3xx->performReading(); } return initI2CSensor(); @@ -41,8 +39,7 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement) if (bmp3xx == nullptr) { bmp3xx = BMP3XXSingleton::GetInstance(); } - if ((int)measurement->which_variant == meshtastic_Telemetry_environment_metrics_tag) - { + if ((int)measurement->which_variant == meshtastic_Telemetry_environment_metrics_tag) { bmp3xx->performReading(); measurement->variant.environment_metrics.has_temperature = true; @@ -53,10 +50,10 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.barometric_pressure = static_cast(bmp3xx->pressure) / 100.0F; measurement->variant.environment_metrics.relative_humidity = 0.0f; - LOG_DEBUG("BMP3XXSensor::getMetrics id: %i temp: %.1f press %.1f\n", measurement->which_variant, measurement->variant.environment_metrics.temperature, measurement->variant.environment_metrics.barometric_pressure); - } - else - { + LOG_DEBUG("BMP3XXSensor::getMetrics id: %i temp: %.1f press %.1f\n", measurement->which_variant, + measurement->variant.environment_metrics.temperature, + measurement->variant.environment_metrics.barometric_pressure); + } else { LOG_DEBUG("BMP3XXSensor::getMetrics id: %i\n", measurement->which_variant); } return true; @@ -65,18 +62,17 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement) // Get a singleton wrapper for an Adafruit_bmp3xx BMP3XXSingleton *BMP3XXSingleton::GetInstance() { - if (pinstance == nullptr) - { + if (pinstance == nullptr) { pinstance = new BMP3XXSingleton(); } return pinstance; } -BMP3XXSingleton::BMP3XXSingleton(){} +BMP3XXSingleton::BMP3XXSingleton() {} -BMP3XXSingleton::~BMP3XXSingleton(){} +BMP3XXSingleton::~BMP3XXSingleton() {} -BMP3XXSingleton* BMP3XXSingleton::pinstance{nullptr}; +BMP3XXSingleton *BMP3XXSingleton::pinstance{nullptr}; bool BMP3XXSingleton::performReading() { diff --git a/src/modules/Telemetry/Sensor/BMP3XXSensor.h b/src/modules/Telemetry/Sensor/BMP3XXSensor.h index 77b434caa..79939c8d8 100644 --- a/src/modules/Telemetry/Sensor/BMP3XXSensor.h +++ b/src/modules/Telemetry/Sensor/BMP3XXSensor.h @@ -7,21 +7,21 @@ #define SEAL_LEVEL_HPA 1013.2f -#include -#include #include "TelemetrySensor.h" +#include +#include // Singleton wrapper for the Adafruit_BMP3XX class class BMP3XXSingleton : public Adafruit_BMP3XX { -private: - static BMP3XXSingleton * pinstance; + private: + static BMP3XXSingleton *pinstance; -protected: + protected: BMP3XXSingleton(); ~BMP3XXSingleton(); -public: + public: // Create a singleton instance (not thread safe) static BMP3XXSingleton *GetInstance(); @@ -41,11 +41,11 @@ public: class BMP3XXSensor : public TelemetrySensor { -protected: + protected: BMP3XXSingleton *bmp3xx = nullptr; virtual void setup() override; -public: + public: BMP3XXSensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;