trunk fmt

This commit is contained in:
Thomas Göttgens 2024-09-02 10:23:31 +02:00
parent d93425fde1
commit e543b61dd8
3 changed files with 22 additions and 26 deletions

View File

@ -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

View File

@ -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<float>(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()
{

View File

@ -7,21 +7,21 @@
#define SEAL_LEVEL_HPA 1013.2f
#include <typeinfo>
#include <Adafruit_BMP3XX.h>
#include "TelemetrySensor.h"
#include <Adafruit_BMP3XX.h>
#include <typeinfo>
// 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;