ESPHome  2024.6.6
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 
53  void set_res_value(LTR390RESOLUTION res) { this->res_ = res; }
54  void set_wfac_value(float wfac) { this->wfac_ = wfac; }
55 
56  void set_light_sensor(sensor::Sensor *light_sensor) { this->light_sensor_ = light_sensor; }
57  void set_als_sensor(sensor::Sensor *als_sensor) { this->als_sensor_ = als_sensor; }
58  void set_uvi_sensor(sensor::Sensor *uvi_sensor) { this->uvi_sensor_ = uvi_sensor; }
59  void set_uv_sensor(sensor::Sensor *uv_sensor) { this->uv_sensor_ = uv_sensor; }
60 
61  protected:
63 
64  void read_als_();
65  void read_uvs_();
66 
67  void read_mode_(int mode_index);
68 
69  bool reading_;
70 
71  // a list of modes and corresponding read functions
72  std::vector<std::tuple<LTR390MODE, std::function<void()>>> mode_funcs_;
73 
76  float sensitivity_;
77  float wfac_;
78 
81 
84 };
85 
86 } // namespace ltr390
87 } // namespace esphome
void read_mode_(int mode_index)
Definition: ltr390.cpp:101
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:57
void set_res_value(LTR390RESOLUTION res)
Definition: ltr390.h:53
float get_setup_priority() const override
Definition: ltr390.h:47
void set_uvi_sensor(sensor::Sensor *uvi_sensor)
Definition: ltr390.h:58
This class simplifies creating components that periodically check a state.
Definition: component.h:283
optional< uint32_t > read_sensor_data_(LTR390MODE mode)
Definition: ltr390.cpp:42
AlsGain gain
void set_gain_value(LTR390GAIN gain)
Definition: ltr390.h:52
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:181
sensor::Sensor * uv_sensor_
Definition: ltr390.h:83
void set_wfac_value(float wfac)
Definition: ltr390.h:54
sensor::Sensor * light_sensor_
Definition: ltr390.h:79
void set_light_sensor(sensor::Sensor *light_sensor)
Definition: ltr390.h:56
LTR390RESOLUTION res_
Definition: ltr390.h:75
void set_uv_sensor(sensor::Sensor *uv_sensor)
Definition: ltr390.h:59
std::vector< std::tuple< LTR390MODE, std::function< void()> > > mode_funcs_
Definition: ltr390.h:72
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
sensor::Sensor * uvi_sensor_
Definition: ltr390.h:82
Base-class for all sensors.
Definition: sensor.h:57
sensor::Sensor * als_sensor_
Definition: ltr390.h:80
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133