mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
e66047e072
* Add BMI160 support * BMI160: use set_timeout for delay * Add support for old compilers Fix "warning: missing terminating ' character" * Increase power-on delay to be more conservative * Add helper for reading little-endian data over i2c * Replace configuration names with globals Note: for testing with external components, you will need to comment out the import & define your own CONF_GYROSCOPE_X, etc, in this file * Improve icons * Fix tests & lint
44 lines
1.6 KiB
C++
44 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/sensor/sensor.h"
|
|
#include "esphome/components/i2c/i2c.h"
|
|
|
|
namespace esphome {
|
|
namespace bmi160 {
|
|
|
|
class BMI160Component : public PollingComponent, public i2c::I2CDevice {
|
|
public:
|
|
void setup() override;
|
|
void dump_config() override;
|
|
|
|
void update() override;
|
|
|
|
float get_setup_priority() const override;
|
|
|
|
void set_accel_x_sensor(sensor::Sensor *accel_x_sensor) { accel_x_sensor_ = accel_x_sensor; }
|
|
void set_accel_y_sensor(sensor::Sensor *accel_y_sensor) { accel_y_sensor_ = accel_y_sensor; }
|
|
void set_accel_z_sensor(sensor::Sensor *accel_z_sensor) { accel_z_sensor_ = accel_z_sensor; }
|
|
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
|
void set_gyro_x_sensor(sensor::Sensor *gyro_x_sensor) { gyro_x_sensor_ = gyro_x_sensor; }
|
|
void set_gyro_y_sensor(sensor::Sensor *gyro_y_sensor) { gyro_y_sensor_ = gyro_y_sensor; }
|
|
void set_gyro_z_sensor(sensor::Sensor *gyro_z_sensor) { gyro_z_sensor_ = gyro_z_sensor; }
|
|
|
|
protected:
|
|
sensor::Sensor *accel_x_sensor_{nullptr};
|
|
sensor::Sensor *accel_y_sensor_{nullptr};
|
|
sensor::Sensor *accel_z_sensor_{nullptr};
|
|
sensor::Sensor *temperature_sensor_{nullptr};
|
|
sensor::Sensor *gyro_x_sensor_{nullptr};
|
|
sensor::Sensor *gyro_y_sensor_{nullptr};
|
|
sensor::Sensor *gyro_z_sensor_{nullptr};
|
|
|
|
void internal_setup_(int stage);
|
|
bool setup_complete_{false};
|
|
|
|
/** reads `len` 16-bit little-endian integers from the given i2c register */
|
|
i2c::ErrorCode read_le_int16_(uint8_t reg, int16_t *value, uint8_t len);
|
|
};
|
|
|
|
} // namespace bmi160
|
|
} // namespace esphome
|