esphome 2024.8.2__py3-none-any.whl → 2024.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. esphome/__main__.py +6 -2
  2. esphome/components/api/api_connection.cpp +53 -0
  3. esphome/components/api/api_connection.h +4 -0
  4. esphome/components/api/api_pb2.cpp +280 -0
  5. esphome/components/api/api_pb2.h +91 -0
  6. esphome/components/api/api_pb2_service.cpp +85 -0
  7. esphome/components/api/api_pb2_service.h +28 -0
  8. esphome/components/async_tcp/__init__.py +3 -3
  9. esphome/components/atm90e26/sensor.py +10 -10
  10. esphome/components/atm90e32/sensor.py +1 -1
  11. esphome/components/bl0906/__init__.py +1 -0
  12. esphome/components/bl0906/bl0906.cpp +238 -0
  13. esphome/components/bl0906/bl0906.h +96 -0
  14. esphome/components/bl0906/const.py +4 -0
  15. esphome/components/bl0906/constants.h +122 -0
  16. esphome/components/bl0906/sensor.py +184 -0
  17. esphome/components/bl0942/__init__.py +1 -1
  18. esphome/components/bl0942/bl0942.cpp +127 -34
  19. esphome/components/bl0942/bl0942.h +87 -3
  20. esphome/components/bl0942/sensor.py +46 -8
  21. esphome/components/ble_client/__init__.py +1 -3
  22. esphome/components/ble_presence/binary_sensor.py +2 -2
  23. esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
  24. esphome/components/bmp280/sensor.py +2 -93
  25. esphome/components/bmp280_base/__init__.py +88 -0
  26. esphome/components/{bmp280/bmp280.cpp → bmp280_base/bmp280_base.cpp} +11 -4
  27. esphome/components/{bmp280/bmp280.h → bmp280_base/bmp280_base.h} +9 -5
  28. esphome/components/bmp280_i2c/__init__.py +0 -0
  29. esphome/components/bmp280_i2c/bmp280_i2c.cpp +27 -0
  30. esphome/components/bmp280_i2c/bmp280_i2c.h +22 -0
  31. esphome/components/bmp280_i2c/sensor.py +22 -0
  32. esphome/components/bmp280_spi/__init__.py +0 -0
  33. esphome/components/bmp280_spi/bmp280_spi.cpp +65 -0
  34. esphome/components/bmp280_spi/bmp280_spi.h +20 -0
  35. esphome/components/bmp280_spi/sensor.py +22 -0
  36. esphome/components/captive_portal/captive_portal.cpp +2 -0
  37. esphome/components/captive_portal/captive_portal.h +3 -1
  38. esphome/components/ch422g/__init__.py +67 -0
  39. esphome/components/ch422g/ch422g.cpp +122 -0
  40. esphome/components/ch422g/ch422g.h +70 -0
  41. esphome/components/debug/debug_esp32.cpp +3 -1
  42. esphome/components/display/__init__.py +5 -4
  43. esphome/components/dsmr/dsmr.cpp +6 -0
  44. esphome/components/dsmr/dsmr.h +6 -0
  45. esphome/components/dsmr/text_sensor.py +7 -2
  46. esphome/components/e131/e131.cpp +2 -0
  47. esphome/components/e131/e131.h +3 -1
  48. esphome/components/e131/e131_addressable_light_effect.cpp +2 -0
  49. esphome/components/e131/e131_addressable_light_effect.h +2 -1
  50. esphome/components/e131/e131_packet.cpp +2 -0
  51. esphome/components/esp32_ble/ble_uuid.cpp +7 -0
  52. esphome/components/esp32_ble/ble_uuid.h +1 -0
  53. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +11 -9
  54. esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +3 -3
  55. esphome/components/esp32_camera/__init__.py +4 -0
  56. esphome/components/esp32_camera/esp32_camera.cpp +9 -1
  57. esphome/components/esp32_camera/esp32_camera.h +3 -0
  58. esphome/components/esp32_can/canbus.py +18 -7
  59. esphome/components/esp32_can/esp32_can.cpp +8 -0
  60. esphome/components/esp32_can/esp32_can.h +4 -0
  61. esphome/components/esp32_rmt_led_strip/led_strip.cpp +14 -2
  62. esphome/components/esp32_rmt_led_strip/led_strip.h +3 -2
  63. esphome/components/esp32_rmt_led_strip/light.py +21 -4
  64. esphome/components/esphome/ota/ota_esphome.cpp +2 -1
  65. esphome/components/esphome/ota/ota_esphome.h +2 -0
  66. esphome/components/font/__init__.py +11 -22
  67. esphome/components/font/font.cpp +3 -2
  68. esphome/components/font/font.h +12 -3
  69. esphome/components/gree/climate.py +2 -1
  70. esphome/components/gree/gree.cpp +54 -3
  71. esphome/components/gree/gree.h +10 -2
  72. esphome/components/gt911/touchscreen/__init__.py +6 -4
  73. esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +17 -0
  74. esphome/components/gt911/touchscreen/gt911_touchscreen.h +2 -0
  75. esphome/components/hmac_md5/__init__.py +2 -0
  76. esphome/components/hmac_md5/hmac_md5.cpp +56 -0
  77. esphome/components/hmac_md5/hmac_md5.h +48 -0
  78. esphome/components/homeassistant/__init__.py +13 -0
  79. esphome/components/homeassistant/switch/__init__.py +15 -2
  80. esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
  81. esphome/components/i2s_audio/__init__.py +88 -9
  82. esphome/components/i2s_audio/i2s_audio.h +20 -2
  83. esphome/components/i2s_audio/media_player/__init__.py +8 -4
  84. esphome/components/i2s_audio/media_player/i2s_audio_media_player.h +1 -1
  85. esphome/components/i2s_audio/microphone/__init__.py +19 -51
  86. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +18 -15
  87. esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +0 -12
  88. esphome/components/i2s_audio/speaker/__init__.py +39 -27
  89. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +49 -37
  90. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +3 -4
  91. esphome/components/ili9xxx/display.py +16 -17
  92. esphome/components/ili9xxx/ili9xxx_display.cpp +1 -1
  93. esphome/components/ili9xxx/ili9xxx_display.h +18 -18
  94. esphome/components/ili9xxx/ili9xxx_init.h +0 -3
  95. esphome/components/improv_serial/improv_serial_component.cpp +2 -1
  96. esphome/components/improv_serial/improv_serial_component.h +2 -1
  97. esphome/components/ledc/ledc_output.cpp +11 -7
  98. esphome/components/libretiny/__init__.py +8 -13
  99. esphome/components/ltr501/__init__.py +1 -0
  100. esphome/components/ltr501/ltr501.cpp +542 -0
  101. esphome/components/ltr501/ltr501.h +184 -0
  102. esphome/components/ltr501/ltr_definitions_501.h +260 -0
  103. esphome/components/ltr501/sensor.py +274 -0
  104. esphome/components/ltr_als_ps/sensor.py +2 -2
  105. esphome/components/lvgl/__init__.py +19 -16
  106. esphome/components/lvgl/automation.py +90 -9
  107. esphome/components/lvgl/defines.py +29 -2
  108. esphome/components/lvgl/gradient.py +61 -0
  109. esphome/components/lvgl/lv_validation.py +45 -27
  110. esphome/components/lvgl/lvcode.py +8 -3
  111. esphome/components/lvgl/lvgl_esphome.cpp +54 -0
  112. esphome/components/lvgl/lvgl_esphome.h +9 -3
  113. esphome/components/lvgl/number/__init__.py +1 -0
  114. esphome/components/lvgl/number/lvgl_number.h +3 -1
  115. esphome/components/lvgl/schemas.py +16 -11
  116. esphome/components/lvgl/select/__init__.py +1 -0
  117. esphome/components/lvgl/select/lvgl_select.h +3 -1
  118. esphome/components/lvgl/switch/__init__.py +2 -1
  119. esphome/components/lvgl/switch/lvgl_switch.h +3 -1
  120. esphome/components/lvgl/text/__init__.py +1 -0
  121. esphome/components/lvgl/text/lvgl_text.h +3 -1
  122. esphome/components/lvgl/trigger.py +3 -2
  123. esphome/components/lvgl/types.py +2 -1
  124. esphome/components/lvgl/widgets/__init__.py +23 -8
  125. esphome/components/lvgl/widgets/arc.py +5 -1
  126. esphome/components/lvgl/widgets/buttonmatrix.py +5 -1
  127. esphome/components/lvgl/widgets/checkbox.py +8 -3
  128. esphome/components/lvgl/widgets/meter.py +8 -1
  129. esphome/components/lvgl/widgets/msgbox.py +26 -15
  130. esphome/components/lvgl/widgets/page.py +51 -7
  131. esphome/components/lvgl/widgets/tileview.py +2 -8
  132. esphome/components/max31856/max31856.cpp +12 -1
  133. esphome/components/max31856/max31856.h +5 -2
  134. esphome/components/max31856/sensor.py +20 -0
  135. esphome/components/mcp9600/sensor.py +2 -2
  136. esphome/components/mdns/__init__.py +6 -6
  137. esphome/components/media_player/media_player.h +16 -0
  138. esphome/components/micro_wake_word/__init__.py +2 -25
  139. esphome/components/microphone/microphone.h +1 -1
  140. esphome/components/mics_4514/mics_4514.cpp +26 -36
  141. esphome/components/modbus_controller/__init__.py +6 -0
  142. esphome/components/modbus_controller/const.py +2 -0
  143. esphome/components/modbus_controller/modbus_controller.cpp +30 -27
  144. esphome/components/modbus_controller/modbus_controller.h +22 -4
  145. esphome/components/network/__init__.py +11 -8
  146. esphome/components/pipsolar/pipsolar.cpp +3 -0
  147. esphome/components/pipsolar/pipsolar.h +1 -0
  148. esphome/components/pipsolar/switch/__init__.py +2 -0
  149. esphome/components/prometheus/prometheus_handler.cpp +2 -0
  150. esphome/components/prometheus/prometheus_handler.h +3 -1
  151. esphome/components/rp2040/__init__.py +7 -8
  152. esphome/components/rpi_dpi_rgb/display.py +20 -17
  153. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +36 -6
  154. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +4 -0
  155. esphome/components/socket/socket.cpp +2 -0
  156. esphome/components/socket/socket.h +2 -0
  157. esphome/components/speaker/speaker.h +1 -1
  158. esphome/components/st7701s/display.py +35 -37
  159. esphome/components/st7701s/st7701s.cpp +11 -6
  160. esphome/components/st7701s/st7701s.h +1 -0
  161. esphome/components/statsd/__init__.py +65 -0
  162. esphome/components/statsd/statsd.cpp +156 -0
  163. esphome/components/statsd/statsd.h +86 -0
  164. esphome/components/tuya/__init__.py +1 -0
  165. esphome/components/tuya/number/__init__.py +39 -2
  166. esphome/components/tuya/number/tuya_number.cpp +58 -2
  167. esphome/components/tuya/number/tuya_number.h +12 -3
  168. esphome/components/udp/__init__.py +158 -0
  169. esphome/components/udp/binary_sensor.py +27 -0
  170. esphome/components/udp/sensor.py +27 -0
  171. esphome/components/udp/udp_component.cpp +616 -0
  172. esphome/components/udp/udp_component.h +158 -0
  173. esphome/components/uponor_smatrix/uponor_smatrix.cpp +4 -6
  174. esphome/components/uponor_smatrix/uponor_smatrix.h +0 -1
  175. esphome/components/veml7700/sensor.py +2 -2
  176. esphome/components/voice_assistant/__init__.py +6 -0
  177. esphome/components/voice_assistant/voice_assistant.cpp +24 -2
  178. esphome/components/voice_assistant/voice_assistant.h +20 -0
  179. esphome/components/web_server/__init__.py +11 -11
  180. esphome/components/web_server/list_entities.cpp +2 -0
  181. esphome/components/web_server/list_entities.h +3 -1
  182. esphome/components/web_server/web_server.cpp +2 -1
  183. esphome/components/web_server/web_server.h +2 -0
  184. esphome/components/web_server_base/web_server_base.cpp +2 -0
  185. esphome/components/web_server_base/web_server_base.h +3 -1
  186. esphome/components/wifi/wifi_component_libretiny.cpp +15 -1
  187. esphome/components/wireguard/__init__.py +9 -6
  188. esphome/components/wireguard/wireguard.cpp +2 -1
  189. esphome/components/wireguard/wireguard.h +3 -1
  190. esphome/config_validation.py +8 -0
  191. esphome/const.py +8 -1
  192. esphome/core/bytebuffer.cpp +117 -84
  193. esphome/core/bytebuffer.h +69 -21
  194. esphome/core/config.py +0 -3
  195. esphome/core/defines.h +2 -0
  196. esphome/core/ring_buffer.cpp +13 -2
  197. esphome/core/ring_buffer.h +56 -0
  198. esphome/external_files.py +5 -3
  199. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/METADATA +1 -1
  200. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/RECORD +204 -169
  201. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/LICENSE +0 -0
  202. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/WHEEL +0 -0
  203. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/entry_points.txt +0 -0
  204. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,184 @@
1
+ #pragma once
2
+
3
+ #include "esphome/components/i2c/i2c.h"
4
+ #include "esphome/components/sensor/sensor.h"
5
+ #include "esphome/core/component.h"
6
+ #include "esphome/core/optional.h"
7
+ #include "esphome/core/automation.h"
8
+
9
+ #include "ltr_definitions_501.h"
10
+
11
+ namespace esphome {
12
+ namespace ltr501 {
13
+
14
+ enum DataAvail : uint8_t { NO_DATA, BAD_DATA, DATA_OK };
15
+
16
+ enum LtrType : uint8_t {
17
+ LTR_TYPE_UNKNOWN = 0,
18
+ LTR_TYPE_ALS_ONLY = 1,
19
+ LTR_TYPE_PS_ONLY = 2,
20
+ LTR_TYPE_ALS_AND_PS = 3,
21
+ };
22
+
23
+ class LTRAlsPs501Component : public PollingComponent, public i2c::I2CDevice {
24
+ public:
25
+ //
26
+ // EspHome framework functions
27
+ //
28
+ float get_setup_priority() const override { return setup_priority::DATA; }
29
+ void setup() override;
30
+ void dump_config() override;
31
+ void update() override;
32
+ void loop() override;
33
+
34
+ // Configuration setters : General
35
+ //
36
+ void set_ltr_type(LtrType type) { this->ltr_type_ = type; }
37
+
38
+ // Configuration setters : ALS
39
+ //
40
+ void set_als_auto_mode(bool enable) { this->automatic_mode_enabled_ = enable; }
41
+ void set_als_gain(AlsGain501 gain) { this->gain_ = gain; }
42
+ void set_als_integration_time(IntegrationTime501 time) { this->integration_time_ = time; }
43
+ void set_als_meas_repeat_rate(MeasurementRepeatRate rate) { this->repeat_rate_ = rate; }
44
+ void set_als_glass_attenuation_factor(float factor) { this->glass_attenuation_factor_ = factor; }
45
+
46
+ // Configuration setters : PS
47
+ //
48
+ void set_ps_high_threshold(uint16_t threshold) { this->ps_threshold_high_ = threshold; }
49
+ void set_ps_low_threshold(uint16_t threshold) { this->ps_threshold_low_ = threshold; }
50
+ void set_ps_cooldown_time_s(uint16_t time) { this->ps_cooldown_time_s_ = time; }
51
+ void set_ps_gain(PsGain501 gain) { this->ps_gain_ = gain; }
52
+
53
+ // Sensors setters
54
+ //
55
+ void set_ambient_light_sensor(sensor::Sensor *sensor) { this->ambient_light_sensor_ = sensor; }
56
+ void set_full_spectrum_counts_sensor(sensor::Sensor *sensor) { this->full_spectrum_counts_sensor_ = sensor; }
57
+ void set_infrared_counts_sensor(sensor::Sensor *sensor) { this->infrared_counts_sensor_ = sensor; }
58
+ void set_actual_gain_sensor(sensor::Sensor *sensor) { this->actual_gain_sensor_ = sensor; }
59
+ void set_actual_integration_time_sensor(sensor::Sensor *sensor) { this->actual_integration_time_sensor_ = sensor; }
60
+ void set_proximity_counts_sensor(sensor::Sensor *sensor) { this->proximity_counts_sensor_ = sensor; }
61
+
62
+ protected:
63
+ //
64
+ // Internal state machine, used to split all the actions into
65
+ // small steps in loop() to make sure we are not blocking execution
66
+ //
67
+ enum class State : uint8_t {
68
+ NOT_INITIALIZED,
69
+ DELAYED_SETUP,
70
+ IDLE,
71
+ WAITING_FOR_DATA,
72
+ COLLECTING_DATA_AUTO,
73
+ DATA_COLLECTED,
74
+ ADJUSTMENT_IN_PROGRESS,
75
+ READY_TO_PUBLISH,
76
+ KEEP_PUBLISHING
77
+ } state_{State::NOT_INITIALIZED};
78
+
79
+ LtrType ltr_type_{LtrType::LTR_TYPE_ALS_ONLY};
80
+
81
+ //
82
+ // Current measurements data
83
+ //
84
+ struct AlsReadings {
85
+ uint16_t ch0{0};
86
+ uint16_t ch1{0};
87
+ AlsGain501 gain{AlsGain501::GAIN_1};
88
+ IntegrationTime501 integration_time{IntegrationTime501::INTEGRATION_TIME_100MS};
89
+ float lux{0.0f};
90
+ uint8_t number_of_adjustments{0};
91
+ } als_readings_;
92
+ uint16_t ps_readings_{0xfffe};
93
+
94
+ inline bool is_als_() const {
95
+ return this->ltr_type_ == LtrType::LTR_TYPE_ALS_ONLY || this->ltr_type_ == LtrType::LTR_TYPE_ALS_AND_PS;
96
+ }
97
+ inline bool is_ps_() const {
98
+ return this->ltr_type_ == LtrType::LTR_TYPE_PS_ONLY || this->ltr_type_ == LtrType::LTR_TYPE_ALS_AND_PS;
99
+ }
100
+
101
+ //
102
+ // Device interaction and data manipulation
103
+ //
104
+ bool check_part_number_();
105
+
106
+ void configure_reset_();
107
+ void configure_als_();
108
+ void configure_integration_time_(IntegrationTime501 time);
109
+ void configure_gain_(AlsGain501 gain);
110
+ DataAvail is_als_data_ready_(AlsReadings &data);
111
+ void read_sensor_data_(AlsReadings &data);
112
+ bool are_adjustments_required_(AlsReadings &data);
113
+ void apply_lux_calculation_(AlsReadings &data);
114
+ void publish_data_part_1_(AlsReadings &data);
115
+ void publish_data_part_2_(AlsReadings &data);
116
+
117
+ void configure_ps_();
118
+ uint16_t read_ps_data_();
119
+ void check_and_trigger_ps_();
120
+
121
+ //
122
+ // Component configuration
123
+ //
124
+ bool automatic_mode_enabled_{false};
125
+ AlsGain501 gain_{AlsGain501::GAIN_1};
126
+ IntegrationTime501 integration_time_{IntegrationTime501::INTEGRATION_TIME_100MS};
127
+ MeasurementRepeatRate repeat_rate_{MeasurementRepeatRate::REPEAT_RATE_500MS};
128
+ float glass_attenuation_factor_{1.0};
129
+
130
+ uint16_t ps_cooldown_time_s_{5};
131
+ PsGain501 ps_gain_{PsGain501::PS_GAIN_1};
132
+ uint16_t ps_threshold_high_{0xffff};
133
+ uint16_t ps_threshold_low_{0x0000};
134
+
135
+ //
136
+ // Sensors for publishing data
137
+ //
138
+ sensor::Sensor *infrared_counts_sensor_{nullptr}; // direct reading CH1, infrared only
139
+ sensor::Sensor *full_spectrum_counts_sensor_{nullptr}; // direct reading CH0, infrared + visible light
140
+ sensor::Sensor *ambient_light_sensor_{nullptr}; // calculated lux
141
+ sensor::Sensor *actual_gain_sensor_{nullptr}; // actual gain of reading
142
+ sensor::Sensor *actual_integration_time_sensor_{nullptr}; // actual integration time
143
+ sensor::Sensor *proximity_counts_sensor_{nullptr}; // proximity sensor
144
+
145
+ bool is_any_als_sensor_enabled_() const {
146
+ return this->ambient_light_sensor_ != nullptr || this->full_spectrum_counts_sensor_ != nullptr ||
147
+ this->infrared_counts_sensor_ != nullptr || this->actual_gain_sensor_ != nullptr ||
148
+ this->actual_integration_time_sensor_ != nullptr;
149
+ }
150
+ bool is_any_ps_sensor_enabled_() const { return this->proximity_counts_sensor_ != nullptr; }
151
+
152
+ //
153
+ // Trigger section for the automations
154
+ //
155
+ friend class LTRPsHighTrigger;
156
+ friend class LTRPsLowTrigger;
157
+
158
+ CallbackManager<void()> on_ps_high_trigger_callback_;
159
+ CallbackManager<void()> on_ps_low_trigger_callback_;
160
+
161
+ void add_on_ps_high_trigger_callback_(std::function<void()> callback) {
162
+ this->on_ps_high_trigger_callback_.add(std::move(callback));
163
+ }
164
+
165
+ void add_on_ps_low_trigger_callback_(std::function<void()> callback) {
166
+ this->on_ps_low_trigger_callback_.add(std::move(callback));
167
+ }
168
+ };
169
+
170
+ class LTRPsHighTrigger : public Trigger<> {
171
+ public:
172
+ explicit LTRPsHighTrigger(LTRAlsPs501Component *parent) {
173
+ parent->add_on_ps_high_trigger_callback_([this]() { this->trigger(); });
174
+ }
175
+ };
176
+
177
+ class LTRPsLowTrigger : public Trigger<> {
178
+ public:
179
+ explicit LTRPsLowTrigger(LTRAlsPs501Component *parent) {
180
+ parent->add_on_ps_low_trigger_callback_([this]() { this->trigger(); });
181
+ }
182
+ };
183
+ } // namespace ltr501
184
+ } // namespace esphome
@@ -0,0 +1,260 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+
5
+ namespace esphome {
6
+ namespace ltr501 {
7
+
8
+ enum class CommandRegisters : uint8_t {
9
+ ALS_CONTR = 0x80, // ALS operation mode control and SW reset
10
+ PS_CONTR = 0x81, // PS operation mode control
11
+ PS_LED = 0x82, // PS LED pulse frequency control
12
+ PS_N_PULSES = 0x83, // PS number of pulses control
13
+ PS_MEAS_RATE = 0x84, // PS measurement rate in active mode
14
+ MEAS_RATE = 0x85, // ALS measurement rate in active mode
15
+ PART_ID = 0x86, // Part Number ID and Revision ID
16
+ MANUFAC_ID = 0x87, // Manufacturer ID
17
+ ALS_DATA_CH1_0 = 0x88, // ALS measurement CH1 data, lower byte - infrared only
18
+ ALS_DATA_CH1_1 = 0x89, // ALS measurement CH1 data, upper byte - infrared only
19
+ ALS_DATA_CH0_0 = 0x8A, // ALS measurement CH0 data, lower byte - visible + infrared
20
+ ALS_DATA_CH0_1 = 0x8B, // ALS measurement CH0 data, upper byte - visible + infrared
21
+ ALS_PS_STATUS = 0x8C, // ALS PS new data status
22
+ PS_DATA_0 = 0x8D, // PS measurement data, lower byte
23
+ PS_DATA_1 = 0x8E, // PS measurement data, upper byte
24
+ ALS_PS_INTERRUPT = 0x8F, // Interrupt status
25
+ PS_THRES_UP_0 = 0x90, // PS interrupt upper threshold, lower byte
26
+ PS_THRES_UP_1 = 0x91, // PS interrupt upper threshold, upper byte
27
+ PS_THRES_LOW_0 = 0x92, // PS interrupt lower threshold, lower byte
28
+ PS_THRES_LOW_1 = 0x93, // PS interrupt lower threshold, upper byte
29
+ PS_OFFSET_1 = 0x94, // PS offset, upper byte
30
+ PS_OFFSET_0 = 0x95, // PS offset, lower byte
31
+ // 0x96 - reserved
32
+ ALS_THRES_UP_0 = 0x97, // ALS interrupt upper threshold, lower byte
33
+ ALS_THRES_UP_1 = 0x98, // ALS interrupt upper threshold, upper byte
34
+ ALS_THRES_LOW_0 = 0x99, // ALS interrupt lower threshold, lower byte
35
+ ALS_THRES_LOW_1 = 0x9A, // ALS interrupt lower threshold, upper byte
36
+ // 0x9B - reserved
37
+ // 0x9C - reserved
38
+ // 0x9D - reserved
39
+ INTERRUPT_PERSIST = 0x9E // Interrupt persistence filter
40
+ };
41
+
42
+ // ALS Sensor gain levels
43
+ enum AlsGain501 : uint8_t {
44
+ GAIN_1 = 0, // GAIN_RANGE_2 // default
45
+ GAIN_150 = 1, // GAIN_RANGE_1
46
+ };
47
+ static const uint8_t GAINS_COUNT = 2;
48
+
49
+ // ALS Sensor integration times
50
+ enum IntegrationTime501 : uint8_t {
51
+ INTEGRATION_TIME_100MS = 0, // default
52
+ INTEGRATION_TIME_50MS = 1, // only in Dynamic GAIN_RANGE_2
53
+ INTEGRATION_TIME_200MS = 2, // only in Dynamic GAIN_RANGE_1
54
+ INTEGRATION_TIME_400MS = 3, // only in Dynamic GAIN_RANGE_1
55
+ };
56
+ static const uint8_t TIMES_COUNT = 4;
57
+
58
+ // ALS Sensor measurement repeat rate
59
+ enum MeasurementRepeatRate {
60
+ REPEAT_RATE_50MS = 0,
61
+ REPEAT_RATE_100MS = 1,
62
+ REPEAT_RATE_200MS = 2,
63
+ REPEAT_RATE_500MS = 3, // default
64
+ REPEAT_RATE_1000MS = 4,
65
+ REPEAT_RATE_2000MS = 5
66
+ };
67
+
68
+ // PS Sensor gain levels
69
+ enum PsGain501 : uint8_t {
70
+ PS_GAIN_1 = 0, // default
71
+ PS_GAIN_4 = 1,
72
+ PS_GAIN_8 = 2,
73
+ PS_GAIN_16 = 3,
74
+ };
75
+
76
+ // LED Pulse Modulation Frequency
77
+ enum PsLedFreq : uint8_t {
78
+ PS_LED_FREQ_30KHZ = 0,
79
+ PS_LED_FREQ_40KHZ = 1,
80
+ PS_LED_FREQ_50KHZ = 2,
81
+ PS_LED_FREQ_60KHZ = 3, // default
82
+ PS_LED_FREQ_70KHZ = 4,
83
+ PS_LED_FREQ_80KHZ = 5,
84
+ PS_LED_FREQ_90KHZ = 6,
85
+ PS_LED_FREQ_100KHZ = 7,
86
+ };
87
+
88
+ // LED current duty
89
+ enum PsLedDuty : uint8_t {
90
+ PS_LED_DUTY_25 = 0,
91
+ PS_LED_DUTY_50 = 1, // default
92
+ PS_LED_DUTY_75 = 2,
93
+ PS_LED_DUTY_100 = 3,
94
+ };
95
+
96
+ // LED pulsed current level
97
+ enum PsLedCurrent : uint8_t {
98
+ PS_LED_CURRENT_5MA = 0,
99
+ PS_LED_CURRENT_10MA = 1,
100
+ PS_LED_CURRENT_20MA = 2,
101
+ PS_LED_CURRENT_50MA = 3, // default
102
+ PS_LED_CURRENT_100MA = 4,
103
+ PS_LED_CURRENT_100MA1 = 5,
104
+ PS_LED_CURRENT_100MA2 = 6,
105
+ PS_LED_CURRENT_100MA3 = 7,
106
+ };
107
+
108
+ // PS measurement rate
109
+ enum PsMeasurementRate : uint8_t {
110
+ PS_MEAS_RATE_50MS = 0,
111
+ PS_MEAS_RATE_70MS = 1,
112
+ PS_MEAS_RATE_100MS = 2, // default
113
+ PS_MEAS_RATE_200MS = 3,
114
+ PS_MEAS_RATE_500MS = 4,
115
+ PS_MEAS_RATE_1000MS = 5,
116
+ PS_MEAS_RATE_2000MS = 6,
117
+ PS_MEAS_RATE_2000MS1 = 7,
118
+ };
119
+
120
+ //
121
+ // ALS_CONTR Register (0x80)
122
+ //
123
+ union AlsControlRegister501 {
124
+ uint8_t raw;
125
+ struct {
126
+ bool asl_mode_xxx : 1;
127
+ bool als_mode_active : 1;
128
+ bool sw_reset : 1;
129
+ AlsGain501 gain : 1;
130
+ uint8_t reserved : 4;
131
+ } __attribute__((packed));
132
+ };
133
+
134
+ //
135
+ // PS_CONTR Register (0x81)
136
+ //
137
+ union PsControlRegister501 {
138
+ uint8_t raw;
139
+ struct {
140
+ bool ps_mode_xxx : 1;
141
+ bool ps_mode_active : 1;
142
+ PsGain501 ps_gain : 2;
143
+ bool reserved_4 : 1;
144
+ bool reserved_5 : 1;
145
+ bool reserved_6 : 1;
146
+ bool reserved_7 : 1;
147
+ } __attribute__((packed));
148
+ };
149
+
150
+ //
151
+ // PS_LED Register (0x82)
152
+ //
153
+ union PsLedRegister {
154
+ uint8_t raw;
155
+ struct {
156
+ PsLedCurrent ps_led_current : 3;
157
+ PsLedDuty ps_led_duty : 2;
158
+ PsLedFreq ps_led_freq : 3;
159
+ } __attribute__((packed));
160
+ };
161
+
162
+ //
163
+ // PS_N_PULSES Register (0x83)
164
+ //
165
+ union PsNPulsesRegister501 {
166
+ uint8_t raw;
167
+ uint8_t number_of_pulses;
168
+ };
169
+
170
+ //
171
+ // PS_MEAS_RATE Register (0x84)
172
+ //
173
+ union PsMeasurementRateRegister {
174
+ uint8_t raw;
175
+ struct {
176
+ PsMeasurementRate ps_measurement_rate : 4;
177
+ uint8_t reserved : 4;
178
+ } __attribute__((packed));
179
+ };
180
+
181
+ //
182
+ // ALS_MEAS_RATE Register (0x85)
183
+ //
184
+ union MeasurementRateRegister501 {
185
+ uint8_t raw;
186
+ struct {
187
+ MeasurementRepeatRate measurement_repeat_rate : 3;
188
+ IntegrationTime501 integration_time : 2;
189
+ bool reserved_5 : 1;
190
+ bool reserved_6 : 1;
191
+ bool reserved_7 : 1;
192
+ } __attribute__((packed));
193
+ };
194
+
195
+ //
196
+ // PART_ID Register (0x86) (Read Only)
197
+ //
198
+ union PartIdRegister {
199
+ uint8_t raw;
200
+ struct {
201
+ uint8_t part_number_id : 4;
202
+ uint8_t revision_id : 4;
203
+ } __attribute__((packed));
204
+ };
205
+
206
+ //
207
+ // ALS_PS_STATUS Register (0x8C) (Read Only)
208
+ //
209
+ union AlsPsStatusRegister {
210
+ uint8_t raw;
211
+ struct {
212
+ bool ps_new_data : 1; // 0 - old data, 1 - new data
213
+ bool ps_interrupt : 1; // 0 - interrupt signal not active, 1 - interrupt signal active
214
+ bool als_new_data : 1; // 0 - old data, 1 - new data
215
+ bool als_interrupt : 1; // 0 - interrupt signal not active, 1 - interrupt signal active
216
+ AlsGain501 gain : 1; // current ALS gain
217
+ bool reserved_5 : 1;
218
+ bool reserved_6 : 1;
219
+ bool reserved_7 : 1;
220
+ } __attribute__((packed));
221
+ };
222
+
223
+ //
224
+ // PS_DATA_1 Register (0x8E) (Read Only)
225
+ //
226
+ union PsData1Register {
227
+ uint8_t raw;
228
+ struct {
229
+ uint8_t ps_data_high : 3;
230
+ uint8_t reserved : 4;
231
+ bool ps_saturation_flag : 1;
232
+ } __attribute__((packed));
233
+ };
234
+
235
+ //
236
+ // INTERRUPT Register (0x8F) (Read Only)
237
+ //
238
+ union InterruptRegister {
239
+ uint8_t raw;
240
+ struct {
241
+ bool ps_interrupt : 1;
242
+ bool als_interrupt : 1;
243
+ bool interrupt_polarity : 1; // 0 - active low (default), 1 - active high
244
+ uint8_t reserved : 5;
245
+ } __attribute__((packed));
246
+ };
247
+
248
+ //
249
+ // INTERRUPT_PERSIST Register (0x9E)
250
+ //
251
+ union InterruptPersistRegister {
252
+ uint8_t raw;
253
+ struct {
254
+ uint8_t als_persist : 4; // 0 - every ALS cycle, 1 - every 2 ALS cycles, ... 15 - every 16 ALS cycles
255
+ uint8_t ps_persist : 4; // 0 - every PS cycle, 1 - every 2 PS cycles, ... 15 - every 16 PS cycles
256
+ } __attribute__((packed));
257
+ };
258
+
259
+ } // namespace ltr501
260
+ } // namespace esphome