mirror of
https://github.com/esphome/esphome.git
synced 2025-02-21 20:38:16 +00:00
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
|
#pragma once
|
||
|
|
||
|
#include "esphome/core/component.h"
|
||
|
#include "esphome/components/sensor/sensor.h"
|
||
|
#include "esphome/components/i2c/i2c.h"
|
||
|
|
||
|
namespace esphome {
|
||
|
namespace bmp085 {
|
||
|
|
||
|
class BMP085Component : public PollingComponent, public i2c::I2CDevice {
|
||
|
public:
|
||
|
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||
|
void set_pressure(sensor::Sensor *pressure) { pressure_ = pressure; }
|
||
|
|
||
|
/// Schedule temperature+pressure readings.
|
||
|
void update() override;
|
||
|
/// Setup the sensor and test for a connection.
|
||
|
void setup() override;
|
||
|
void dump_config() override;
|
||
|
|
||
|
float get_setup_priority() const override;
|
||
|
|
||
|
protected:
|
||
|
struct CalibrationData {
|
||
|
int16_t ac1, ac2, ac3;
|
||
|
uint16_t ac4, ac5, ac6;
|
||
|
int16_t b1, b2;
|
||
|
int16_t mb, mc, md;
|
||
|
float temp;
|
||
|
};
|
||
|
|
||
|
/// Internal method to read the temperature from the component after it has been scheduled.
|
||
|
void read_temperature_();
|
||
|
/// Internal method to read the pressure from the component after it has been scheduled.
|
||
|
void read_pressure_();
|
||
|
|
||
|
bool set_mode_(uint8_t mode);
|
||
|
|
||
|
sensor::Sensor *temperature_{nullptr};
|
||
|
sensor::Sensor *pressure_{nullptr};
|
||
|
CalibrationData calibration_;
|
||
|
};
|
||
|
|
||
|
} // namespace bmp085
|
||
|
} // namespace esphome
|