ESPHome  2024.12.2
ltr390.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tuple>
4 #include <vector>
9 
10 namespace esphome {
11 namespace ltr390 {
12 
13 enum LTR390CTRL {
17 };
18 
19 // enums from https://github.com/adafruit/Adafruit_LTR390/
20 // Sensing modes
21 enum LTR390MODE {
24 };
25 
26 // Sensor gain levels
27 enum LTR390GAIN {
29  LTR390_GAIN_3, // Default
33 };
34 
35 // Sensor resolution
43 };
44 
46  public:
47  float get_setup_priority() const override { return setup_priority::DATA; }
48  void setup() override;
49  void dump_config() override;
50  void update() override;
51 
54  void set_als_res_value(LTR390RESOLUTION res) { this->res_als_ = res; }
55  void set_uv_res_value(LTR390RESOLUTION res) { this->res_uv_ = res; }
56  void set_wfac_value(float wfac) { this->wfac_ = wfac; }
57 
58  void set_light_sensor(sensor::Sensor *light_sensor) { this->light_sensor_ = light_sensor; }
59  void set_als_sensor(sensor::Sensor *als_sensor) { this->als_sensor_ = als_sensor; }
60  void set_uvi_sensor(sensor::Sensor *uvi_sensor) { this->uvi_sensor_ = uvi_sensor; }
61  void set_uv_sensor(sensor::Sensor *uv_sensor) { this->uv_sensor_ = uv_sensor; }
62 
63  protected:
65 
66  void read_als_();
67  void read_uvs_();
68 
69  void read_mode_(int mode_index);
70 
71  bool reading_;
72 
73  // a list of modes and corresponding read functions
74  std::vector<std::tuple<LTR390MODE, std::function<void()>>> mode_funcs_;
75 
81  float wfac_;
82 
85 
88 };
89 
90 } // namespace ltr390
91 } // namespace esphome
void set_uv_gain_value(LTR390GAIN gain)
Definition: ltr390.h:53
void read_mode_(int mode_index)
Definition: ltr390.cpp:102
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void set_als_sensor(sensor::Sensor *als_sensor)
Definition: ltr390.h:59
float get_setup_priority() const override
Definition: ltr390.h:47
void set_uvi_sensor(sensor::Sensor *uvi_sensor)
Definition: ltr390.h:60
This class simplifies creating components that periodically check a state.
Definition: component.h:283
AlsGain501 gain
optional< uint32_t > read_sensor_data_(LTR390MODE mode)
Definition: ltr390.cpp:43
void set_uv_res_value(LTR390RESOLUTION res)
Definition: ltr390.h:55
void set_als_gain_value(LTR390GAIN gain)
Definition: ltr390.h:52
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:183
void set_als_res_value(LTR390RESOLUTION res)
Definition: ltr390.h:54
sensor::Sensor * uv_sensor_
Definition: ltr390.h:87
LTR390RESOLUTION res_uv_
Definition: ltr390.h:79
void set_wfac_value(float wfac)
Definition: ltr390.h:56
sensor::Sensor * light_sensor_
Definition: ltr390.h:83
void set_light_sensor(sensor::Sensor *light_sensor)
Definition: ltr390.h:58
void set_uv_sensor(sensor::Sensor *uv_sensor)
Definition: ltr390.h:61
std::vector< std::tuple< LTR390MODE, std::function< void()> > > mode_funcs_
Definition: ltr390.h:74
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
sensor::Sensor * uvi_sensor_
Definition: ltr390.h:86
Base-class for all sensors.
Definition: sensor.h:57
sensor::Sensor * als_sensor_
Definition: ltr390.h:84
LTR390RESOLUTION res_als_
Definition: ltr390.h:78
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133