SparkFun_VEML7700_Arduino_Library
Classes | Public Member Functions | List of all members
VEML7700 Class Reference

#include <SparkFun_VEML7700_Arduino_Library.h>

Public Member Functions

 VEML7700 ()
 Class to communicate with the VEML7700.
 
bool begin (TwoWire &wirePort=Wire)
 Begin communication with the VEML7700. More...
 
void enableDebugging (Stream &debugPort=Serial)
 Enable debug messages on the chosen Serial port (Stream) More...
 
void disableDebugging ()
 Disable debug messages.
 
bool isConnected ()
 Check that the VEML7700 is awake and communicating. More...
 
VEML7700_error_t setShutdown (VEML7700_shutdown_t)
 Set the VEML7700's shut down setting (ALS_SD) More...
 
VEML7700_error_t powerOn ()
 
VEML7700_error_t shutdown ()
 
VEML7700_shutdown_t getShutdown ()
 Get the VEML7700's shut down setting (ALS_SD) More...
 
VEML7700_error_t setInterruptEnable (VEML7700_interrupt_enable_t ie)
 Set the VEML7700's interrupt enable setting (ALS_INT_EN) More...
 
VEML7700_error_t getInterruptEnable (VEML7700_interrupt_enable_t *ie)
 Get the VEML7700's interrupt enable setting (ALS_INT_EN) More...
 
VEML7700_interrupt_enable_t getInterruptEnable ()
 Get the VEML7700's interrupt enable setting (ALS_INT_EN) More...
 
VEML7700_error_t setPersistenceProtect (VEML7700_persistence_protect_t pp)
 Set the VEML7700's persistence protect number setting (ALS_PERS) More...
 
VEML7700_error_t getPersistenceProtect (VEML7700_persistence_protect_t *pp)
 Get the VEML7700's persistence protect number setting (ALS_PERS) More...
 
VEML7700_persistence_protect_t getPersistenceProtect ()
 Get the VEML7700's persistence protect number setting (ALS_PERS) More...
 
const char * getPersistenceProtectStr ()
 Get the VEML7700's persistence protect number setting (ALS_PERS) as printable text.
 
VEML7700_error_t setIntegrationTime (VEML7700_integration_time_t it)
 Set the VEML7700's integration time setting (ALS_IT)
Note: these are defined here in simple sequential order
The actual register settings are defined in VEML7700_config_integration_time_t. More...
 
VEML7700_error_t getIntegrationTime (VEML7700_integration_time_t *it)
 Get the VEML7700's integration time setting (ALS_IT) More...
 
VEML7700_integration_time_t getIntegrationTime ()
 Get the VEML7700's integration time setting (ALS_IT) More...
 
const char * getIntegrationTimeStr ()
 Get the VEML7700's integration time setting (ALS_IT) as printable text.
 
VEML7700_error_t setSensitivityMode (VEML7700_sensitivity_mode_t sm)
 Set the VEML7700's sensitivity mode selection (ALS_SM) More...
 
VEML7700_error_t getSensitivityMode (VEML7700_sensitivity_mode_t *sm)
 Get the VEML7700's sensitivity mode selection (ALS_SM) More...
 
VEML7700_sensitivity_mode_t getSensitivityMode ()
 Get the VEML7700's sensitivity mode selection (ALS_SM) More...
 
const char * getSensitivityModeStr ()
 Get the VEML7700's sensitivity mode selection (ALS_SM) as printable text.
 
VEML7700_error_t setHighThreshold (uint16_t threshold)
 Set the VEML7700's ALS high threshold window setting (ALS_WH) More...
 
VEML7700_error_t getHighThreshold (uint16_t *threshold)
 Get the VEML7700's ALS high threshold window setting (ALS_WH) More...
 
uint16_t getHighThreshold ()
 Get the VEML7700's ALS high threshold window setting (ALS_WH) More...
 
VEML7700_error_t setLowThreshold (uint16_t threshold)
 Set the VEML7700's ALS low threshold window setting (ALS_WL) More...
 
VEML7700_error_t getLowThreshold (uint16_t *threshold)
 Get the VEML7700's ALS low threshold window setting (ALS_WL) More...
 
uint16_t getLowThreshold ()
 Get the VEML7700's ALS low threshold window setting (ALS_WL) More...
 
VEML7700_error_t getAmbientLight (uint16_t *ambient)
 Get the VEML7700's ambient light sensor data (ALS) More...
 
uint16_t getAmbientLight ()
 Get the VEML7700's ambient light sensor data (ALS) More...
 
VEML7700_error_t getWhiteLevel (uint16_t *whiteLevel)
 Get the VEML7700's white level data (WHITE) More...
 
uint16_t getWhiteLevel ()
 Get the VEML7700's white level data (WHITE) More...
 
VEML7700_error_t getLux (float *lux)
 Read the sensor data and calculate the lux. More...
 
float getLux ()
 Read the sensor data and calculate the lux. More...
 
VEML7700_error_t getInterruptStatus (VEML7700_interrupt_status_t *status)
 Read the VEML7700's interrupt status register
Note: reading the interrupt status register clears the interrupts.
So, we need to check both interrupt flags in a single read. More...
 
VEML7700_interrupt_status_t getInterruptStatus ()
 Read the VEML7700's interrupt status register
Note: reading the interrupt status register clears the interrupts.
So, we need to check both interrupt flags in a single read. More...
 

Detailed Description

Communication interface for the VEML7700

Member Function Documentation

◆ begin()

bool VEML7700::begin ( TwoWire &  wirePort = Wire)

Begin communication with the VEML7700.

Begin the VEML7700. Default to Wire

Parameters
wirePort
The TwoWire (I2C) port used to communicate with the sensor.
Default is Wire.
Returns
True if communication with the VEML7700 was successful, otherwise false.

Write _configurationRegister into the VEML7700_CONFIGURATION_REGISTER. This will place the device into a known state, in case it was configured previously and remained powered on when the code was restarted.

◆ enableDebugging()

void VEML7700::enableDebugging ( Stream &  debugPort = Serial)

Enable debug messages on the chosen Serial port (Stream)

Enable debug messages. Default to Serial

Parameters
debugPort
The Serial port (Stream) the debug messages will be printed to.
Default is Serial.

◆ getAmbientLight() [1/2]

uint16_t VEML7700::getAmbientLight ( )

Get the VEML7700's ambient light sensor data (ALS)

Returns
The ambient light reading

◆ getAmbientLight() [2/2]

VEML7700_error_t VEML7700::getAmbientLight ( uint16_t *  ambient)

Get the VEML7700's ambient light sensor data (ALS)

Read the sensor data

Parameters
ambient
Will be set to the ambient level on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getHighThreshold() [1/2]

uint16_t VEML7700::getHighThreshold ( )

Get the VEML7700's ALS high threshold window setting (ALS_WH)

Returns
The threshold setting

◆ getHighThreshold() [2/2]

VEML7700_error_t VEML7700::getHighThreshold ( uint16_t *  threshold)

Get the VEML7700's ALS high threshold window setting (ALS_WH)

Parameters
threshold
Will be set to the threshold setting on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getIntegrationTime() [1/2]

VEML7700_integration_time_t VEML7700::getIntegrationTime ( )

Get the VEML7700's integration time setting (ALS_IT)

Returns
If successful:
VEML7700_INTEGRATION_25ms
VEML7700_INTEGRATION_50ms
VEML7700_INTEGRATION_100ms
VEML7700_INTEGRATION_200ms
VEML7700_INTEGRATION_400ms
VEML7700_INTEGRATION_800ms
Otherwise:
VEML7700_INTEGRATION_INVALID

◆ getIntegrationTime() [2/2]

VEML7700_error_t VEML7700::getIntegrationTime ( VEML7700_integration_time_t it)

Get the VEML7700's integration time setting (ALS_IT)

Parameters
it
Will be set to the intergration time setting on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getInterruptEnable() [1/2]

VEML7700_interrupt_enable_t VEML7700::getInterruptEnable ( )

Get the VEML7700's interrupt enable setting (ALS_INT_EN)

Returns
VEML7700_INT_DISABLE or VEML7700_INT_ENABLE if successful, VEML7700_INT_INVALID otherwise

◆ getInterruptEnable() [2/2]

VEML7700_error_t VEML7700::getInterruptEnable ( VEML7700_interrupt_enable_t ie)

Get the VEML7700's interrupt enable setting (ALS_INT_EN)

Parameters
ie
Will be set to the interrupt enable setting on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getInterruptStatus() [1/2]

VEML7700_interrupt_status_t VEML7700::getInterruptStatus ( )

Read the VEML7700's interrupt status register
Note: reading the interrupt status register clears the interrupts.
So, we need to check both interrupt flags in a single read.

Returns
If successful:
VEML7700_INT_STATUS_NONE
VEML7700_INT_STATUS_HIGH
VEML7700_INT_STATUS_LOW
VEML7700_INT_STATUS_BOTH
Otherwise:
VEML7700_INT_STATUS_INVALID

◆ getInterruptStatus() [2/2]

VEML7700_error_t VEML7700::getInterruptStatus ( VEML7700_interrupt_status_t status)

Read the VEML7700's interrupt status register
Note: reading the interrupt status register clears the interrupts.
So, we need to check both interrupt flags in a single read.

Note: reading the interrupt status register clears the interrupts. So, we need to check both interrupt flags in a single read.

Parameters
status
Will be set to the logical OR of ALS_IF_L and ALS_IF_H on return
Possible values are:
VEML7700_INT_STATUS_NONE
VEML7700_INT_STATUS_HIGH
VEML7700_INT_STATUS_LOW
VEML7700_INT_STATUS_BOTH
If an I2C error occurred, status will be:
VEML7700_INT_STATUS_INVALID
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getLowThreshold() [1/2]

uint16_t VEML7700::getLowThreshold ( )

Get the VEML7700's ALS low threshold window setting (ALS_WL)

Returns
The threshold setting

◆ getLowThreshold() [2/2]

VEML7700_error_t VEML7700::getLowThreshold ( uint16_t *  threshold)

Get the VEML7700's ALS low threshold window setting (ALS_WL)

Parameters
threshold
Will be set to the threshold setting on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getLux() [1/2]

float VEML7700::getLux ( )

Read the sensor data and calculate the lux.

Returns
The lux

◆ getLux() [2/2]

VEML7700_error_t VEML7700::getLux ( float *  lux)

Read the sensor data and calculate the lux.

Parameters
lux
Will be set to the lux on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

First, we need to extract the correct resolution from the VEML7700_LUX_RESOLUTION gain and integration time look up table. Let's begin by reading the gain (sensitivity) and integration time.

Now we can extract the correct resolution from the look up table.

Now we read the ambient level and multiply it by the resolution

◆ getPersistenceProtect() [1/2]

VEML7700_persistence_protect_t VEML7700::getPersistenceProtect ( )

Get the VEML7700's persistence protect number setting (ALS_PERS)

Returns
If successful:
VEML7700_PERSISTENCE_1
VEML7700_PERSISTENCE_2
VEML7700_PERSISTENCE_4
VEML7700_PERSISTENCE_8
Otherwise:
VEML7700_PERSISTENCE_INVALID

◆ getPersistenceProtect() [2/2]

VEML7700_error_t VEML7700::getPersistenceProtect ( VEML7700_persistence_protect_t pp)

Get the VEML7700's persistence protect number setting (ALS_PERS)

Parameters
pp
Will be set to the persistence protect number on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getSensitivityMode() [1/2]

VEML7700_sensitivity_mode_t VEML7700::getSensitivityMode ( )

Get the VEML7700's sensitivity mode selection (ALS_SM)

Returns
If successful:
VEML7700_SENSITIVITY_x1
VEML7700_SENSITIVITY_x2
VEML7700_SENSITIVITY_x1_8
VEML7700_SENSITIVITY_x1_4
Otherwise:
VEML7700_SENSITIVITY_INVALID

◆ getSensitivityMode() [2/2]

VEML7700_error_t VEML7700::getSensitivityMode ( VEML7700_sensitivity_mode_t sm)

Get the VEML7700's sensitivity mode selection (ALS_SM)

Parameters
sm
Will be set to the sensitivity mode selection on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ getShutdown()

VEML7700_shutdown_t VEML7700::getShutdown ( )

Get the VEML7700's shut down setting (ALS_SD)

Returns
VEML7700_POWER_ON or VEML7700_SHUT_DOWN if successful, VEML7700_SHUTDOWN_INVALID otherwise

◆ getWhiteLevel() [1/2]

uint16_t VEML7700::getWhiteLevel ( )

Get the VEML7700's white level data (WHITE)

Returns
The white level reading

◆ getWhiteLevel() [2/2]

VEML7700_error_t VEML7700::getWhiteLevel ( uint16_t *  whiteLevel)

Get the VEML7700's white level data (WHITE)

Parameters
whiteLevel
Will be set to the white level on return
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ isConnected()

boolean VEML7700::isConnected ( )

Check that the VEML7700 is awake and communicating.

Returns
True if communication with the VEML7700 was successful, otherwise false.

◆ setHighThreshold()

VEML7700_error_t VEML7700::setHighThreshold ( uint16_t  threshold)

Set the VEML7700's ALS high threshold window setting (ALS_WH)

Parameters
threshold
The threshold setting: 0x0000 to 0xFFFF
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ setIntegrationTime()

VEML7700_error_t VEML7700::setIntegrationTime ( VEML7700_integration_time_t  it)

Set the VEML7700's integration time setting (ALS_IT)
Note: these are defined here in simple sequential order
The actual register settings are defined in VEML7700_config_integration_time_t.

Parameters
it
The integration time setting. Possible values are:
VEML7700_INTEGRATION_25ms
VEML7700_INTEGRATION_50ms
VEML7700_INTEGRATION_100ms
VEML7700_INTEGRATION_200ms
VEML7700_INTEGRATION_400ms
VEML7700_INTEGRATION_800ms
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ setInterruptEnable()

VEML7700_error_t VEML7700::setInterruptEnable ( VEML7700_interrupt_enable_t  ie)

Set the VEML7700's interrupt enable setting (ALS_INT_EN)

Parameters
ie
The interrupt enable setting. Possible values are:
VEML7700_INT_DISABLE
VEML7700_INT_ENABLE
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ setLowThreshold()

VEML7700_error_t VEML7700::setLowThreshold ( uint16_t  threshold)

Set the VEML7700's ALS low threshold window setting (ALS_WL)

Parameters
threshold
The threshold setting: 0x0000 to 0xFFFF
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ setPersistenceProtect()

VEML7700_error_t VEML7700::setPersistenceProtect ( VEML7700_persistence_protect_t  pp)

Set the VEML7700's persistence protect number setting (ALS_PERS)

Parameters
pp
The persistence protect setting. Possible values are:
VEML7700_PERSISTENCE_1
VEML7700_PERSISTENCE_2
VEML7700_PERSISTENCE_4
VEML7700_PERSISTENCE_8
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ setSensitivityMode()

VEML7700_error_t VEML7700::setSensitivityMode ( VEML7700_sensitivity_mode_t  sm)

Set the VEML7700's sensitivity mode selection (ALS_SM)

Parameters
it
The sensitivity mode selection. Possible values are:
VEML7700_SENSITIVITY_x1
VEML7700_SENSITIVITY_x2
VEML7700_SENSITIVITY_x1_8
VEML7700_SENSITIVITY_x1_4
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

◆ setShutdown()

VEML7700_error_t VEML7700::setShutdown ( VEML7700_shutdown_t  sd)

Set the VEML7700's shut down setting (ALS_SD)

Configuration controls

Parameters
sd
The shut down setting. Possible values are:
VEML7700_POWER_ON
VEML7700_SHUT_DOWN
Returns
VEML7700_SUCCESS (VEML7700_ERROR_SUCCESS) if successful

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