Kenji Arai / 6180XA1_simple

Dependents:   Check_VL6180XA1_ToF

Fork of X_NUCLEO_6180XA1 by ST

Embed: (wiki syntax)

« Back to documentation index

VL6180X Class Reference

VL6180X Class Reference

Interface for STMicronics VL6180X Proximity sensor, gesture and ambient light sensing (ALS) module. More...

#include <VL6180X.h>

Public Member Functions

 VL6180X (PinName p_sda, PinName p_scl, PinName ce_pin, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS)
 Constructor 1.
 VL6180X (I2C &p_i2c, PinName ce_pin, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS)
 Constructor 2.
virtual int get_distance (uint32_t *pi_data)
 Get a single distance measure result.
virtual int get_lux (uint32_t *pi_data)
 Get a single light (in Lux) measure result.
int init (void)
 One time device initialization.

Detailed Description

Interface for STMicronics VL6180X Proximity sensor, gesture and ambient light sensing (ALS) module.

 #include "mbed.h"

 // I2C Communication
 VL6180X        sensor(I2C_SDA, I2C_SCL, D8);   // SDA, SCL & Chip Enable
 // 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);
 VL6180X        sensor(i2c, D8);                // I2C, Chip Enable

 int main()
 { 
     uint32_t lux;
     uint32_t dist;
 
     while (true) {
        sensor.get_distance(&dist);
        sensor.get_lux(&lux);
        wait_ms(500);
   }
 }

Class representing a VL6180X sensor component

Definition at line 113 of file VL6180X.h.


Constructor & Destructor Documentation

VL6180X ( PinName  p_sda,
PinName  p_scl,
PinName  ce_pin,
uint8_t  DevAddr = DEFAULT_DEVICE_ADDRESS 
)

Constructor 1.

Parameters:
[in]Pinfor I2C SDA & SDL
[in]pinMbed DigitalOut PinName to be used as component GPIO_0 CE
[in]DevAddrdevice address, 0x29 by default

Definition at line 121 of file VL6180X.h.

VL6180X ( I2C &  p_i2c,
PinName  ce_pin,
uint8_t  DevAddr = DEFAULT_DEVICE_ADDRESS 
)

Constructor 2.

Parameters:
[in]&i2cdevice I2C to be used for communication
[in]pinMbed DigitalOut PinName to be used as component GPIO_0 CE
[in]DevAddrdevice address, 0x29 by default

Definition at line 136 of file VL6180X.h.


Member Function Documentation

virtual int get_distance ( uint32_t *  pi_data ) [virtual]

Get a single distance measure result.

Function Description
It can be called after having initialized a component. It start a single distance measure in polling mode and wait until the measure is finisched. The function block until the measure is finished, it can blocks indefinitely in case the measure never ends for any reason
Parameters:
pi_dataPointer to distance
Returns:
0 on success

Definition at line 158 of file VL6180X.h.

virtual int get_lux ( uint32_t *  pi_data ) [virtual]

Get a single light (in Lux) measure result.

Function Description
It can be called after having initialized a component. It start a single light measure in polling mode and wait until the measure is finisched. The function block until the measure is finished, it can blocks indefinitely in case the measure never ends for any reason

Definition at line 179 of file VL6180X.h.

int init ( void   )

One time device initialization.

To be called once and only once after device is brought out of reset (Chip enable) and booted see VL6180X_WaitDeviceBooted()

Function Description
When not used after a fresh device "power up" or reset, it may return CALIBRATION_WARNING meaning wrong calibration data may have been fetched from device that can result in ranging offset error
If application cannot execute device reset or need to run VL6180X_InitData multiple time then it must ensure proper offset calibration saving and restore on its own by using VL6180X_GetOffsetCalibrationData() on first power up and then VL6180X_SetOffsetCalibrationData() all all subsequent init
Parameters:
void
Returns:
0 on success, CALIBRATION_WARNING if failed

Definition at line 208 of file VL6180X.h.