ESPHome
2026.12.0-dev
Loading...
Searching...
No Matches
esphome
components
vl6180x
vl6180x.h
Go to the documentation of this file.
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/gpio.h
"
7
#include "
esphome/core/helpers.h
"
8
9
namespace
esphome::vl6180x
{
10
11
class
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
44
static
SlotList<GPIOPin *, VL6180X_ENABLE_PIN_COUNT>
enable_pins
;
// NOLINT
45
#endif
46
47
GPIOPin
*
enable_pin_
{
nullptr
};
48
float
lux_per_count_
{0.0f};
49
uint16_t
als_integration_time_ms_
{100};
50
uint8_t
als_gain_code_
{6};
51
uint8_t
scaler_
{1};
52
bool
measuring_
{
false
};
53
};
54
55
}
// namespace esphome::vl6180x
esphome::Component::setup
virtual void setup()
Where the component's initialization should happen.
Definition
component.cpp:84
esphome::GPIOPin
Definition
gpio_pin.h:61
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:542
esphome::i2c::I2CDevice
This Class provides the methods to read/write bytes from/to an i2c device.
Definition
i2c.h:144
esphome::vl6180x::VL6180XComponent
Definition
vl6180x.h:11
esphome::vl6180x::VL6180XComponent::als_integration_time_ms_
uint16_t als_integration_time_ms_
Definition
vl6180x.h:49
esphome::vl6180x::VL6180XComponent::start_range_
void start_range_()
Definition
vl6180x.cpp:189
esphome::vl6180x::VL6180XComponent::enable_pins
static SlotList< GPIOPin *, VL6180X_ENABLE_PIN_COUNT > enable_pins
Definition
vl6180x.h:44
esphome::vl6180x::VL6180XComponent::start_als_
void start_als_()
Definition
vl6180x.cpp:232
esphome::vl6180x::VL6180XComponent::lux_per_count_
float lux_per_count_
Definition
vl6180x.h:48
esphome::vl6180x::VL6180XComponent::read_range_
void read_range_()
Definition
vl6180x.cpp:197
esphome::vl6180x::VL6180XComponent::measuring_
bool measuring_
Definition
vl6180x.h:52
esphome::vl6180x::VL6180XComponent::read_als_
void read_als_()
Definition
vl6180x.cpp:241
esphome::vl6180x::VL6180XComponent::scaler_
uint8_t scaler_
Definition
vl6180x.h:51
esphome::vl6180x::VL6180XComponent::als_gain_code_
uint8_t als_gain_code_
Definition
vl6180x.h:50
esphome::vl6180x::VL6180XComponent::enable_pin_
GPIOPin * enable_pin_
Definition
vl6180x.h:47
esphome::vl6180x::VL6180XComponent::init_
bool init_()
Definition
vl6180x.cpp:140
component.h
gpio.h
helpers.h
i2c.h
esphome::vl6180x
Definition
vl6180x.cpp:5
esphome::SlotList
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
sensor.h
Generated by
1.12.0