|
9 | 9 | class SFEVL53L1X
|
10 | 10 | {
|
11 | 11 | public:
|
12 |
| - SFEVL53L1X(TwoWire &i2cPort = Wire, int shutdownPin = -1, int interruptPin = -1); |
13 |
| - bool init(); |
14 |
| - bool checkID(); |
15 |
| - void sensorOn(); |
16 |
| - void sensorOff(); //virtual void VL53L1_Off(void) |
17 |
| - VL53L1X_Version_t getSoftwareVersion();//VL53L1X_ERROR VL53L1X_GetSWVersion(VL53L1X_Version_t *pVersion); |
18 |
| - void setI2CAddress(uint8_t addr);//VL53L1X_ERROR VL53L1X_SetI2CAddress(uint8_t new_address); |
19 |
| - int getI2CAddress(); |
20 |
| - void clearInterrupt();//VL53L1X_ERROR VL53L1X_ClearInterrupt(); |
21 |
| - void setInterruptPolarityHigh();//VL53L1X_ERROR VL53L1X_SetInterruptPolarity(uint8_t IntPol); |
22 |
| - void setInterruptPolarityLow(); |
23 |
| - uint8_t getInterruptPolarity();//VL53L1X_ERROR VL53L1X_GetInterruptPolarity(uint8_t *pIntPol); |
24 |
| - void startRanging();//Begins taking measurements |
25 |
| - void stopRanging();//Stops taking measurements |
26 |
| - bool checkForDataReady();//VL53L1X_ERROR VL53L1X_CheckForDataReady(uint8_t *isDataReady); |
27 |
| - void setTimingBudgetInMs(uint16_t timingBudget);//VL53L1X_ERROR VL53L1X_SetTimingBudgetInMs(uint16_t TimingBudgetInMs); |
28 |
| - uint16_t getTimingBudgetInMs();//VL53L1X_ERROR VL53L1X_GetTimingBudgetInMs(uint16_t *pTimingBudgetInMs); |
29 |
| - void setDistanceModeLong();//VL53L1X_ERROR VL53L1X_SetDistanceMode(uint16_t DistanceMode); |
30 |
| - void setDistanceModeShort();//VL53L1X_ERROR VL53L1X_GetDistanceMode(uint16_t *pDistanceMode); |
31 |
| - uint8_t getDistanceMode(); |
32 |
| - void setIntermeasurementPeriod(uint16_t intermeasurement);//VL53L1X_ERROR VL53L1X_SetInterMeasurementInMs(uint16_t InterMeasurementInMs); |
33 |
| - uint16_t getIntermeasurementPeriod();//VL53L1X_ERROR VL53L1X_GetInterMeasurementInMs(uint16_t * pIM); |
34 |
| - bool checkBootState();//VL53L1X_ERROR VL53L1X_BootState(uint8_t *state); |
35 |
| - uint16_t getSensorID();//VL53L1X_ERROR VL53L1X_GetSensorId(uint16_t *id); |
36 |
| - uint16_t getDistance();//Returns distance |
37 |
| - uint16_t getSignalPerSpad();//VL53L1X_ERROR VL53L1X_GetSignalPerSpad(uint16_t *signalPerSp); |
38 |
| - uint16_t getAmbientPerSpad();//VL53L1X_ERROR VL53L1X_GetAmbientPerSpad(uint16_t *amb); |
39 |
| - uint16_t getSignalRate();//VL53L1X_ERROR VL53L1X_GetSignalRate(uint16_t *signalRate); |
40 |
| - uint16_t getSpadNb();//VL53L1X_ERROR VL53L1X_GetSpadNb(uint16_t *spNb); |
41 |
| - uint16_t getAmbientRate();//VL53L1X_ERROR VL53L1X_GetAmbientRate(uint16_t *ambRate); |
42 |
| - uint8_t getRangeStatus();//VL53L1X_ERROR VL53L1X_GetRangeStatus(uint8_t *rangeStatus); |
43 |
| - void setOffset(int16_t offset);//VL53L1X_ERROR VL53L1X_SetOffset(int16_t OffsetValue); |
44 |
| - int16_t getOffset();//VL53L1X_ERROR VL53L1X_GetOffset(int16_t *Offset); |
45 |
| - void setXTalk(uint16_t xTalk);//VL53L1X_ERROR VL53L1X_SetXtalk(uint16_t XtalkValue); |
46 |
| - uint16_t getXTalk();//VL53L1X_ERROR VL53L1X_GetXtalk(uint16_t *Xtalk); |
47 |
| - void setDistanceThreshold(uint16_t lowThresh, uint16_t hiThresh, uint8_t window);//VL53L1X_ERROR VL53L1X_SetDistanceThreshold(uint16_t ThreshLow, |
48 |
| - // uint16_t ThreshHigh, uint8_t Window, |
49 |
| - // uint8_t IntOnNoTarget); |
50 |
| - uint16_t getDistanceThresholdWindow();//VL53L1X_ERROR VL53L1X_GetDistanceThresholdWindow(uint16_t *window); |
51 |
| - uint16_t getDistanceThresholdLow();//VL53L1X_ERROR VL53L1X_GetDistanceThresholdLow(uint16_t *low); |
52 |
| - uint16_t getDistanceThresholdHigh();//VL53L1X_ERROR VL53L1X_GetDistanceThresholdHigh(uint16_t *high); |
53 |
| - void setROI(uint16_t x, uint16_t y);//VL53L1X_ERROR VL53L1X_SetROI(uint16_t X, uint16_t Y); |
54 |
| - uint16_t getROIX();//VL53L1X_ERROR VL53L1X_GetROI_XY(uint16_t *ROI_X, uint16_t *ROI_Y); |
55 |
| - uint16_t getROIY(); |
56 |
| - void setSignalThreshold(uint16_t signalThreshold);//VL53L1X_ERROR VL53L1X_SetSignalThreshold(uint16_t signal); |
57 |
| - uint16_t getSignalThreshold();//VL53L1X_ERROR VL53L1X_GetSignalThreshold(uint16_t *signal); |
58 |
| - void setSigmaThreshold(uint16_t sigmaThreshold);//VL53L1X_ERROR VL53L1X_SetSigmaThreshold(uint16_t sigma); |
59 |
| - uint16_t getSigmaThreshold();//VL53L1X_ERROR VL53L1X_GetSigmaThreshold(uint16_t *signal); |
60 |
| - void startTemperatureUpdate();//VL53L1X_ERROR VL53L1X_StartTemperatureUpdate(); |
61 |
| - void calibrateOffset(uint16_t targetDistanceInMm);//int8_t VL53L1X_CalibrateOffset(uint16_t TargetDistInMm, int16_t *offset); |
62 |
| - void calibrateXTalk(uint16_t targetDistanceInMm);//int8_t VL53L1X_CalibrateXtalk(uint16_t TargetDistInMm, uint16_t *xtalk); |
| 12 | + SFEVL53L1X(TwoWire &i2cPort = Wire, int shutdownPin = -1, int interruptPin = -1); //Constructs our Distance sensor without an interrupt or shutdown pin |
| 13 | + bool init(); //Deprecated version of begin |
| 14 | + bool begin(); //Initialization of sensor |
| 15 | + bool checkID(); //Check the ID of the sensor, returns true if ID is correct |
| 16 | + void sensorOn(); //Toggles shutdown pin to turn sensor on and off |
| 17 | + void sensorOff(); //Toggles shutdown pin to turn sensor on and off |
| 18 | + VL53L1X_Version_t getSoftwareVersion(); //Get's the current ST software version |
| 19 | + void setI2CAddress(uint8_t addr); //Set the I2C address |
| 20 | + int getI2CAddress(); //Get the I2C address |
| 21 | + void clearInterrupt(); // Clear the interrupt flag |
| 22 | + void setInterruptPolarityHigh(); //Set the polarity of an active interrupt to High |
| 23 | + void setInterruptPolarityLow(); //Set the polarity of an active interrupt to Low |
| 24 | + uint8_t getInterruptPolarity(); //get the current interrupt polarity |
| 25 | + void startRanging(); //Begins taking measurements |
| 26 | + void stopRanging(); //Stops taking measurements |
| 27 | + bool checkForDataReady(); //Checks the to see if data is ready |
| 28 | + void setTimingBudgetInMs(uint16_t timingBudget); //Set the timing budget for a measurement |
| 29 | + uint16_t getTimingBudgetInMs(); //Get the timing budget for a measurement |
| 30 | + void setDistanceModeLong(); //Set to 4M range |
| 31 | + void setDistanceModeShort(); //Set to 1.3M range |
| 32 | + uint8_t getDistanceMode(); //Get the distance mode, returns 1 for short and 2 for long |
| 33 | + void setIntermeasurementPeriod(uint16_t intermeasurement); //Set time between measurements in ms |
| 34 | + uint16_t getIntermeasurementPeriod(); //Get time between measurements in ms |
| 35 | + bool checkBootState(); //Check if the VL53L1X has been initialized |
| 36 | + uint16_t getSensorID(); //Get the sensor ID |
| 37 | + uint16_t getDistance(); //Returns distance |
| 38 | + uint16_t getSignalPerSpad(); //Returns the average signal rate per SPAD (The sensitive pads that detect light, the VL53L1X has a 16x16 array of these) in kcps/SPAD, or kilo counts per second per SPAD. |
| 39 | + uint16_t getAmbientPerSpad(); //Returns the ambient noise when not measuring a signal in kcps/SPAD. |
| 40 | + uint16_t getSignalRate(); //Returns the signal rate in kcps. All SPADs combined. |
| 41 | + uint16_t getSpadNb(); //Returns the current number of enabled SPADs |
| 42 | + uint16_t getAmbientRate(); // Returns the total ambinet rate in kcps. All SPADs combined. |
| 43 | + uint8_t getRangeStatus(); //Returns the range status, which can be any of the following. 0 = no error, 1 = signal fail, 2 = sigma fail, 7 = wrapped target fail |
| 44 | + void setOffset(int16_t offset); //Manually set an offset in mm |
| 45 | + int16_t getOffset(); //Get the current offset in mm |
| 46 | + void setXTalk(uint16_t xTalk); //Manually set the value of crosstalk in counts per second (cps), which is interference from any sort of window in front of your sensor. |
| 47 | + uint16_t getXTalk(); //Returns the current crosstalk value in cps. |
| 48 | + void setDistanceThreshold(uint16_t lowThresh, uint16_t hiThresh, uint8_t window);//Set bounds for the interrupt. lowThresh and hiThresh are the bounds of your interrupt while window decides when the interrupt should fire. The options for window are shown below. |
| 49 | + //0: Interrupt triggered on measured distance below lowThresh. |
| 50 | + //1: Interrupt triggered on measured distance above hiThresh. |
| 51 | + //2: Interrupt triggered on measured distance outside of bounds. |
| 52 | + //3: Interrupt triggered on measured distance inside of bounds. |
| 53 | + uint16_t getDistanceThresholdWindow(); //Returns distance threshold window option |
| 54 | + uint16_t getDistanceThresholdLow(); //Returns lower bound in mm. |
| 55 | + uint16_t getDistanceThresholdHigh(); //Returns upper bound in mm |
| 56 | + void setROI(uint16_t x, uint16_t y); //Set the height and width of the ROI in SPADs, lowest possible option is 4. ROI is always centered. |
| 57 | + uint16_t getROIX(); //Returns the width of the ROI in SPADs |
| 58 | + uint16_t getROIY(); //Returns the height of the ROI in SPADs |
| 59 | + void setSignalThreshold(uint16_t signalThreshold); //Programs the necessary threshold to trigger a measurement. Default is 1024 kcps. |
| 60 | + uint16_t getSignalThreshold(); //Returns the signal threshold in kcps |
| 61 | + void setSigmaThreshold(uint16_t sigmaThreshold); //Programs a new sigma threshold in mm. (default=15 mm) |
| 62 | + uint16_t getSigmaThreshold(); //Returns the current sigma threshold. |
| 63 | + void startTemperatureUpdate(); //Recalibrates the sensor for temperature changes. Run this any time the temperature has changed by more than 8°C |
| 64 | + void calibrateOffset(uint16_t targetDistanceInMm); //Autocalibrate the offset by placing a target a known distance away from the sensor and passing this known distance into the function. |
| 65 | + void calibrateXTalk(uint16_t targetDistanceInMm); //Autocalibrate the crosstalk by placing a target a known distance away from the sensor and passing this known distance into the function. |
63 | 66 | private:
|
64 | 67 | TwoWire *_i2cPort;
|
65 | 68 | int _shutdownPin;
|
|
0 commit comments