Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Check_VL53L0X_simple_with_three_ToF Check_VL53L0X_simple_ToF_Sensor Check_VL53L0X_simple_with_three_ToF Check_VL53L0X_simple_ToF_Sensor ... more
Fork of VL53L0X by
VL53L0X Class Reference
Interface for STMicronics VL53L0X World smallest Time-of-Flight (ToF) ranging sensor. More...
#include <VL53L0X.h>
Public Member Functions | |
| VL53L0X (I2C &i2c, PinName xshut, PinName pin_gpio1) | |
| Constructor. | |
| VL53L0X (PinName p_sda, PinName p_scl, PinName xshut) | |
| Constructor 2 (another simple way) | |
| VL53L0X (I2C &p_i2c, PinName xshut) | |
| Constructor 3 (another simple way) | |
| virtual | ~VL53L0X () |
| Destructor. | |
| void | preparation (void) |
| initialize | |
| void | VL53L0X_on (void) |
| PowerOn the sensor. | |
| void | VL53L0X_off (void) |
| PowerOff the sensor. | |
| int | init_sensor (uint8_t new_addr) |
| Initialize the sensor with default values. | |
| int | set_mode (RangeProfile range_mode) |
| Start the measure by single shot operating mode. | |
| virtual int | get_distance (uint32_t *p_data) |
| Get ranging result and only that. | |
Detailed Description
Interface for STMicronics VL53L0X World smallest Time-of-Flight (ToF) ranging sensor.
#include "mbed.h" // I2C Communication VL53L0X sensor(I2C_SDA, I2C_SCL, D8); // SDA, SCL & XSHUT // If you connected I2C line not only this device but also other devices, // you need to declare following method. I2C i2c(I2C_SDA, I2C_SCL); VL53L0X sensor(i2c, D8); // I2C, XSHUT int main() { int status = VL53L0X_ERROR_NONE; uint32_t data; status = sensor.init_sensor(0x33<<1U); //new addres(not equal others) status = sensor.set_mode(range_long_distance_33ms_200cm); //status = sensor.set_mode(range_hi_accurate_200ms_120cm); //status = sensor.set_mode(range_hi_speed_20ms_120cm); while (true) { status = sensor.get_distance(&data); if (status == VL53L0X_ERROR_NONE) { printf("%5d\r\n", data); } else { printf("error\r\n"); } } }
Class representing a VL53L0 sensor component
Definition at line 158 of file VL53L0X.h.
Constructor & Destructor Documentation
| VL53L0X | ( | I2C & | i2c, |
| PinName | xshut, | ||
| PinName | pin_gpio1 | ||
| ) |
| VL53L0X | ( | PinName | p_sda, |
| PinName | p_scl, | ||
| PinName | xshut | ||
| ) |
| VL53L0X | ( | I2C & | p_i2c, |
| PinName | xshut | ||
| ) |
Member Function Documentation
| virtual int get_distance | ( | uint32_t * | p_data ) | [virtual] |
Get ranging result and only that.
- Function Description
- Unlike VL53L0X_get_ranging_measurement_data() this function only retrieves the range in millimeter
It does any required up-scale translation
It can be called after success status polling or in interrupt mode
- Warning:
- these function is not doing wrap around filtering
This function doesn't perform any data ready check!
- Parameters:
-
p_data Pointer to range distance
- Returns:
- "0" on success
| int set_mode | ( | RangeProfile | range_mode ) |
| void VL53L0X_off | ( | void | ) |
Generated on Wed Jul 13 2022 18:43:14 by
1.7.2
