Files
firmware/src/modules/Telemetry/Sensor/BMP3XXSensor.h

56 lines
1.3 KiB
C
Raw Normal View History

2024-08-17 16:19:39 +10:00
#include "configuration.h"
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
#ifndef _BMP3XX_SENSOR_H
#define _BMP3XX_SENSOR_H
#define SEAL_LEVEL_HPA 1013.2f
2024-08-31 18:15:33 +10:00
#include <typeinfo>
2024-08-17 16:19:39 +10:00
#include <Adafruit_BMP3XX.h>
2024-08-31 18:15:33 +10:00
#include "TelemetrySensor.h"
2024-08-17 16:19:39 +10:00
2024-08-31 18:15:33 +10:00
// Singleton wrapper for the Adafruit_BMP3XX class
class BMP3XXSingleton : public Adafruit_BMP3XX
2024-08-17 16:19:39 +10:00
{
2024-08-31 18:15:33 +10:00
private:
2024-08-31 19:40:54 +10:00
static BMP3XXSingleton * pinstance;
2024-08-31 18:15:33 +10:00
2024-08-17 16:19:39 +10:00
protected:
2024-08-31 18:15:33 +10:00
BMP3XXSingleton();
~BMP3XXSingleton();
2024-08-17 16:19:39 +10:00
public:
2024-08-31 19:40:54 +10:00
// Create a singleton instance (not thread safe)
2024-08-31 18:15:33 +10:00
static BMP3XXSingleton *GetInstance();
// Singletons should not be cloneable.
BMP3XXSingleton(BMP3XXSingleton &other) = delete;
// Singletons should not be assignable.
void operator=(const BMP3XXSingleton &) = delete;
// Performs a full reading of all sensors in the BMP3XX. Assigns
// the internal temperature, pressure and altitudeAmsl variables
bool performReading();
// Altitude in metres above mean sea level, assigned after calling performReading()
double altitudeAmslMetres = 0.0f;
2024-08-17 16:19:39 +10:00
};
2024-08-31 18:15:33 +10:00
class BMP3XXSensor : public TelemetrySensor
{
protected:
BMP3XXSingleton *bmp3xx = nullptr;
virtual void setup() override;
public:
BMP3XXSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
};
2024-08-17 23:01:43 +10:00
2024-08-17 16:19:39 +10:00
#endif
#endif