ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
vl53l1x.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/gpio.h"
7
8namespace esphome::vl53l1x {
9
10// Values index the distance mode and timing budget tables in the .cpp.
16
18 public:
20
21 void setup() override;
22 void loop() override;
23 void update() override;
24 void dump_config() override;
25
26 void set_enable_pin(GPIOPin *pin) { this->enable_pin_ = pin; }
28 void set_timing_budget(uint16_t budget_ms) { this->budget_ms_ = budget_ms; }
29 // Rate in MCPS, stored as the register's 9.7 fixed point value.
30 void set_signal_rate_limit(float limit_mcps) { this->signal_rate_limit_ = static_cast<uint16_t>(limit_mcps * 128); }
31 void set_offset(int16_t offset_mm) { this->offset_mm_ = offset_mm; }
32 void set_roi(uint8_t width, uint8_t height) {
33 this->roi_width_ = width;
34 this->roi_height_ = height;
35 }
36 void set_roi_center(uint8_t center) { this->roi_center_ = center; }
37
38 protected:
39 void fail_at_default_address_(const LogString *message);
40 bool wait_for_boot_();
41 bool configure_();
42 bool start_ranging_();
43
44 bool write_byte16_(uint16_t reg, uint8_t value);
45 bool write_word16_(uint16_t reg, uint16_t value);
46 bool read_byte16_(uint16_t reg, uint8_t *value);
47 bool read_word16_(uint16_t reg, uint16_t *value);
48
49 // Every instance, so the first setup() can hold all sensors with an enable pin in reset.
50 static VL53L1XSensor *first_sensor; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
51
55 uint16_t budget_ms_{50};
56 uint16_t signal_rate_limit_{128};
57 int16_t offset_mm_{0};
58 uint8_t roi_width_{16};
59 uint8_t roi_height_{16};
60 uint8_t roi_center_{0}; // 0 selects the centre the way the ULD does
62 bool first_result_{true};
63};
64
65} // namespace esphome::vl53l1x
BedjetMode mode
BedJet operating mode.
This class simplifies creating components that periodically check a state.
Definition component.h:519
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:164
Base-class for all sensors.
Definition sensor.h:47
bool write_word16_(uint16_t reg, uint16_t value)
Definition vl53l1x.cpp:419
static VL53L1XSensor * first_sensor
Definition vl53l1x.h:50
void fail_at_default_address_(const LogString *message)
Definition vl53l1x.cpp:271
bool write_byte16_(uint16_t reg, uint8_t value)
Definition vl53l1x.cpp:415
bool read_word16_(uint16_t reg, uint16_t *value)
Definition vl53l1x.cpp:428
void set_enable_pin(GPIOPin *pin)
Definition vl53l1x.h:26
bool read_byte16_(uint16_t reg, uint8_t *value)
Definition vl53l1x.cpp:424
void set_signal_rate_limit(float limit_mcps)
Definition vl53l1x.h:30
void set_distance_mode(DistanceMode mode)
Definition vl53l1x.h:27
void set_timing_budget(uint16_t budget_ms)
Definition vl53l1x.h:28
void set_roi_center(uint8_t center)
Definition vl53l1x.h:36
void set_roi(uint8_t width, uint8_t height)
Definition vl53l1x.h:32
void set_offset(int16_t offset_mm)
Definition vl53l1x.h:31
const LogString * message
Definition component.cpp:35
static void uint32_t