DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
vl53l0x.h File Reference

ST VL53L0X / VL53L1X optical time-of-flight ranging codec (DETWS_ENABLE_VL53L0X). More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define VL53L0X_REG_SYSRANGE_START   0x00
 
#define VL53L0X_REG_SYSTEM_INTERRUPT_CLEAR   0x0B
 
#define VL53L0X_REG_RESULT_INTERRUPT_STATUS   0x13
 
#define VL53L0X_REG_RESULT_RANGE_STATUS   0x14
 
#define VL53L0X_REG_IDENTIFICATION_MODEL_ID   0xC0
 
#define VL53L0X_MODEL_ID   0xEE
 IDENTIFICATION_MODEL_ID for the VL53L0X.
 
#define VL53L0X_RANGE_VALID   11
 DeviceRangeStatus value that means a valid measurement.
 

Functions

uint16_t vl53l0x_range_mm (uint8_t hi, uint8_t lo)
 Combine the range high/low bytes (RESULT_RANGE_STATUS+10 / +11) into millimeters.
 
bool vl53l0x_data_ready (uint8_t interrupt_status)
 True if a new measurement is ready (any of the low 3 interrupt-status bits set).
 
uint8_t vl53l0x_range_status (uint8_t range_status_reg)
 The DeviceRangeStatus field (bits 6:3) of the RESULT_RANGE_STATUS register.
 
bool vl53l0x_range_valid (uint8_t range_status_reg)
 True if the range-status field reports a valid measurement (== VL53L0X_RANGE_VALID).
 
bool vl53l0x_begin (uint8_t addr)
 Verify the model id and start continuous back-to-back ranging at addr.
 
bool vl53l0x_read_mm (uint16_t *mm)
 If a measurement is ready, read the distance into mm and clear the interrupt.
 

Detailed Description

ST VL53L0X / VL53L1X optical time-of-flight ranging codec (DETWS_ENABLE_VL53L0X).

The VL53L0X emits an infrared pulse and times the round-trip to a target, reporting distance in millimeters - contactless ranging and gesture, bridged to the same telemetry sink as the other field sensors. Its documented register interface is small: check IDENTIFICATION_MODEL_ID (0xC0 == 0xEE), start ranging via SYSRANGE_START, poll RESULT_INTERRUPT_STATUS for data-ready, read the 16-bit range from RESULT_RANGE_STATUS + 10, then clear the interrupt.

This codec is pure and host-tested: vl53l0x_range_mm combines the range register pair, vl53l0x_data_ready decodes the interrupt-status byte, and vl53l0x_range_valid checks the device range-status field. On an ESP32 the binding runs the ranging loop over I2C (Wire); only that touches hardware. Note: ST's optional tuning blob (for best accuracy) is not applied - default-settings ranging via the documented registers.

Definition in file vl53l0x.h.

Macro Definition Documentation

◆ VL53L0X_REG_SYSRANGE_START

#define VL53L0X_REG_SYSRANGE_START   0x00

Definition at line 26 of file vl53l0x.h.

◆ VL53L0X_REG_SYSTEM_INTERRUPT_CLEAR

#define VL53L0X_REG_SYSTEM_INTERRUPT_CLEAR   0x0B

Definition at line 27 of file vl53l0x.h.

◆ VL53L0X_REG_RESULT_INTERRUPT_STATUS

#define VL53L0X_REG_RESULT_INTERRUPT_STATUS   0x13

Definition at line 28 of file vl53l0x.h.

◆ VL53L0X_REG_RESULT_RANGE_STATUS

#define VL53L0X_REG_RESULT_RANGE_STATUS   0x14

Definition at line 29 of file vl53l0x.h.

◆ VL53L0X_REG_IDENTIFICATION_MODEL_ID

#define VL53L0X_REG_IDENTIFICATION_MODEL_ID   0xC0

Definition at line 30 of file vl53l0x.h.

◆ VL53L0X_MODEL_ID

#define VL53L0X_MODEL_ID   0xEE

IDENTIFICATION_MODEL_ID for the VL53L0X.

Definition at line 32 of file vl53l0x.h.

◆ VL53L0X_RANGE_VALID

#define VL53L0X_RANGE_VALID   11

DeviceRangeStatus value that means a valid measurement.

Definition at line 33 of file vl53l0x.h.

Function Documentation

◆ vl53l0x_range_mm()

uint16_t vl53l0x_range_mm ( uint8_t  hi,
uint8_t  lo 
)

Combine the range high/low bytes (RESULT_RANGE_STATUS+10 / +11) into millimeters.

◆ vl53l0x_data_ready()

bool vl53l0x_data_ready ( uint8_t  interrupt_status)

True if a new measurement is ready (any of the low 3 interrupt-status bits set).

◆ vl53l0x_range_status()

uint8_t vl53l0x_range_status ( uint8_t  range_status_reg)

The DeviceRangeStatus field (bits 6:3) of the RESULT_RANGE_STATUS register.

◆ vl53l0x_range_valid()

bool vl53l0x_range_valid ( uint8_t  range_status_reg)

True if the range-status field reports a valid measurement (== VL53L0X_RANGE_VALID).

◆ vl53l0x_begin()

bool vl53l0x_begin ( uint8_t  addr)

Verify the model id and start continuous back-to-back ranging at addr.

Returns
present + ack.

◆ vl53l0x_read_mm()

bool vl53l0x_read_mm ( uint16_t *  mm)

If a measurement is ready, read the distance into mm and clear the interrupt.

Returns
true on a fresh, valid reading; false if not ready / invalid / I2C error.