76 #ifndef VCNL4010_h // Guard code definition 78 #define VCNL4010_h // Define the name inside guard code 80 #define _BV(bit) (1 << (bit)) 85 #ifndef I2C_MODES // I2C related constants 87 #define I2C_MODES // Guard code to prevent multiple declarations 127 bool begin(
const uint8_t deviceAddress);
128 bool begin(
const uint32_t &i2CSpeed);
129 bool begin(
const uint8_t deviceAddress,
130 const uint32_t &i2CSpeed);
132 void setLEDmA(
const uint8_t mA = 20)
const;
138 uint8_t
readByte(
const uint8_t addr)
const;
139 uint16_t
readWord(
const uint8_t addr)
const;
140 void writeByte(
const uint8_t addr,
const uint8_t data)
const;
142 const uint8_t avg = 32)
const;
145 void setInterrupt(
const uint8_t count = 1,
const bool ProxReady =
false,
146 const bool ALSReady =
false,
const bool ProxThreshold =
false,
147 const bool ALSThreshold =
false,
const uint16_t lowThreshold = 0,
148 const uint16_t highThreshold = UINT16_MAX)
const;
151 bool _ContinuousAmbient =
false;
152 bool _ContinuousProximity =
false;
void setAmbientContinuous(const bool ContinuousMode=true)
Definition: VCNL4010.cpp:375
const uint8_t VCNL4010_I2C_MS_DELAY
I2C Delay in communications.
Definition: VCNL4010.h:95
const uint8_t BIT_ALS_OD
start On-Demand ALS reading bit
Definition: VCNL4010.h:112
Main class definition.
Definition: VCNL4010.h:118
const uint8_t REGISTER_AMBIENT_PARAM
Register containing ambient set.
Definition: VCNL4010.h:100
const uint32_t I2C_FAST_MODE
Fast mode.
Definition: VCNL4010.h:89
void setInterrupt(const uint8_t count=1, const bool ProxReady=false, const bool ALSReady=false, const bool ProxThreshold=false, const bool ALSThreshold=false, const uint16_t lowThreshold=0, const uint16_t highThreshold=UINT16_MAX) const
Definition: VCNL4010.cpp:327
const uint8_t REGISTER_PROXIMITY_RATE
Register containing sampling rate.
Definition: VCNL4010.h:98
const uint8_t REGISTER_HIGH_THRESH_MSB
MSB of high threshold value.
Definition: VCNL4010.h:106
void setProximityHz(const uint8_t Hz=2)
Definition: VCNL4010.cpp:131
const uint8_t BIT_ALS_EN
enable periodic ALS reading bit
Definition: VCNL4010.h:114
void setProximityContinuous(const bool ContinuousMode=true)
Definition: VCNL4010.cpp:396
const uint8_t REGISTER_CMD
Register containing commands.
Definition: VCNL4010.h:96
const uint8_t VCNL4010_PRODUCT_VERSION
Current product ID.
Definition: VCNL4010.h:94
const uint32_t I2C_FAST_MODE_PLUS_MODE
Really fast mode.
Definition: VCNL4010.h:90
const uint8_t REGISTER_INTERRUPT
Register containing Interrupts.
Definition: VCNL4010.h:103
const uint8_t BIT_PROX_OD
start On-Demand PROX reading bit
Definition: VCNL4010.h:113
const uint8_t BIT_ALS_DATA_RDY
ALS data ready bit.
Definition: VCNL4010.h:110
const uint8_t BIT_PROX_EN
enable periodic PROX reading bit
Definition: VCNL4010.h:115
uint16_t getAmbientLight() const
Definition: VCNL4010.cpp:269
const uint8_t REGISTER_PROXIMITY
Register containing Proximity.
Definition: VCNL4010.h:102
void clearInterrupt(const uint8_t intVal=0) const
Definition: VCNL4010.cpp:312
const uint8_t REGISTER_LOW_THRESH_MSB
MSB of low threshold value.
Definition: VCNL4010.h:104
void setAmbientLight(const uint8_t sample=2, const uint8_t avg=32) const
Definition: VCNL4010.cpp:218
const uint8_t REGISTER_HIGH_THRESH_LSB
LSB of high threshold value.
Definition: VCNL4010.h:107
bool begin(void)
Definition: VCNL4010.cpp:61
uint16_t readWord(const uint8_t addr) const
Definition: VCNL4010.cpp:101
VCNL4010()
Definition: VCNL4010.cpp:8
const uint8_t BIT_SELFTIMED_EN
enable periodic (self-timed) reading bit
Definition: VCNL4010.h:116
const uint8_t REGISTER_LOW_THRESH_LSB
LSB of low threshold value.
Definition: VCNL4010.h:105
uint16_t getProximity() const
Definition: VCNL4010.cpp:285
void writeByte(const uint8_t addr, const uint8_t data) const
Definition: VCNL4010.cpp:119
const uint8_t BIT_PROX_DATA_RDY
PROX data ready bit.
Definition: VCNL4010.h:111
~VCNL4010()
Definition: VCNL4010.cpp:14
const uint8_t REGISTER_PROXIMITY_TIMING
Register containing ProxTiming.
Definition: VCNL4010.h:109
const uint8_t REGISTER_PRODUCT
Register containing product ID.
Definition: VCNL4010.h:97
uint8_t readByte(const uint8_t addr) const
Definition: VCNL4010.cpp:87
const uint8_t REGISTER_INTERRUPT_STATUS
Interrupt status register.
Definition: VCNL4010.h:108
void setLEDmA(const uint8_t mA=20) const
Definition: VCNL4010.cpp:180
const uint8_t REGISTER_LED_CURRENT
Register containing IR LED mA.
Definition: VCNL4010.h:99
uint8_t getInterrupt() const
Definition: VCNL4010.cpp:301
const uint8_t REGISTER_AMBIENT_LIGHT
Register containing ambient data.
Definition: VCNL4010.h:101
const uint8_t VCNL4010_I2C_ADDRESS
Device address, fixed value.
Definition: VCNL4010.h:93
const uint32_t I2C_STANDARD_MODE
Default normal I2C 100KHz speed.
Definition: VCNL4010.h:88
void setProximityFreq(const uint8_t value=0)
Definition: VCNL4010.cpp:189
const uint32_t I2C_HIGH_SPEED_MODE
Turbo mode.
Definition: VCNL4010.h:91