ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
vl6180x.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/gpio.h"
8
9namespace esphome::vl6180x {
10
11class VL6180XComponent final : public PollingComponent, public i2c::I2CDevice {
12 SUB_SENSOR(distance)
13 SUB_SENSOR(illuminance)
14
15 public:
16 void setup() override;
17 void update() override;
18 void dump_config() override;
19
20 void set_enable_pin(GPIOPin *pin) { this->enable_pin_ = pin; }
21 void set_scaler(uint8_t scaler) { this->scaler_ = scaler; }
25 void set_als(uint8_t gain_code, uint16_t integration_time_ms, float lux_per_count) {
26 this->als_gain_code_ = gain_code;
27 this->als_integration_time_ms_ = integration_time_ms;
28 this->lux_per_count_ = lux_per_count;
29 }
30
31#ifdef VL6180X_ENABLE_PIN_COUNT
33 static void register_enable_pin(GPIOPin *pin) { enable_pins.push_back(pin); }
34#endif
35
36 protected:
37 bool init_();
38 void start_range_();
39 void read_range_();
40 void start_als_();
41 void read_als_();
42
43#ifdef VL6180X_ENABLE_PIN_COUNT
45#endif
46
48 float lux_per_count_{0.0f};
50 uint8_t als_gain_code_{6};
51 uint8_t scaler_{1};
52 bool measuring_{false};
53};
54
55} // namespace esphome::vl6180x
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:542
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
static SlotList< GPIOPin *, VL6180X_ENABLE_PIN_COUNT > enable_pins
Definition vl6180x.h:44
std::conditional_t< N==0, EmptyList< T >, StaticVector< T, N > > SlotList
StaticVector<T, N>, or EmptyList<T> when N is 0.
Definition helpers.h:444