Adafruit VL6180X Arduino Library
Public Member Functions | List of all members
Adafruit_VL6180X Class Reference

! Class for managing connection and state to a VL6180X sensor More...

#include <Adafruit_VL6180X.h>

Public Member Functions

 Adafruit_VL6180X (uint8_t i2caddr=VL6180X_DEFAULT_I2C_ADDR)
 Instantiates a new VL6180X class. More...
 
boolean begin (TwoWire *theWire=&Wire)
 Initializes I2C interface, checks that VL6180X is found and resets chip. More...
 
boolean setAddress (uint8_t newAddr)
 Sets the address of the device to a different address. chip. More...
 
uint8_t getAddress (void)
 gets the address of the device chip. More...
 
uint8_t readRange (void)
 Single shot ranging. Be sure to check the return of readRangeStatus to before using the return value! More...
 
float readLux (uint8_t gain)
 Single shot lux measurement. More...
 
uint8_t readRangeStatus (void)
 Request ranging success/error message (retreive after ranging) More...
 
boolean startRange (void)
 start Single shot ranging. The caller of this should have code that waits until the read completes, by either calling waitRangeComplete or calling isRangeComplete until it returns true. And then the code should call readRangeResult to retrieve the range value and clear out the internal status. More...
 
boolean isRangeComplete (void)
 Check to see if the range command completed. More...
 
boolean waitRangeComplete (void)
 Wait until Range completed. More...
 
uint8_t readRangeResult (void)
 Return results of read reqyest also clears out the interrupt Be sure to check the return of readRangeStatus to before using the return value! More...
 
void startRangeContinuous (uint16_t period_ms=50)
 Start continuous ranging. More...
 
void stopRangeContinuous (void)
 stop continuous range operation.
 
void setOffset (uint8_t offset)
 Set the offset. More...
 
void getID (uint8_t *id_ptr)
 Get the 7 bytes of id. More...
 

Detailed Description

! Class for managing connection and state to a VL6180X sensor

Constructor & Destructor Documentation

◆ Adafruit_VL6180X()

Adafruit_VL6180X::Adafruit_VL6180X ( uint8_t  i2caddr = VL6180X_DEFAULT_I2C_ADDR)

Instantiates a new VL6180X class.

Parameters
i2caddrOptional initial i2c address of the chip, VL6180X_DEFAULT_I2C_ADDR is used by default

Member Function Documentation

◆ begin()

boolean Adafruit_VL6180X::begin ( TwoWire *  theWire = &Wire)

Initializes I2C interface, checks that VL6180X is found and resets chip.

Parameters
theWireOptional pointer to I2C interface, &Wire is used by default
Returns
True if chip found and initialized, False otherwise

◆ setAddress()

boolean Adafruit_VL6180X::setAddress ( uint8_t  newAddr)

Sets the address of the device to a different address. chip.

Parameters
newAddrnew I2C address for the device.
Returns
True if write succeeded.

◆ getAddress()

uint8_t Adafruit_VL6180X::getAddress ( void  )

gets the address of the device chip.

Returns
the address

◆ readRange()

uint8_t Adafruit_VL6180X::readRange ( void  )

Single shot ranging. Be sure to check the return of readRangeStatus to before using the return value!

Returns
Distance in millimeters if valid

◆ readLux()

float Adafruit_VL6180X::readLux ( uint8_t  gain)

Single shot lux measurement.

Parameters
gainGain setting, one of VL6180X_ALS_GAIN_*
Returns
Lux reading

◆ readRangeStatus()

uint8_t Adafruit_VL6180X::readRangeStatus ( void  )

Request ranging success/error message (retreive after ranging)

Returns
One of possible VL6180X_ERROR_* values

◆ startRange()

boolean Adafruit_VL6180X::startRange ( void  )

start Single shot ranging. The caller of this should have code that waits until the read completes, by either calling waitRangeComplete or calling isRangeComplete until it returns true. And then the code should call readRangeResult to retrieve the range value and clear out the internal status.

Returns
true if range completed.

◆ isRangeComplete()

boolean Adafruit_VL6180X::isRangeComplete ( void  )

Check to see if the range command completed.

Returns
true if range completed.

◆ waitRangeComplete()

boolean Adafruit_VL6180X::waitRangeComplete ( void  )

Wait until Range completed.

Returns
true if range completed.

◆ readRangeResult()

uint8_t Adafruit_VL6180X::readRangeResult ( void  )

Return results of read reqyest also clears out the interrupt Be sure to check the return of readRangeStatus to before using the return value!

Returns
if range started.

◆ startRangeContinuous()

void Adafruit_VL6180X::startRangeContinuous ( uint16_t  period_ms = 50)

Start continuous ranging.

Parameters
period_msOptional Period between ranges in ms. Values will be rounded down to 10ms units with minimum of 10ms. Default is 50

◆ setOffset()

void Adafruit_VL6180X::setOffset ( uint8_t  offset)

Set the offset.

Parameters
offsetOffset setting

◆ getID()

void Adafruit_VL6180X::getID ( uint8_t *  id_ptr)

Get the 7 bytes of id.

Parameters
id_ptrPointer to array of id bytes

The documentation for this class was generated from the following files: