ESPHome  2024.9.0
apds9306.h
Go to the documentation of this file.
1 // Based on this datasheet:
2 // https://www.mouser.ca/datasheet/2/678/AVGO_S_A0002854364_1-2574547.pdf
3 
4 #pragma once
5 
9 
10 namespace esphome {
11 namespace apds9306 {
12 
13 enum MeasurementBitWidth : uint8_t {
20 };
21 static const uint8_t MEASUREMENT_BIT_WIDTH_VALUES[] = {20, 19, 18, 17, 16, 13};
22 
23 enum MeasurementRate : uint8_t {
31 };
32 static const uint16_t MEASUREMENT_RATE_VALUES[] = {25, 50, 100, 200, 500, 1000, 2000};
33 
34 enum AmbientLightGain : uint8_t {
40 };
41 static const uint8_t AMBIENT_LIGHT_GAIN_VALUES[] = {1, 3, 6, 9, 18};
42 
43 class APDS9306 : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
44  public:
45  void setup() override;
46  float get_setup_priority() const override { return setup_priority::BUS; }
47  void dump_config() override;
48  void update() override;
49  void set_bit_width(MeasurementBitWidth bit_width) { this->bit_width_ = bit_width; }
50  void set_measurement_rate(MeasurementRate measurement_rate) { this->measurement_rate_ = measurement_rate; }
52 
53  protected:
54  enum ErrorCode {
55  NONE = 0,
58  } error_code_{NONE};
59 
63 };
64 
65 } // namespace apds9306
66 } // namespace esphome
MeasurementBitWidth bit_width_
Definition: apds9306.h:60
float get_setup_priority() const override
Definition: apds9306.h:46
void set_ambient_light_gain(AmbientLightGain gain)
Definition: apds9306.h:51
void set_bit_width(MeasurementBitWidth bit_width)
Definition: apds9306.h:49
enum esphome::apds9306::APDS9306::ErrorCode NONE
This class simplifies creating components that periodically check a state.
Definition: component.h:283
MeasurementRate measurement_rate_
Definition: apds9306.h:61
AlsGain501 gain
void set_measurement_rate(MeasurementRate measurement_rate)
Definition: apds9306.h:50
const float BUS
For communication buses like i2c/spi.
Definition: component.cpp:16
void setup() override
Definition: apds9306.cpp:56
void dump_config() override
Definition: apds9306.cpp:93
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void update() override
Definition: apds9306.cpp:118
AmbientLightGain gain_
Definition: apds9306.h:62
Base-class for all sensors.
Definition: sensor.h:57
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133