SparkFun_VEML7700_Arduino_Library
|
#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... | |
Communication interface for the VEML7700
bool VEML7700::begin | ( | TwoWire & | wirePort = Wire | ) |
Begin communication with the VEML7700.
Begin the VEML7700. Default to Wire
wirePort | The TwoWire (I2C) port used to communicate with the sensor. Default is Wire. |
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.
void VEML7700::enableDebugging | ( | Stream & | debugPort = Serial | ) |
Enable debug messages on the chosen Serial port (Stream)
Enable debug messages. Default to Serial
debugPort | The Serial port (Stream) the debug messages will be printed to. Default is Serial. |
uint16_t VEML7700::getAmbientLight | ( | ) |
Get the VEML7700's ambient light sensor data (ALS)
VEML7700_error_t VEML7700::getAmbientLight | ( | uint16_t * | ambient | ) |
Get the VEML7700's ambient light sensor data (ALS)
Read the sensor data
ambient | Will be set to the ambient level on return |
uint16_t VEML7700::getHighThreshold | ( | ) |
Get the VEML7700's ALS high threshold window setting (ALS_WH)
VEML7700_error_t VEML7700::getHighThreshold | ( | uint16_t * | threshold | ) |
Get the VEML7700's ALS high threshold window setting (ALS_WH)
threshold | Will be set to the threshold setting on return |
VEML7700_integration_time_t VEML7700::getIntegrationTime | ( | ) |
Get the VEML7700's integration time setting (ALS_IT)
VEML7700_error_t VEML7700::getIntegrationTime | ( | VEML7700_integration_time_t * | it | ) |
Get the VEML7700's integration time setting (ALS_IT)
it | Will be set to the intergration time setting on return |
VEML7700_interrupt_enable_t VEML7700::getInterruptEnable | ( | ) |
Get the VEML7700's interrupt enable setting (ALS_INT_EN)
VEML7700_error_t VEML7700::getInterruptEnable | ( | VEML7700_interrupt_enable_t * | ie | ) |
Get the VEML7700's interrupt enable setting (ALS_INT_EN)
ie | Will be set to the interrupt enable setting on return |
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.
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.
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 |
uint16_t VEML7700::getLowThreshold | ( | ) |
Get the VEML7700's ALS low threshold window setting (ALS_WL)
VEML7700_error_t VEML7700::getLowThreshold | ( | uint16_t * | threshold | ) |
Get the VEML7700's ALS low threshold window setting (ALS_WL)
threshold | Will be set to the threshold setting on return |
float VEML7700::getLux | ( | ) |
Read the sensor data and calculate the lux.
VEML7700_error_t VEML7700::getLux | ( | float * | lux | ) |
Read the sensor data and calculate the lux.
lux | Will be set to the lux on return |
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
VEML7700_persistence_protect_t VEML7700::getPersistenceProtect | ( | ) |
Get the VEML7700's persistence protect number setting (ALS_PERS)
VEML7700_error_t VEML7700::getPersistenceProtect | ( | VEML7700_persistence_protect_t * | pp | ) |
Get the VEML7700's persistence protect number setting (ALS_PERS)
pp | Will be set to the persistence protect number on return |
VEML7700_sensitivity_mode_t VEML7700::getSensitivityMode | ( | ) |
Get the VEML7700's sensitivity mode selection (ALS_SM)
VEML7700_error_t VEML7700::getSensitivityMode | ( | VEML7700_sensitivity_mode_t * | sm | ) |
Get the VEML7700's sensitivity mode selection (ALS_SM)
sm | Will be set to the sensitivity mode selection on return |
VEML7700_shutdown_t VEML7700::getShutdown | ( | ) |
Get the VEML7700's shut down setting (ALS_SD)
uint16_t VEML7700::getWhiteLevel | ( | ) |
Get the VEML7700's white level data (WHITE)
VEML7700_error_t VEML7700::getWhiteLevel | ( | uint16_t * | whiteLevel | ) |
Get the VEML7700's white level data (WHITE)
whiteLevel | Will be set to the white level on return |
boolean VEML7700::isConnected | ( | ) |
VEML7700_error_t VEML7700::setHighThreshold | ( | uint16_t | threshold | ) |
Set the VEML7700's ALS high threshold window setting (ALS_WH)
threshold | The threshold setting: 0x0000 to 0xFFFF |
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.
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 |
VEML7700_error_t VEML7700::setInterruptEnable | ( | VEML7700_interrupt_enable_t | ie | ) |
Set the VEML7700's interrupt enable setting (ALS_INT_EN)
ie | The interrupt enable setting. Possible values are: VEML7700_INT_DISABLE VEML7700_INT_ENABLE |
VEML7700_error_t VEML7700::setLowThreshold | ( | uint16_t | threshold | ) |
Set the VEML7700's ALS low threshold window setting (ALS_WL)
threshold | The threshold setting: 0x0000 to 0xFFFF |
VEML7700_error_t VEML7700::setPersistenceProtect | ( | VEML7700_persistence_protect_t | pp | ) |
Set the VEML7700's persistence protect number setting (ALS_PERS)
pp | The persistence protect setting. Possible values are: VEML7700_PERSISTENCE_1 VEML7700_PERSISTENCE_2 VEML7700_PERSISTENCE_4 VEML7700_PERSISTENCE_8 |
VEML7700_error_t VEML7700::setSensitivityMode | ( | VEML7700_sensitivity_mode_t | sm | ) |
Set the VEML7700's sensitivity mode selection (ALS_SM)
it | The sensitivity mode selection. Possible values are: VEML7700_SENSITIVITY_x1 VEML7700_SENSITIVITY_x2 VEML7700_SENSITIVITY_x1_8 VEML7700_SENSITIVITY_x1_4 |
VEML7700_error_t VEML7700::setShutdown | ( | VEML7700_shutdown_t | sd | ) |
Set the VEML7700's shut down setting (ALS_SD)
Configuration controls
sd | The shut down setting. Possible values are: VEML7700_POWER_ON VEML7700_SHUT_DOWN |