mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-08 05:31:25 +00:00
trunk fmt
This commit is contained in:
parent
d93425fde1
commit
e543b61dd8
@ -268,7 +268,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1); // GET_ID
|
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1); // GET_ID
|
||||||
switch(registerValue) {
|
switch (registerValue) {
|
||||||
case 0x50: // BMP-388 should be 0x50
|
case 0x50: // BMP-388 should be 0x50
|
||||||
LOG_INFO("BMP-388 sensor found at address 0x%x\n", (uint8_t)addr.address);
|
LOG_INFO("BMP-388 sensor found at address 0x%x\n", (uint8_t)addr.address);
|
||||||
type = BMP_3XX;
|
type = BMP_3XX;
|
||||||
@ -279,7 +279,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
type = BMP_280;
|
type = BMP_280;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifndef HAS_NCP5623
|
#ifndef HAS_NCP5623
|
||||||
|
@ -4,15 +4,14 @@
|
|||||||
|
|
||||||
#include "BMP3XXSensor.h"
|
#include "BMP3XXSensor.h"
|
||||||
|
|
||||||
BMP3XXSensor::BMP3XXSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP3XX, "BMP3XX"){}
|
BMP3XXSensor::BMP3XXSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP3XX, "BMP3XX") {}
|
||||||
|
|
||||||
void BMP3XXSensor::setup() {}
|
void BMP3XXSensor::setup() {}
|
||||||
|
|
||||||
int32_t BMP3XXSensor::runOnce()
|
int32_t BMP3XXSensor::runOnce()
|
||||||
{
|
{
|
||||||
LOG_INFO("Init sensor: %s\n", sensorName);
|
LOG_INFO("Init sensor: %s\n", sensorName);
|
||||||
if (!hasSensor())
|
if (!hasSensor()) {
|
||||||
{
|
|
||||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,8 +28,7 @@ int32_t BMP3XXSensor::runOnce()
|
|||||||
bmp3xx->setOutputDataRate(BMP3_ODR_25_HZ);
|
bmp3xx->setOutputDataRate(BMP3_ODR_25_HZ);
|
||||||
|
|
||||||
// take a couple of initial readings to settle the sensor filters
|
// 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();
|
bmp3xx->performReading();
|
||||||
}
|
}
|
||||||
return initI2CSensor();
|
return initI2CSensor();
|
||||||
@ -41,8 +39,7 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement)
|
|||||||
if (bmp3xx == nullptr) {
|
if (bmp3xx == nullptr) {
|
||||||
bmp3xx = BMP3XXSingleton::GetInstance();
|
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();
|
bmp3xx->performReading();
|
||||||
|
|
||||||
measurement->variant.environment_metrics.has_temperature = true;
|
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.barometric_pressure = static_cast<float>(bmp3xx->pressure) / 100.0F;
|
||||||
measurement->variant.environment_metrics.relative_humidity = 0.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);
|
LOG_DEBUG("BMP3XXSensor::getMetrics id: %i temp: %.1f press %.1f\n", measurement->which_variant,
|
||||||
}
|
measurement->variant.environment_metrics.temperature,
|
||||||
else
|
measurement->variant.environment_metrics.barometric_pressure);
|
||||||
{
|
} else {
|
||||||
LOG_DEBUG("BMP3XXSensor::getMetrics id: %i\n", measurement->which_variant);
|
LOG_DEBUG("BMP3XXSensor::getMetrics id: %i\n", measurement->which_variant);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -65,18 +62,17 @@ bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement)
|
|||||||
// Get a singleton wrapper for an Adafruit_bmp3xx
|
// Get a singleton wrapper for an Adafruit_bmp3xx
|
||||||
BMP3XXSingleton *BMP3XXSingleton::GetInstance()
|
BMP3XXSingleton *BMP3XXSingleton::GetInstance()
|
||||||
{
|
{
|
||||||
if (pinstance == nullptr)
|
if (pinstance == nullptr) {
|
||||||
{
|
|
||||||
pinstance = new BMP3XXSingleton();
|
pinstance = new BMP3XXSingleton();
|
||||||
}
|
}
|
||||||
return pinstance;
|
return pinstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
BMP3XXSingleton::BMP3XXSingleton(){}
|
BMP3XXSingleton::BMP3XXSingleton() {}
|
||||||
|
|
||||||
BMP3XXSingleton::~BMP3XXSingleton(){}
|
BMP3XXSingleton::~BMP3XXSingleton() {}
|
||||||
|
|
||||||
BMP3XXSingleton* BMP3XXSingleton::pinstance{nullptr};
|
BMP3XXSingleton *BMP3XXSingleton::pinstance{nullptr};
|
||||||
|
|
||||||
bool BMP3XXSingleton::performReading()
|
bool BMP3XXSingleton::performReading()
|
||||||
{
|
{
|
||||||
|
@ -7,21 +7,21 @@
|
|||||||
|
|
||||||
#define SEAL_LEVEL_HPA 1013.2f
|
#define SEAL_LEVEL_HPA 1013.2f
|
||||||
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <Adafruit_BMP3XX.h>
|
|
||||||
#include "TelemetrySensor.h"
|
#include "TelemetrySensor.h"
|
||||||
|
#include <Adafruit_BMP3XX.h>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
// Singleton wrapper for the Adafruit_BMP3XX class
|
// Singleton wrapper for the Adafruit_BMP3XX class
|
||||||
class BMP3XXSingleton : public Adafruit_BMP3XX
|
class BMP3XXSingleton : public Adafruit_BMP3XX
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static BMP3XXSingleton * pinstance;
|
static BMP3XXSingleton *pinstance;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BMP3XXSingleton();
|
BMP3XXSingleton();
|
||||||
~BMP3XXSingleton();
|
~BMP3XXSingleton();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Create a singleton instance (not thread safe)
|
// Create a singleton instance (not thread safe)
|
||||||
static BMP3XXSingleton *GetInstance();
|
static BMP3XXSingleton *GetInstance();
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ public:
|
|||||||
|
|
||||||
class BMP3XXSensor : public TelemetrySensor
|
class BMP3XXSensor : public TelemetrySensor
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
BMP3XXSingleton *bmp3xx = nullptr;
|
BMP3XXSingleton *bmp3xx = nullptr;
|
||||||
virtual void setup() override;
|
virtual void setup() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BMP3XXSensor();
|
BMP3XXSensor();
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user