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_VL6180XA1_ToF
Fork of X_NUCLEO_6180XA1 by
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 |
||
| ) |
| VL6180X | ( | I2C & | p_i2c, |
| PinName | ce_pin, | ||
| uint8_t | DevAddr = DEFAULT_DEVICE_ADDRESS |
||
| ) |
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_data Pointer to distance
- Returns:
- 0 on success
| 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
| 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
Generated on Tue Jul 12 2022 22:24:22 by
1.7.2
