ESPHome  2024.12.2
qmc5883l.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace qmc5883l {
9 
15 };
16 
20 };
21 
27 };
28 
30  public:
31  void setup() override;
32  void dump_config() override;
33  float get_setup_priority() const override;
34  void update() override;
35 
36  void set_datarate(QMC5883LDatarate datarate) { datarate_ = datarate; }
37  void set_range(QMC5883LRange range) { range_ = range; }
38  void set_oversampling(QMC5883LOversampling oversampling) { oversampling_ = oversampling; }
39  void set_x_sensor(sensor::Sensor *x_sensor) { x_sensor_ = x_sensor; }
40  void set_y_sensor(sensor::Sensor *y_sensor) { y_sensor_ = y_sensor; }
41  void set_z_sensor(sensor::Sensor *z_sensor) { z_sensor_ = z_sensor; }
42  void set_heading_sensor(sensor::Sensor *heading_sensor) { heading_sensor_ = heading_sensor; }
43  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
44 
45  protected:
54  enum ErrorCode {
55  NONE = 0,
57  } error_code_;
58  i2c::ErrorCode read_bytes_16_le_(uint8_t a_register, uint16_t *data, uint8_t len = 1);
60 };
61 
62 } // namespace qmc5883l
63 } // namespace esphome
void set_range(QMC5883LRange range)
Definition: qmc5883l.h:37
void set_datarate(QMC5883LDatarate datarate)
Definition: qmc5883l.h:36
sensor::Sensor * heading_sensor_
Definition: qmc5883l.h:52
Helper class to request loop() to be called as fast as possible.
Definition: helpers.h:622
void set_oversampling(QMC5883LOversampling oversampling)
Definition: qmc5883l.h:38
This class simplifies creating components that periodically check a state.
Definition: component.h:283
HighFrequencyLoopRequester high_freq_
Definition: qmc5883l.h:59
enum esphome::qmc5883l::QMC5883LComponent::ErrorCode error_code_
float get_setup_priority() const override
Definition: qmc5883l.cpp:82
i2c::ErrorCode read_bytes_16_le_(uint8_t a_register, uint16_t *data, uint8_t len=1)
Definition: qmc5883l.cpp:165
void set_z_sensor(sensor::Sensor *z_sensor)
Definition: qmc5883l.h:41
sensor::Sensor * temperature_sensor_
Definition: qmc5883l.h:53
void set_x_sensor(sensor::Sensor *x_sensor)
Definition: qmc5883l.h:39
std::string size_t len
Definition: helpers.h:293
void set_heading_sensor(sensor::Sensor *heading_sensor)
Definition: qmc5883l.h:42
void set_y_sensor(sensor::Sensor *y_sensor)
Definition: qmc5883l.h:40
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Definition: i2c_bus.h:11
Base-class for all sensors.
Definition: sensor.h:57
QMC5883LOversampling oversampling_
Definition: qmc5883l.h:48
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition: qmc5883l.h:43
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133