Adafruit VCNL4040 Arduino Library
Public Member Functions | Public Attributes | List of all members
Adafruit_VCNL4040 Class Reference

Class that stores state and functions for interacting with the VCNL4040 I2C Digital Potentiometer. More...

#include <Adafruit_VCNL4040.h>

Public Member Functions

 Adafruit_VCNL4040 ()
 Instantiates a new VCNL4040 class.
 
boolean begin (uint8_t i2c_addr=VCNL4040_I2CADDR_DEFAULT, TwoWire *wire=&Wire)
 Sets up the hardware and initializes I2C. More...
 
uint16_t getProximity (void)
 Gets the current proximity sensor value. More...
 
uint16_t getAmbientLight (void)
 Gets the current ambient light sensor value. More...
 
uint16_t getWhiteLight (void)
 Gets the current white light value. More...
 
uint16_t getLux (void)
 Gets the current ambient light sensor in Lux. More...
 
void enableProximity (bool enable)
 Enables or disables proximity measurements. More...
 
void enableAmbientLight (bool enable)
 Enables ambient light measurements. More...
 
void enableWhiteLight (bool enable)
 Enables white light measurements. More...
 
uint8_t getInterruptStatus (void)
 Gets and clears the interrupt status register. More...
 
void enableAmbientLightInterrupts (bool enable)
 Enables or disables ambient light based interrupts. More...
 
uint16_t getAmbientLightHighThreshold (void)
 Gets the current ambient light high threshold. More...
 
void setAmbientLightHighThreshold (uint16_t high_threshold)
 Sets the ambient light high threshold. More...
 
uint16_t getAmbientLightLowThreshold (void)
 Gets the ambient light low threshold. More...
 
void setAmbientLightLowThreshold (uint16_t low_threshold)
 Sets the ambient light low threshold. More...
 
void enableProximityInterrupts (VCNL4040_ProximityType interrupt_condition)
 Disables or enables proximity interrupts under a given condition. More...
 
uint16_t getProximityLowThreshold (void)
 Gets the proximity low threshold. More...
 
void setProximityLowThreshold (uint16_t low_threshold)
 Sets the proximity low threshold. More...
 
uint16_t getProximityHighThreshold (void)
 Gets the proximity high threshold. More...
 
void setProximityHighThreshold (uint16_t high_threshold)
 Sets the proximity high threshold. More...
 
VCNL4040_ProximityIntegration getProximityIntegrationTime (void)
 Gets the integration time for proximity sensing measurements. More...
 
void setProximityIntegrationTime (VCNL4040_ProximityIntegration integration_time)
 Sets the integration time for proximity sensing measurements. More...
 
VCNL4040_AmbientIntegration getAmbientIntegrationTime (void)
 Gets the integration time for ambient light sensing measurements. More...
 
void setAmbientIntegrationTime (VCNL4040_AmbientIntegration integration_time)
 Sets the integration time for ambient light sensing measurements. More...
 
VCNL4040_LEDCurrent getProximityLEDCurrent (void)
 Gets the current for the LED used for proximity measurements. More...
 
void setProximityLEDCurrent (VCNL4040_LEDCurrent led_current)
 Sets the current for the LED used for proximity measurements. More...
 
VCNL4040_LEDDutyCycle getProximityLEDDutyCycle (void)
 Sets the duty cycle for the LED used for proximity measurements. More...
 
void setProximityLEDDutyCycle (VCNL4040_LEDDutyCycle duty_cycle)
 Sets the duty cycle for the LED used for proximity measurements. More...
 
bool getProximityHighResolution (void)
 Gets the resolution of proximity measurements. More...
 
void setProximityHighResolution (bool high_resolution)
 Sets the resolution of proximity measurements. More...
 

Public Attributes

Adafruit_BusIO_Register * PS_CONFIG_12
 BusIO Register for PS_CONFIG1 and PS_CONFIG2.
 
Adafruit_BusIO_Register * ALS_CONFIG
 BusIO Register for ALS_CONFIG.
 
Adafruit_BusIO_Register * PS_MS
 BusIO Register for PS_MS.
 

Detailed Description

Class that stores state and functions for interacting with the VCNL4040 I2C Digital Potentiometer.

Member Function Documentation

◆ begin()

boolean Adafruit_VCNL4040::begin ( uint8_t  i2c_address = VCNL4040_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
Returns
True if initialization was successful, otherwise false.

◆ getProximity()

uint16_t Adafruit_VCNL4040::getProximity ( void  )

Gets the current proximity sensor value.

Returns
The current proximity measurement in units

◆ getAmbientLight()

uint16_t Adafruit_VCNL4040::getAmbientLight ( void  )

Gets the current ambient light sensor value.

Returns
The current ambient light measurement in units

◆ getWhiteLight()

uint16_t Adafruit_VCNL4040::getWhiteLight ( void  )

Gets the current white light value.

Returns
The current white light measurement in units

◆ getLux()

uint16_t Adafruit_VCNL4040::getLux ( void  )

Gets the current ambient light sensor in Lux.

Returns
The current ambient light measurement in Lux

◆ enableProximity()

void Adafruit_VCNL4040::enableProximity ( bool  enable)

Enables or disables proximity measurements.

Parameters
enableSet to true to enable proximity measurements, set to false to disable.

◆ enableAmbientLight()

void Adafruit_VCNL4040::enableAmbientLight ( bool  enable)

Enables ambient light measurements.

Parameters
enableSet to true to enable ambient light measurements, set to false to disable.

◆ enableWhiteLight()

void Adafruit_VCNL4040::enableWhiteLight ( bool  enable)

Enables white light measurements.

Parameters
enableSet to true to enable white light measurements, set to false to disable.

◆ getInterruptStatus()

uint8_t Adafruit_VCNL4040::getInterruptStatus ( void  )

Gets and clears the interrupt status register.

Returns
The current value of the interrupt status register. Indivitual interrupt types can be checked by anding the returned byte with the members of VCNL4040_InterruptType:VCNL4040_PROXIMITY_AWAY, VCNL4040_PROXIMITY_CLOSE, PROXIMITY_LOW, or PROXIMITY_HIGH

◆ enableAmbientLightInterrupts()

void Adafruit_VCNL4040::enableAmbientLightInterrupts ( bool  enable)

Enables or disables ambient light based interrupts.

Parameters
enableSet to true to enable or false to disable ambient light interrupts

◆ getAmbientLightHighThreshold()

uint16_t Adafruit_VCNL4040::getAmbientLightHighThreshold ( void  )

Gets the current ambient light high threshold.

Returns
The current ambient light high threshold

◆ setAmbientLightHighThreshold()

void Adafruit_VCNL4040::setAmbientLightHighThreshold ( uint16_t  high_threshold)

Sets the ambient light high threshold.

Parameters
high_thresholdThe high threshold to set

◆ getAmbientLightLowThreshold()

uint16_t Adafruit_VCNL4040::getAmbientLightLowThreshold ( void  )

Gets the ambient light low threshold.

Returns
the current ambient light low threshold

◆ setAmbientLightLowThreshold()

void Adafruit_VCNL4040::setAmbientLightLowThreshold ( uint16_t  low_threshold)

Sets the ambient light low threshold.

Parameters
low_thresholdThe low threshold to set

◆ enableProximityInterrupts()

void Adafruit_VCNL4040::enableProximityInterrupts ( VCNL4040_ProximityType  interrupt_condition)

Disables or enables proximity interrupts under a given condition.

Parameters
interrupt_conditionThe condition under which to raise an interrupt. Must be a VCNL4040_ProximityType. Use VCNL4040_PROXIMITY_INT_DISABLE to disable proximity interrupts.

◆ getProximityLowThreshold()

uint16_t Adafruit_VCNL4040::getProximityLowThreshold ( void  )

Gets the proximity low threshold.

Returns
The current low threshold

◆ setProximityLowThreshold()

void Adafruit_VCNL4040::setProximityLowThreshold ( uint16_t  low_threshold)

Sets the proximity low threshold.

Parameters
low_thresholdThe low threshold to set

◆ getProximityHighThreshold()

uint16_t Adafruit_VCNL4040::getProximityHighThreshold ( void  )

Gets the proximity high threshold.

Returns
The current high threshold

◆ setProximityHighThreshold()

void Adafruit_VCNL4040::setProximityHighThreshold ( uint16_t  high_threshold)

Sets the proximity high threshold.

Parameters
high_thresholdThe high threshold to set

◆ getProximityIntegrationTime()

VCNL4040_ProximityIntegration Adafruit_VCNL4040::getProximityIntegrationTime ( void  )

Gets the integration time for proximity sensing measurements.

Returns
The integration time being used for proximity measurements.

◆ setProximityIntegrationTime()

void Adafruit_VCNL4040::setProximityIntegrationTime ( VCNL4040_ProximityIntegration  integration_time)

Sets the integration time for proximity sensing measurements.

Parameters
integration_timeThe integration time to use for proximity measurements. Must be a VCNL4040_ProximityIntegration.

◆ getAmbientIntegrationTime()

VCNL4040_AmbientIntegration Adafruit_VCNL4040::getAmbientIntegrationTime ( void  )

Gets the integration time for ambient light sensing measurements.

Returns
The integration time being used for ambient light measurements.

◆ setAmbientIntegrationTime()

void Adafruit_VCNL4040::setAmbientIntegrationTime ( VCNL4040_AmbientIntegration  integration_time)

Sets the integration time for ambient light sensing measurements.

Parameters
integration_timeThe integration time to use for ambient light measurements. Must be a VCNL4040_AmbientIntegration.

◆ getProximityLEDCurrent()

VCNL4040_LEDCurrent Adafruit_VCNL4040::getProximityLEDCurrent ( void  )

Gets the current for the LED used for proximity measurements.

Returns
The LED current value being used for proximity measurements.

◆ setProximityLEDCurrent()

void Adafruit_VCNL4040::setProximityLEDCurrent ( VCNL4040_LEDCurrent  led_current)

Sets the current for the LED used for proximity measurements.

Parameters
led_currentThe current value to be used for proximity measurements. Must be a VCNL4040_LEDCurrent.

◆ getProximityLEDDutyCycle()

VCNL4040_LEDDutyCycle Adafruit_VCNL4040::getProximityLEDDutyCycle ( void  )

Sets the duty cycle for the LED used for proximity measurements.

Returns
The duty cycle value being used for proximity measurements.

◆ setProximityLEDDutyCycle()

void Adafruit_VCNL4040::setProximityLEDDutyCycle ( VCNL4040_LEDDutyCycle  duty_cycle)

Sets the duty cycle for the LED used for proximity measurements.

Parameters
duty_cycleThe duty cycle value to be used for proximity measurements. Must be a VCNL4040_LEDDutyCycle.

◆ getProximityHighResolution()

bool Adafruit_VCNL4040::getProximityHighResolution ( void  )

Gets the resolution of proximity measurements.

Returns
The current proximity measurement resolution If true, proximity measurements are 16-bit, If false, proximity measurements are 12-bit,

◆ setProximityHighResolution()

void Adafruit_VCNL4040::setProximityHighResolution ( bool  high_resolution)

Sets the resolution of proximity measurements.

Parameters
high_resolutionSet to true to take 16-bit measurements for proximity, set to faluse to use 12-bit measurements.

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