Skip to content

getInterrupt()

Arnd edited this page Dec 11, 2020 · 2 revisions

getInterrupt()

This function retrieves the values of the interrupt status register. If the returned unsigned integer is 0 then no interrupts are pending, any other value means that one or more interrupts are set. The values are set by bit position as follows:

Bit Value
0 High Threshold reached
1 Low Threshold reached
2 Ambient light reading ready
3 Proximity reading ready

The interrupt settings remain until cleared using the clearInterrupt() function.


Example:

VCNL4010 Sensor();                              // Instantiate class    
...    
while (!Sensor.begin());                        // Initialize the VCNL4010
uint8_t interruptFlags = Sensor.getInterrupt(); // Get values
if(interruptFlags|B0001) Serial.print("High threshold set");
if(interruptFlags|B0010) Serial.print("Low threshold set");
if(interruptFlags|B0100) Serial.print("Ambient sample ready");
if(interruptFlags|B1000) Serial.print("Proximity sample ready");