mirror of
https://github.com/esphome/esphome.git
synced 2024-12-03 12:14:13 +01:00
8e75980ebd
* Cleanup dashboard JS * Add vscode * Save start_mark/end_mark * Updates * Updates * Remove need for cv.nameable It's a bit hacky but removes so much bloat from integrations * Add enum helper * Document APIs, and Improvements * Fixes * Fixes * Update PULL_REQUEST_TEMPLATE.md * Updates * Updates * Updates
45 lines
1.2 KiB
C++
45 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
|