Kenji Arai / VL53L0X_simple

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 ST

Embed: (wiki syntax)

« Back to documentation index

VL53L0X Class Reference

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 
)

Constructor.

Parameters:
[in]&i2cdevice I2C to be used for communication
[in]pinMbed DigitalInOut PinName to be used for XSHUT
[in]&pin_gpio1pin Mbed InterruptIn PinName to be used as component GPIO_1 INT

Definition at line 167 of file VL53L0X.h.

VL53L0X ( PinName  p_sda,
PinName  p_scl,
PinName  xshut 
)

Constructor 2 (another simple way)

Parameters:
[in]Pinfor I2C SDA & SDL
[in]pinMbed DigitalInOut PinName to be used for XSHUT

Definition at line 178 of file VL53L0X.h.

VL53L0X ( I2C &  p_i2c,
PinName  xshut 
)

Constructor 3 (another simple way)

Parameters:
[in]&i2cdevice I2C to be used for communication
[in]pinMbed DigitalInOut PinName to be used for XSHUT

Definition at line 188 of file VL53L0X.h.

virtual ~VL53L0X (  ) [virtual]

Destructor.

Definition at line 195 of file VL53L0X.h.


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_dataPointer to range distance
Returns:
"0" on success

Definition at line 307 of file VL53L0X.h.

void preparation ( void   )

initialize

Returns:
void

Definition at line 213 of file VL53L0X.h.

int set_mode ( RangeProfile  range_mode )

Start the measure by single shot operating mode.

Parameters:
[in]operatingmode
Returns:
"0" on success

Definition at line 288 of file VL53L0X.h.

void VL53L0X_off ( void   )

PowerOff the sensor.

Returns:
void

Definition at line 255 of file VL53L0X.h.

void VL53L0X_on ( void   )

PowerOn the sensor.

Returns:
void

Definition at line 229 of file VL53L0X.h.