sparkfun / SparkFun_VL53L1X_Arduino_Library

A library for the laser based VL53L1X Time Of Flight distance sensor capable of detecting a target 4m away!
MIT License
88 stars 50 forks source link

Interrupt on no target should be off by default or settable #44

Closed mindlekofer closed 2 years ago

mindlekofer commented 3 years ago

When using a distance threshold mode the interrupt also gets triggered when there is no target or the target is out of range. This is in usually not intended e.g. if used as an external wake up source if a target is entering the allowed window.

The according parameter in the API function is defaulted to 1 by the abstraction (see code below), which enables the "out of window" interrupts. In my opinion this should be set to 0 by default or settable.

Current code:

void SFEVL53L1X::setDistanceThreshold(uint16_t lowThresh, uint16_t hiThresh, uint8_t window)
{
    _device->VL53L1X_SetDistanceThreshold(lowThresh, hiThresh, window, 1);
}

Proposed correction:

void SFEVL53L1X::setDistanceThreshold(uint16_t lowThresh, uint16_t hiThresh, uint8_t window)
{
    _device->VL53L1X_SetDistanceThreshold(lowThresh, hiThresh, window, 0);
}
PPVJM commented 2 years ago

Please pull the library and check Example 8. Cheers!