mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 09:36:59 +00:00
Merge pull request #3570 from tonhuisman/feature/P113-add-vl53l1x-tof-sensor
[P113] Add VL53L1X Time of Flight sensor to ESPEasy
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
.. include:: ../Plugin/_plugin_substitutions_p11x.repl
|
||||
.. _P113_page:
|
||||
|
||||
|P113_typename|
|
||||
==================================================
|
||||
|
||||
|P113_shortinfo|
|
||||
|
||||
Plugin details
|
||||
--------------
|
||||
|
||||
Type: |P113_type|
|
||||
|
||||
Name: |P113_name|
|
||||
|
||||
Status: |P113_status|
|
||||
|
||||
GitHub: |P113_github|_
|
||||
|
||||
Maintainer: |P113_maintainer|
|
||||
|
||||
Used libraries: |P113_usedlibraries|
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
This I2C sensor with 2 ranges offers distance measurement based on a Laser Time-of-Flight sensor. Output result for Distance is in millimeters.
|
||||
|
||||
The VL53L1X sensor can measure either 0 - 130cm (Normal range) or 0 - 400cm (Long range), where the closely related VL53L0X can measure up to 200cm. The API's for these sensors are not compatible, so different libraries are used.
|
||||
|
||||
Configuration
|
||||
--------------
|
||||
|
||||
.. image:: P113_DeviceConfiguration.png
|
||||
|
||||
**Name** A unique name should be entered here.
|
||||
|
||||
**Enabled** The device can be disabled or enabled. When not enabled the device should not use any resources.
|
||||
|
||||
I2C Options
|
||||
^^^^^^^^^^^^
|
||||
|
||||
The available settings here depend on the build used. At least the **Force Slow I2C speed** option is available, but selections for the I2C Multiplexer can also be shown. For details see the :ref:`Hardware_page`
|
||||
|
||||
**I2C Address**: The address the device is using. The chip allows to select the secondary address and keep that active until the next power-cycle of the sensor.
|
||||
|
||||
Device Settings
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
**Timing**: The timing setting of the sensor determines the accuracy of the measurement. There are 6 options available:
|
||||
|
||||
.. image:: P113_TimingOptions.png
|
||||
|
||||
*100 ms (Normal)* The default value, using an integration time of 100 msec.
|
||||
|
||||
*20ms (Fastest)* The fastest but least accurate measurement. Should only be used for Normal range (see below).
|
||||
|
||||
*33ms (Fast)* A fast but not very accurate measurement.
|
||||
|
||||
*50ms* A somewhat more accurate measurement.
|
||||
|
||||
*200ms Accurate* A slower but far more accurate measurement. For use with a longer read interval setting (30-60 sec).
|
||||
|
||||
*500ms* The longest integration time available. For use with long read interval settings.
|
||||
|
||||
**Range**: the measuring ranges:
|
||||
|
||||
.. image:: P113_RangeOptions.png
|
||||
|
||||
*Normal (~130cm)* For measurements in the 0 to 1300 millimeter (130cm) range.
|
||||
|
||||
*Long (~400cm)* For measurements in the 0 to 4000 millimeter (400cm) range (but somewhat less accurate).
|
||||
|
||||
**Send event when value unchanged** To avoid many of the same events when the measurement is stable, this option is off by default. When enabled, every measurement will cause an event, and send the data to any enabled Controller.
|
||||
|
||||
**Trigger delta** To avoid triggering many events with only a small difference in distance the 'Trigger delta' option is available. This can be set to only trigger an event when the new distance is at least the delta less or more than the previous measurement.
|
||||
|
||||
NB: This setting is ignored if 'Send event when value unchanged' is checked!
|
||||
|
||||
|
||||
The Data Acquisition, Send to Controller and Interval settings are standard available configuration items. Send to Controller only when one or more Controllers are configured.
|
||||
|
||||
**Interval** By default, Interval will be set to 60 sec. Setting this to 1 or 2 seconds, usually offers a reasonable response time.
|
||||
|
||||
Values
|
||||
^^^^^^
|
||||
|
||||
The measured distance is available in ``Distance``. A formula can be set to recalculate, f.e. to centimeters using ``%value%/10``. The number of decimals is by default set to 2, but for use with millimeters distance it can be set to 0, as no decimals are provided from the measurement.
|
||||
|
||||
The Ambient lighting condition during measurement is available in ``Ambient``. The unit is kcps (Photons per second, recalculated to kilo count per second)
|
||||
|
||||
.. Events
|
||||
.. ~~~~~~
|
||||
|
||||
.. .. include:: P113_events.repl
|
||||
|
||||
|
||||
|
||||
Change log
|
||||
----------
|
||||
|
||||
.. versionchanged:: 2.0
|
||||
|
||||
|added| 2021-04-05 Added to main repository as Plugin 113 Distance - VL53L1X (400cm), based on a copy of Plugin 110 Distance - VL53L0X (200cm)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -132,6 +132,7 @@ There's three different released versions of ESP Easy:
|
||||
":ref:`P108_page`","|P108_status|","P108"
|
||||
":ref:`P110_page`","|P110_status|","P110"
|
||||
":ref:`P111_page`","|P111_status|","P111"
|
||||
":ref:`P113_page`","|P113_status|","P113"
|
||||
|
||||
|
||||
Internal GPIO handling
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.. |Plugin_Analog_input| replace:: :ref:`P002_page`, :ref:`P007_page`, :ref:`P025_page`, :ref:`P060_page`, :ref:`P097_page`
|
||||
.. |Plugin_Communication| replace:: :ref:`P016_page`, :ref:`P020_page`, :ref:`P035_page`, :ref:`P044_page`, :ref:`P054_page`, :ref:`P071_page`, :ref:`P087_page`, :ref:`P089_page`, :ref:`P094_page`, :ref:`P101_page`
|
||||
.. |Plugin_Display| replace:: :ref:`P012_page`, :ref:`P023_page`, :ref:`P036_page`, :ref:`P057_page`, :ref:`P073_page`, :ref:`P075_page`, :ref:`P095_page`
|
||||
.. |Plugin_Distance| replace:: :ref:`P110_page`
|
||||
.. |Plugin_Distance| replace:: :ref:`P110_page`, :ref:`P113_page`
|
||||
.. |Plugin_Dust| replace:: :ref:`P018_page`, :ref:`P053_page`, :ref:`P056_page`
|
||||
.. |Plugin_Energy_AC| replace:: :ref:`P076_page`, :ref:`P077_page`, :ref:`P078_page`, :ref:`P102_page`, :ref:`P108_page`
|
||||
.. |Plugin_Energy_DC| replace:: :ref:`P027_page`, :ref:`P085_page`
|
||||
|
||||
@@ -23,3 +23,16 @@
|
||||
.. |P111_maintainer| replace:: `TD-er, twinbee77, tonhuisman`
|
||||
.. |P111_compileinfo| replace:: `.`
|
||||
.. |P111_usedlibraries| replace:: `https://github.com/miguelbalboa/rfid (local copy)`
|
||||
|
||||
.. |P113_name| replace:: :cyan:`VL53L1X`
|
||||
.. |P113_type| replace:: :cyan:`Distance`
|
||||
.. |P113_typename| replace:: :cyan:`Distance - VL53L1X (400cm)`
|
||||
.. |P113_porttype| replace:: `.`
|
||||
.. |P113_status| replace:: :yellow:`TESTING`
|
||||
.. |P113_github| replace:: P113_VL53L1X.ino
|
||||
.. _P113_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P113_VL53L1X.ino
|
||||
.. |P113_usedby| replace:: `.`
|
||||
.. |P113_shortinfo| replace:: `Laser distance (Time of Flight) sensor`
|
||||
.. |P113_maintainer| replace:: `TD-er, tonhuisman`
|
||||
.. |P113_compileinfo| replace:: `.`
|
||||
.. |P113_usedlibraries| replace:: `https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library (local copy)`
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ComponentObject.h
|
||||
* @author AST
|
||||
* @version V1.0.0
|
||||
* @date April 13th, 2015
|
||||
* @brief This file contains the abstract class describing the interface of a
|
||||
* generic component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
|
||||
#ifndef __COMPONENT_OBJECT_CLASS_H
|
||||
#define __COMPONENT_OBJECT_CLASS_H
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/* Classes ------------------------------------------------------------------*/
|
||||
|
||||
/** An abstract class for Generic components.
|
||||
*/
|
||||
class ComponentObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Initializing the component.
|
||||
* @param[in] init pointer to device specific initalization structure.
|
||||
* @retval "0" in case of success, an error code otherwise.
|
||||
*/
|
||||
virtual int Init() = 0;
|
||||
|
||||
/**
|
||||
* @brief Getting the ID of the component.
|
||||
* @param[out] id pointer to an allocated variable to store the ID into.
|
||||
* @retval "0" in case of success, an error code otherwise.
|
||||
*/
|
||||
virtual int ReadID() = 0;
|
||||
};
|
||||
|
||||
#endif /* __COMPONENT_OBJECT_CLASS_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file RangeSensor.h
|
||||
* @author AST / EST
|
||||
* @version V0.0.1
|
||||
* @date 13-April-2015
|
||||
* @brief This file contains the abstract class describing in general
|
||||
* the interfaces of a range sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent from recursive inclusion --------------------------------*/
|
||||
#ifndef __RANGE_SENSOR_CLASS_H
|
||||
#define __RANGE_SENSOR_CLASS_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <ComponentObject.h>
|
||||
|
||||
/* Classes ------------------------------------------------------------------*/
|
||||
/** An abstract class for range sensors
|
||||
*/
|
||||
class RangeSensor : public ComponentObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Get current range [mm]
|
||||
* @param[out] piData Pointer to where to store range to
|
||||
* @return 0 in case of success, an error code otherwise
|
||||
*/
|
||||
virtual int GetDistance(uint32_t *piData) = 0;
|
||||
};
|
||||
|
||||
#endif /* __RANGE_SENSOR_CLASS_H */
|
||||
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
This is a library written for the VL53L1X I2C Distance sensor.
|
||||
|
||||
Written by Andy England @ SparkFun Electronics, October 17th, 2017
|
||||
|
||||
The sensor uses I2C to communicate, as well as a single (optional)
|
||||
interrupt line that is not currently supported in this driver.
|
||||
|
||||
https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library
|
||||
|
||||
Do you like this library? Help support SparkFun. Buy a board!
|
||||
|
||||
Development environment specifics:
|
||||
Arduino IDE 1.8.1
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "Arduino.h"
|
||||
#include "SparkFun_VL53L1X.h"
|
||||
#include "vl53l1x_class.h"
|
||||
|
||||
SFEVL53L1X::SFEVL53L1X(TwoWire &i2cPort, int shutdownPin, int interruptPin)
|
||||
{
|
||||
_i2cPort = &i2cPort;
|
||||
_shutdownPin = shutdownPin;
|
||||
_interruptPin = interruptPin;
|
||||
_device = new VL53L1X(&i2cPort, shutdownPin, interruptPin);
|
||||
}
|
||||
|
||||
bool SFEVL53L1X::init()
|
||||
{
|
||||
return _device->VL53L1X_SensorInit();
|
||||
}
|
||||
|
||||
bool SFEVL53L1X::begin()
|
||||
{
|
||||
if (checkID() == false)
|
||||
return (VL53L1_ERROR_PLATFORM_SPECIFIC_START);
|
||||
|
||||
return _device->VL53L1X_SensorInit();
|
||||
}
|
||||
|
||||
/*Checks the ID of the device, returns true if ID is correct*/
|
||||
|
||||
bool SFEVL53L1X::checkID()
|
||||
{
|
||||
uint16_t sensorId;
|
||||
_device->VL53L1X_GetSensorId(&sensorId);
|
||||
return sensorId == 0xEACC;
|
||||
}
|
||||
|
||||
/*Turns the sensor on if the Shutdown pin is connected*/
|
||||
|
||||
void SFEVL53L1X::sensorOn()
|
||||
{
|
||||
if (_shutdownPin >= 0)
|
||||
{
|
||||
digitalWrite(_shutdownPin, HIGH);
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
||||
/*Turns the sensor off if the Shutdown pin is connected*/
|
||||
|
||||
void SFEVL53L1X::sensorOff()
|
||||
{
|
||||
if (_shutdownPin >= 0)
|
||||
{
|
||||
digitalWrite(_shutdownPin, LOW);
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
||||
/*Gets the software version number of the current library installed.*/
|
||||
|
||||
VL53L1X_Version_t SFEVL53L1X::getSoftwareVersion()
|
||||
{
|
||||
VL53L1X_Version_t tempVersion;
|
||||
_device->VL53L1X_GetSWVersion(&tempVersion);
|
||||
return tempVersion;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setI2CAddress(uint8_t addr)
|
||||
{
|
||||
_i2cAddress = addr;
|
||||
_device->VL53L1X_SetI2CAddress(addr);
|
||||
}
|
||||
|
||||
int SFEVL53L1X::getI2CAddress()
|
||||
{
|
||||
return _i2cAddress;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::clearInterrupt()
|
||||
{
|
||||
_device->VL53L1X_ClearInterrupt();
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setInterruptPolarityHigh()
|
||||
{
|
||||
_device->VL53L1X_SetInterruptPolarity(1);
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setInterruptPolarityLow()
|
||||
{
|
||||
_device->VL53L1X_SetInterruptPolarity(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the interrupt polarity\n
|
||||
* 1=active high (default), 0=active low
|
||||
*/
|
||||
|
||||
uint8_t SFEVL53L1X::getInterruptPolarity()
|
||||
{
|
||||
uint8_t tmp;
|
||||
_device->VL53L1X_GetInterruptPolarity(&tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::startRanging()
|
||||
{
|
||||
_device->VL53L1X_StartRanging();
|
||||
}
|
||||
|
||||
void SFEVL53L1X::stopRanging()
|
||||
{
|
||||
_device->VL53L1X_StopRanging();
|
||||
}
|
||||
|
||||
bool SFEVL53L1X::checkForDataReady()
|
||||
{
|
||||
uint8_t dataReady;
|
||||
_device->VL53L1X_CheckForDataReady(&dataReady);
|
||||
return (bool)dataReady;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setTimingBudgetInMs(uint16_t timingBudget)
|
||||
{
|
||||
_device->VL53L1X_SetTimingBudgetInMs(timingBudget);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getTimingBudgetInMs()
|
||||
{
|
||||
uint16_t timingBudget;
|
||||
_device->VL53L1X_GetTimingBudgetInMs(&timingBudget);
|
||||
return timingBudget;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setDistanceModeLong()
|
||||
{
|
||||
_device->VL53L1X_SetDistanceMode(2);
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setDistanceModeShort()
|
||||
{
|
||||
_device->VL53L1X_SetDistanceMode(1);
|
||||
}
|
||||
|
||||
uint8_t SFEVL53L1X::getDistanceMode()
|
||||
{
|
||||
uint16_t distanceMode;
|
||||
_device->VL53L1X_GetDistanceMode(&distanceMode);
|
||||
return distanceMode;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setIntermeasurementPeriod(uint16_t intermeasurement)
|
||||
{
|
||||
_device->VL53L1X_SetInterMeasurementInMs(intermeasurement);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getIntermeasurementPeriod()
|
||||
{
|
||||
uint16_t intermeasurement;
|
||||
_device->VL53L1X_GetInterMeasurementInMs(&intermeasurement);
|
||||
return intermeasurement;
|
||||
}
|
||||
|
||||
bool SFEVL53L1X::checkBootState()
|
||||
{
|
||||
uint8_t bootState;
|
||||
_device->VL53L1X_BootState(&bootState);
|
||||
return (bool)bootState;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getSensorID()
|
||||
{
|
||||
uint16_t id;
|
||||
_device->VL53L1X_GetSensorId(&id);
|
||||
return id;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getDistance()
|
||||
{
|
||||
uint16_t distance;
|
||||
_device->VL53L1X_GetDistance(&distance);
|
||||
return (int)distance;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getSignalPerSpad()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetSignalPerSpad(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getAmbientPerSpad()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetAmbientPerSpad(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getSignalRate()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetSignalRate(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getSpadNb()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetSpadNb(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getAmbientRate()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetAmbientRate(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint8_t SFEVL53L1X::getRangeStatus()
|
||||
{
|
||||
uint8_t temp;
|
||||
_device->VL53L1X_GetRangeStatus(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setOffset(int16_t offset)
|
||||
{
|
||||
_device->VL53L1X_SetOffset(offset);
|
||||
}
|
||||
|
||||
int16_t SFEVL53L1X::getOffset()
|
||||
{
|
||||
int16_t temp;
|
||||
_device->VL53L1X_GetOffset(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setXTalk(uint16_t xTalk)
|
||||
{
|
||||
_device->VL53L1X_SetXtalk(xTalk);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getXTalk()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetXtalk(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setDistanceThreshold(uint16_t lowThresh, uint16_t hiThresh, uint8_t window)
|
||||
{
|
||||
_device->VL53L1X_SetDistanceThreshold(lowThresh, hiThresh, window, 1);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getDistanceThresholdWindow()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetDistanceThresholdWindow(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getDistanceThresholdLow()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetDistanceThresholdLow(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getDistanceThresholdHigh()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetDistanceThresholdHigh(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setROI(uint8_t x, uint8_t y, uint8_t opticalCenter)
|
||||
{
|
||||
_device->VL53L1X_SetROI(x, y, opticalCenter);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getROIX()
|
||||
{
|
||||
uint16_t tempX;
|
||||
uint16_t tempY;
|
||||
_device->VL53L1X_GetROI_XY(&tempX, &tempY);
|
||||
return tempX;
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getROIY()
|
||||
{
|
||||
uint16_t tempX;
|
||||
uint16_t tempY;
|
||||
_device->VL53L1X_GetROI_XY(&tempX, &tempY);
|
||||
return tempY;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setSignalThreshold(uint16_t signalThreshold)
|
||||
{
|
||||
_device->VL53L1X_SetSignalThreshold(signalThreshold);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getSignalThreshold()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetSignalThreshold(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::setSigmaThreshold(uint16_t sigmaThreshold)
|
||||
{
|
||||
_device->VL53L1X_SetSigmaThreshold(sigmaThreshold);
|
||||
}
|
||||
|
||||
uint16_t SFEVL53L1X::getSigmaThreshold()
|
||||
{
|
||||
uint16_t temp;
|
||||
_device->VL53L1X_GetSigmaThreshold(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void SFEVL53L1X::startTemperatureUpdate()
|
||||
{
|
||||
_device->VL53L1X_StartTemperatureUpdate();
|
||||
}
|
||||
|
||||
void SFEVL53L1X::calibrateOffset(uint16_t targetDistanceInMm)
|
||||
{
|
||||
int16_t offset = getOffset();
|
||||
_device->VL53L1X_CalibrateOffset(targetDistanceInMm, &offset);
|
||||
}
|
||||
|
||||
void SFEVL53L1X::calibrateXTalk(uint16_t targetDistanceInMm)
|
||||
{
|
||||
uint16_t xTalk = getXTalk();
|
||||
_device->VL53L1X_CalibrateXtalk(targetDistanceInMm, &xTalk);
|
||||
};
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
This is a library written for the VL53L1X I2C Distance sensor.
|
||||
|
||||
Written by Andy England @ SparkFun Electronics, October 17th, 2017
|
||||
|
||||
The sensor uses I2C to communicate, as well as a single (optional)
|
||||
interrupt line that is not currently supported in this driver.
|
||||
|
||||
https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library
|
||||
|
||||
Do you like this library? Help support SparkFun. Buy a board!
|
||||
|
||||
Development environment specifics:
|
||||
Arduino IDE 1.8.1
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Wire.h"
|
||||
#include "RangeSensor.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
#include "vl53l1x_class.h"
|
||||
|
||||
class SFEVL53L1X
|
||||
{
|
||||
public:
|
||||
SFEVL53L1X(TwoWire &i2cPort = Wire, int shutdownPin = -1, int interruptPin = -1); //Constructs our Distance sensor without an interrupt or shutdown pin
|
||||
bool init(); //Deprecated version of begin
|
||||
bool begin(); //Initialization of sensor
|
||||
bool checkID(); //Check the ID of the sensor, returns true if ID is correct
|
||||
void sensorOn(); //Toggles shutdown pin to turn sensor on and off
|
||||
void sensorOff(); //Toggles shutdown pin to turn sensor on and off
|
||||
VL53L1X_Version_t getSoftwareVersion(); //Get's the current ST software version
|
||||
void setI2CAddress(uint8_t addr); //Set the I2C address
|
||||
int getI2CAddress(); //Get the I2C address
|
||||
void clearInterrupt(); // Clear the interrupt flag
|
||||
void setInterruptPolarityHigh(); //Set the polarity of an active interrupt to High
|
||||
void setInterruptPolarityLow(); //Set the polarity of an active interrupt to Low
|
||||
uint8_t getInterruptPolarity(); //get the current interrupt polarity
|
||||
void startRanging(); //Begins taking measurements
|
||||
void stopRanging(); //Stops taking measurements
|
||||
bool checkForDataReady(); //Checks the to see if data is ready
|
||||
void setTimingBudgetInMs(uint16_t timingBudget); //Set the timing budget for a measurement
|
||||
uint16_t getTimingBudgetInMs(); //Get the timing budget for a measurement
|
||||
void setDistanceModeLong(); //Set to 4M range
|
||||
void setDistanceModeShort(); //Set to 1.3M range
|
||||
uint8_t getDistanceMode(); //Get the distance mode, returns 1 for short and 2 for long
|
||||
void setIntermeasurementPeriod(uint16_t intermeasurement); //Set time between measurements in ms
|
||||
uint16_t getIntermeasurementPeriod(); //Get time between measurements in ms
|
||||
bool checkBootState(); //Check if the VL53L1X has been initialized
|
||||
uint16_t getSensorID(); //Get the sensor ID
|
||||
uint16_t getDistance(); //Returns distance
|
||||
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.
|
||||
uint16_t getAmbientPerSpad(); //Returns the ambient noise when not measuring a signal in kcps/SPAD.
|
||||
uint16_t getSignalRate(); //Returns the signal rate in kcps. All SPADs combined.
|
||||
uint16_t getSpadNb(); //Returns the current number of enabled SPADs
|
||||
uint16_t getAmbientRate(); // Returns the total ambinet rate in kcps. All SPADs combined.
|
||||
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
|
||||
void setOffset(int16_t offset); //Manually set an offset in mm
|
||||
int16_t getOffset(); //Get the current offset in mm
|
||||
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.
|
||||
uint16_t getXTalk(); //Returns the current crosstalk value in cps.
|
||||
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.
|
||||
//0: Interrupt triggered on measured distance below lowThresh.
|
||||
//1: Interrupt triggered on measured distance above hiThresh.
|
||||
//2: Interrupt triggered on measured distance outside of bounds.
|
||||
//3: Interrupt triggered on measured distance inside of bounds.
|
||||
uint16_t getDistanceThresholdWindow(); //Returns distance threshold window option
|
||||
uint16_t getDistanceThresholdLow(); //Returns lower bound in mm.
|
||||
uint16_t getDistanceThresholdHigh(); //Returns upper bound in mm
|
||||
/**Table of Optical Centers**
|
||||
*
|
||||
* 128,136,144,152,160,168,176,184, 192,200,208,216,224,232,240,248
|
||||
* 129,137,145,153,161,169,177,185, 193,201,209,217,225,233,241,249
|
||||
* 130,138,146,154,162,170,178,186, 194,202,210,218,226,234,242,250
|
||||
* 131,139,147,155,163,171,179,187, 195,203,211,219,227,235,243,251
|
||||
* 132,140,148,156,164,172,180,188, 196,204,212,220,228,236,244,252
|
||||
* 133,141,149,157,165,173,181,189, 197,205,213,221,229,237,245,253
|
||||
* 134,142,150,158,166,174,182,190, 198,206,214,222,230,238,246,254
|
||||
* 135,143,151,159,167,175,183,191, 199,207,215,223,231,239,247,255
|
||||
|
||||
* 127,119,111,103, 95, 87, 79, 71, 63, 55, 47, 39, 31, 23, 15, 7
|
||||
* 126,118,110,102, 94, 86, 78, 70, 62, 54, 46, 38, 30, 22, 14, 6
|
||||
* 125,117,109,101, 93, 85, 77, 69, 61, 53, 45, 37, 29, 21, 13, 5
|
||||
* 124,116,108,100, 92, 84, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4
|
||||
* 123,115,107, 99, 91, 83, 75, 67, 59, 51, 43, 35, 27, 19, 11, 3
|
||||
* 122,114,106, 98, 90, 82, 74, 66, 58, 50, 42, 34, 26, 18, 10, 2
|
||||
* 121,113,105, 97, 89, 81, 73, 65, 57, 49, 41, 33, 25, 17, 9, 1
|
||||
* 120,112,104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0 Pin 1
|
||||
*
|
||||
* To set the center, set the pad that is to the right and above the exact center of the region you'd like to measure as your opticalCenter*/
|
||||
void setROI(uint8_t x, uint8_t y, uint8_t opticalCenter); //Set the height and width of the ROI(region of interest) in SPADs, lowest possible option is 4. Set optical center based on above table
|
||||
uint16_t getROIX(); //Returns the width of the ROI in SPADs
|
||||
uint16_t getROIY(); //Returns the height of the ROI in SPADs
|
||||
void setSignalThreshold(uint16_t signalThreshold); //Programs the necessary threshold to trigger a measurement. Default is 1024 kcps.
|
||||
uint16_t getSignalThreshold(); //Returns the signal threshold in kcps
|
||||
void setSigmaThreshold(uint16_t sigmaThreshold); //Programs a new sigma threshold in mm. (default=15 mm)
|
||||
uint16_t getSigmaThreshold(); //Returns the current sigma threshold.
|
||||
void startTemperatureUpdate(); //Recalibrates the sensor for temperature changes. Run this any time the temperature has changed by more than 8°C
|
||||
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.
|
||||
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.
|
||||
private:
|
||||
TwoWire *_i2cPort;
|
||||
int _shutdownPin;
|
||||
int _interruptPin;
|
||||
int _i2cAddress = 0x52;
|
||||
VL53L1X* _device;
|
||||
};
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core and is dual licensed,
|
||||
* either 'STMicroelectronics
|
||||
* Proprietary license'
|
||||
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* 'STMicroelectronics Proprietary license'
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
* terms at www.st.com/sla0081
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_error_codes.h
|
||||
*
|
||||
* @brief Error Code definitions for VL53L1 API.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_ERROR_CODES_H_
|
||||
#define _VL53L1_ERROR_CODES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/** @defgroup VL53L1_define_Error_group Error and Warning code returned by API
|
||||
* The following DEFINE are used to identify the PAL ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef int8_t VL53L1_Error;
|
||||
|
||||
#define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
|
||||
#define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
|
||||
/*!< Warning invalid calibration data may be in used
|
||||
\a VL53L1_InitData()
|
||||
\a VL53L1_GetOffsetCalibrationData
|
||||
\a VL53L1_SetOffsetCalibrationData */
|
||||
#define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
|
||||
/*!< Warning parameter passed was clipped to min before to be applied */
|
||||
|
||||
#define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
|
||||
/*!< Unqualified error */
|
||||
#define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
|
||||
/*!< Parameter passed is invalid or out of range */
|
||||
#define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
|
||||
/*!< Function is not supported in current mode or configuration */
|
||||
#define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
|
||||
/*!< Device report a ranging error interrupt status */
|
||||
#define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
|
||||
/*!< Aborted due to time out */
|
||||
#define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
|
||||
/*!< Asked mode is not supported by the device */
|
||||
#define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
|
||||
/*!< ... */
|
||||
#define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
|
||||
/*!< Supplied buffer is larger than I2C supports */
|
||||
#define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
|
||||
/*!< User tried to setup a non-existing GPIO pin */
|
||||
#define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
|
||||
/*!< unsupported GPIO functionality */
|
||||
#define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
|
||||
/*!< error reported from IO functions */
|
||||
#define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
|
||||
/*!< The command is not allowed in the current device state
|
||||
* (power down) */
|
||||
#define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
|
||||
/*!< In the function a division by zero occurs */
|
||||
#define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
|
||||
/*!< Error during reference SPAD initialization */
|
||||
#define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
|
||||
/*!< GPH sync interrupt check fail - API out of sync with device*/
|
||||
#define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
|
||||
/*!< Stream count check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
|
||||
/*!< GPH ID check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
|
||||
/*!< Zone dynamic config stream count check failed - API out of sync */
|
||||
#define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
|
||||
/*!< Zone dynamic config GPH ID check failed - API out of sync */
|
||||
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
|
||||
/*!< Thrown when run_xtalk_extraction fn has 0 succesful samples
|
||||
* when using the full array to sample the xtalk. In this case there is
|
||||
* not enough information to generate new Xtalk parm info. The function
|
||||
* will exit and leave the current xtalk parameters unaltered */
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
|
||||
/*!< Thrown when run_xtalk_extraction fn has found that the
|
||||
* avg sigma estimate of the full array xtalk sample is > than the
|
||||
* maximal limit allowed. In this case the xtalk sample is too noisy for
|
||||
* measurement. The function will exit and leave the current xtalk parameters
|
||||
* unaltered. */
|
||||
|
||||
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
|
||||
/*!< Thrown if there one of stages has no valid offset calibration
|
||||
* samples. A fatal error calibration not valid */
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
|
||||
/*!< Thrown if there one of stages has zero effective SPADS
|
||||
* Traps the case when MM1 SPADs is zero.
|
||||
* A fatal error calibration not valid */
|
||||
#define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
|
||||
/*!< Thrown if then some of the zones have no valid samples
|
||||
* A fatal error calibration not valid */
|
||||
|
||||
#define VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH ((VL53L1_Error) - 27)
|
||||
/*!< Thrown if the tuning file key table version does not match with
|
||||
* expected value. The driver expects the key table version to match
|
||||
* the compiled default version number in the define
|
||||
* #VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT
|
||||
* */
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 28)
|
||||
/*!< Thrown if there are less than 5 good SPADs are available. */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 29)
|
||||
/*!< Thrown if the final reference rate is greater than
|
||||
the upper reference rate limit - default is 40 Mcps.
|
||||
Implies a minimum Q3 (x10) SPAD (5) selected */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 30)
|
||||
/*!< Thrown if the final reference rate is less than
|
||||
the lower reference rate limit - default is 10 Mcps.
|
||||
Implies maximum Q1 (x1) SPADs selected */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 31)
|
||||
/*!< Thrown if there is less than the requested number of
|
||||
* valid samples. */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 32)
|
||||
/*!< Thrown if the offset calibration range sigma estimate is greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 33)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() peak rate is greater
|
||||
than that 50.0Mcps. This is the recommended max rate to avoid
|
||||
pile-up influencing the offset measurement */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 34)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() when one of stages
|
||||
range has less that 5.0 effective SPADS. This is the recommended
|
||||
min value to yield a stable offset */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 35)
|
||||
/*!< Thrown if one of more of the zones have less than
|
||||
the requested number of valid samples */
|
||||
#define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 36)
|
||||
/*!< Thrown if one or more zones have sigma estimate value greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement */
|
||||
#define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 37)
|
||||
/*!< Thrown if one of more zones have peak rate higher than
|
||||
that 50.0Mcps. This is the recommended max rate to avoid
|
||||
pile-up influencing the offset measurement */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 38)
|
||||
/*!< Thrown to notify that some of the xtalk samples did not yield
|
||||
* valid ranging pulse data while attempting to measure
|
||||
* the xtalk signal in vl53l1_run_xtalk_extract(). This can signify any of
|
||||
* the zones are missing samples, for further debug information the
|
||||
* xtalk_results struct should be referred to. This warning is for
|
||||
* notification only, the xtalk pulse and shape have still been generated
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39)
|
||||
/*!< Thrown to notify that some of teh xtalk samples used for gradient
|
||||
* generation did not yield valid ranging pulse data while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
|
||||
* that any one of the zones 0-3 yielded no successful samples. The
|
||||
* xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 40)
|
||||
/*!< Thrown to notify that some of the xtalk samples used for gradient
|
||||
* generation did not pass the sigma limit check while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
|
||||
* that any one of the zones 0-3 yielded an avg sigma_mm value > the limit.
|
||||
* The xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
|
||||
#define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 41)
|
||||
/*!< Tells requested functionality has not been implemented yet or
|
||||
* not compatible with the device */
|
||||
#define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
|
||||
/*!< Tells the starting code for platform */
|
||||
/** @} VL53L1_define_Error_group */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _VL53L1_ERROR_CODES_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,561 @@
|
||||
/*******************************************************************************
|
||||
Copyright © 2018, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __VL53L1X_CLASS_H
|
||||
#define __VL53L1X_CLASS_H
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# ifdef VL53L1X_API_EXPORTS
|
||||
# define VL53L1X_API __declspec(dllexport)
|
||||
# else
|
||||
# define VL53L1X_API
|
||||
# endif
|
||||
#else
|
||||
# define VL53L1X_API
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "Arduino.h"
|
||||
#include "Wire.h"
|
||||
#include "RangeSensor.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
|
||||
#define VL53L1X_IMPLEMENTATION_VER_MAJOR 1
|
||||
#define VL53L1X_IMPLEMENTATION_VER_MINOR 0
|
||||
#define VL53L1X_IMPLEMENTATION_VER_SUB 1
|
||||
#define VL53L1X_IMPLEMENTATION_VER_REVISION 0000
|
||||
|
||||
typedef int8_t VL53L1X_ERROR;
|
||||
|
||||
#define SOFT_RESET 0x0000
|
||||
#define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001
|
||||
#define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008
|
||||
#define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016
|
||||
#define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018
|
||||
#define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A
|
||||
#define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E
|
||||
#define MM_CONFIG__INNER_OFFSET_MM 0x0020
|
||||
#define MM_CONFIG__OUTER_OFFSET_MM 0x0022
|
||||
#define GPIO_HV_MUX__CTRL 0x0030
|
||||
#define GPIO__TIO_HV_STATUS 0x0031
|
||||
#define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046
|
||||
#define PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B
|
||||
#define RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E
|
||||
#define RANGE_CONFIG__VCSEL_PERIOD_A 0x0060
|
||||
#define RANGE_CONFIG__VCSEL_PERIOD_B 0x0063
|
||||
#define RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061
|
||||
#define RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062
|
||||
#define RANGE_CONFIG__SIGMA_THRESH 0x0064
|
||||
#define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066
|
||||
#define RANGE_CONFIG__VALID_PHASE_HIGH 0x0069
|
||||
#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD 0x006C
|
||||
#define SYSTEM__THRESH_HIGH 0x0072
|
||||
#define SYSTEM__THRESH_LOW 0x0074
|
||||
#define SD_CONFIG__WOI_SD0 0x0078
|
||||
#define SD_CONFIG__INITIAL_PHASE_SD0 0x007A
|
||||
#define ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F
|
||||
#define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080
|
||||
#define SYSTEM__SEQUENCE_CONFIG 0x0081
|
||||
#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD 0x0082
|
||||
#define SYSTEM__INTERRUPT_CLEAR 0x0086
|
||||
#define SYSTEM__MODE_START 0x0087
|
||||
#define VL53L1_RESULT__RANGE_STATUS 0x0089
|
||||
#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x008C
|
||||
#define RESULT__AMBIENT_COUNT_RATE_MCPS_SD 0x0090
|
||||
#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096
|
||||
#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0098
|
||||
#define VL53L1_RESULT__OSC_CALIBRATE_VAL 0x00DE
|
||||
#define VL53L1_FIRMWARE__SYSTEM_STATUS 0x00E5
|
||||
#define VL53L1_IDENTIFICATION__MODEL_ID 0x010F
|
||||
#define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x013E
|
||||
|
||||
|
||||
#define VL53L1X_DEFAULT_DEVICE_ADDRESS 0x52
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/**
|
||||
* @brief defines SW Version
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t major; /*!< major number */
|
||||
uint8_t minor; /*!< minor number */
|
||||
uint8_t build; /*!< build number */
|
||||
uint32_t revision; /*!< revision number */
|
||||
} VL53L1X_Version_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t I2cDevAddr;
|
||||
TwoWire *I2cHandle;
|
||||
|
||||
} VL53L1_Dev_t;
|
||||
|
||||
typedef VL53L1_Dev_t *VL53L1_DEV;
|
||||
|
||||
|
||||
/* Classes -------------------------------------------------------------------*/
|
||||
/** Class representing a VL53L1 sensor component
|
||||
*/
|
||||
class VL53L1X : public RangeSensor
|
||||
{
|
||||
public:
|
||||
/** Constructor
|
||||
* @param[in] &i2c device I2C to be used for communication
|
||||
* @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
|
||||
* @param[in] DevAddr device address, 0x52 by default
|
||||
*/
|
||||
VL53L1X(TwoWire *i2c, int pin, int pin_gpio1) : RangeSensor(), dev_i2c(i2c), gpio0(pin), gpio1Int(pin_gpio1)
|
||||
{
|
||||
MyDevice.I2cDevAddr=VL53L1X_DEFAULT_DEVICE_ADDRESS;
|
||||
MyDevice.I2cHandle = i2c;
|
||||
Device = &MyDevice;
|
||||
if(gpio0 >= 0)
|
||||
{
|
||||
pinMode(gpio0, OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
/** Destructor
|
||||
*/
|
||||
virtual ~VL53L1X(){}
|
||||
/* warning: VL53L1 class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor.
|
||||
The warning should request to introduce a virtual destructor to make sure to delete the object */
|
||||
|
||||
/*** Interface Methods ***/
|
||||
/*** High level API ***/
|
||||
/**
|
||||
* @brief PowerOn the sensor
|
||||
* @return void
|
||||
*/
|
||||
/* turns on the sensor */
|
||||
virtual void VL53L1_On(void)
|
||||
{
|
||||
if(gpio0 >= 0)
|
||||
{
|
||||
digitalWrite(gpio0, HIGH);
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PowerOff the sensor
|
||||
* @return void
|
||||
*/
|
||||
/* turns off the sensor */
|
||||
virtual void VL53L1_Off(void)
|
||||
{
|
||||
if(gpio0 >= 0)
|
||||
{
|
||||
digitalWrite(gpio0, LOW);
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the sensor with default values
|
||||
* @return 0 on Success
|
||||
*/
|
||||
|
||||
VL53L1X_ERROR InitSensor(uint8_t address){
|
||||
VL53L1X_ERROR status = 0;
|
||||
uint8_t sensorState = 0;
|
||||
VL53L1_Off();
|
||||
VL53L1_On();
|
||||
status = VL53L1X_SetI2CAddress(address);
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
uint8_t byteData;
|
||||
uint16_t wordData;
|
||||
status = VL53L1_RdByte(Device, 0x010F, &byteData);
|
||||
Serial.println("VL53L1X Model_ID: " + String(byteData));
|
||||
status = VL53L1_RdByte(Device, 0x0110, &byteData);
|
||||
Serial.println("VL53L1X Module_Type: " + String(byteData));
|
||||
status = VL53L1_RdWord(Device, 0x010F, &wordData);
|
||||
Serial.println("VL53L1X: " + String(wordData));
|
||||
#endif
|
||||
|
||||
|
||||
while (!sensorState && !status){
|
||||
status = VL53L1X_BootState(&sensorState);
|
||||
delay(2);
|
||||
}
|
||||
if(!status){
|
||||
status = VL53L1X_SensorInit();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief One time device initialization
|
||||
* @param void
|
||||
* @return 0 on success, @a #CALIBRATION_WARNING if failed
|
||||
*/
|
||||
virtual int Init()
|
||||
{
|
||||
return VL53L1X_SensorInit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Read function of the ID device */
|
||||
virtual int ReadID(){
|
||||
uint16_t sensorId;
|
||||
VL53L1X_GetSensorId(&sensorId);
|
||||
if (sensorId == 0xEEAC)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get ranging result and only that
|
||||
* @param pRange_mm Pointer to range distance
|
||||
* @return 0 on success
|
||||
*/
|
||||
int GetDistance(uint32_t *piData)
|
||||
{
|
||||
int status;
|
||||
uint16_t distance;
|
||||
status = VL53L1X_GetDistance(&distance);
|
||||
*piData = (uint32_t) distance;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* VL53L1X_api.h functions */
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function returns the SW driver version
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSWVersion(VL53L1X_Version_t *pVersion);
|
||||
|
||||
/**
|
||||
* @brief This function sets the sensor I2C address used in case multiple devices application, default address 0x52
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetI2CAddress(uint8_t new_address);
|
||||
|
||||
/**
|
||||
* @brief This function loads the 135 bytes default values to initialize the sensor.
|
||||
* @param dev Device address
|
||||
* @return 0:success, != 0:failed
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SensorInit();
|
||||
|
||||
/**
|
||||
* @brief This function clears the interrupt, to be called after a ranging data reading
|
||||
* to arm the interrupt for the next data ready event.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_ClearInterrupt();
|
||||
|
||||
/**
|
||||
* @brief This function programs the interrupt polarity\n
|
||||
* 1=active high (default), 0=active low
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetInterruptPolarity(uint8_t IntPol);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current interrupt polarity\n
|
||||
* 1=active high (default), 0=active low
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetInterruptPolarity(uint8_t *pIntPol);
|
||||
|
||||
/**
|
||||
* @brief This function starts the ranging distance operation\n
|
||||
* The ranging operation is continuous. The clear interrupt has to be done after each get data to allow the interrupt to raise when the next data is ready\n
|
||||
* 1=active high (default), 0=active low, use SetInterruptPolarity() to change the interrupt polarity if required.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_StartRanging();
|
||||
|
||||
/**
|
||||
* @brief This function stops the ranging.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_StopRanging();
|
||||
|
||||
/**
|
||||
* @brief This function checks if the new ranging data is available by polling the dedicated register.
|
||||
* @param : isDataReady==0 -> not ready; isDataReady==1 -> ready
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_CheckForDataReady(uint8_t *isDataReady);
|
||||
|
||||
/**
|
||||
* @brief This function programs the timing budget in ms.
|
||||
* Predefined values = 15, 20, 33, 50, 100(default), 200, 500.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetTimingBudgetInMs(uint16_t TimingBudgetInMs);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current timing budget in ms.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetTimingBudgetInMs(uint16_t *pTimingBudgetInMs);
|
||||
|
||||
/**
|
||||
* @brief This function programs the distance mode (1=short, 2=long(default)).
|
||||
* Short mode max distance is limited to 1.3 m but better ambient immunity.\n
|
||||
* Long mode can range up to 4 m in the dark with 200 ms timing budget.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetDistanceMode(uint16_t DistanceMode);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current distance mode (1=short, 2=long).
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceMode(uint16_t *pDistanceMode);
|
||||
|
||||
/**
|
||||
* @brief This function programs the Intermeasurement period in ms\n
|
||||
* Intermeasurement period must be >/= timing budget. This condition is not checked by the API,
|
||||
* the customer has the duty to check the condition. Default = 100 ms
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetInterMeasurementInMs(uint16_t InterMeasurementInMs);
|
||||
|
||||
/**
|
||||
* @brief This function returns the Intermeasurement period in ms.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetInterMeasurementInMs(uint16_t * pIM);
|
||||
|
||||
/**
|
||||
* @brief This function returns the boot state of the device (1:booted, 0:not booted)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_BootState(uint8_t *state);
|
||||
|
||||
/**
|
||||
* @brief This function returns the sensor id, sensor Id must be 0xEEAC
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSensorId(uint16_t *id);
|
||||
|
||||
/**
|
||||
* @brief This function returns the distance measured by the sensor in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistance(uint16_t *distance);
|
||||
|
||||
/**
|
||||
* @brief This function returns the returned signal per SPAD in kcps/SPAD.
|
||||
* With kcps stands for Kilo Count Per Second
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSignalPerSpad(uint16_t *signalPerSp);
|
||||
|
||||
/**
|
||||
* @brief This function returns the ambient per SPAD in kcps/SPAD
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetAmbientPerSpad(uint16_t *amb);
|
||||
|
||||
/**
|
||||
* @brief This function returns the returned signal in kcps.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSignalRate(uint16_t *signalRate);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current number of enabled SPADs
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSpadNb(uint16_t *spNb);
|
||||
|
||||
/**
|
||||
* @brief This function returns the ambient rate in kcps
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetAmbientRate(uint16_t *ambRate);
|
||||
|
||||
/**
|
||||
* @brief This function returns the ranging status error \n
|
||||
* (0:no error, 1:sigma failed, 2:signal failed, ..., 7:wrap-around)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetRangeStatus(uint8_t *rangeStatus);
|
||||
|
||||
/**
|
||||
* @brief This function programs the offset correction in mm
|
||||
* @param OffsetValue:the offset correction value to program in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetOffset(int16_t OffsetValue);
|
||||
|
||||
/**
|
||||
* @brief This function returns the programmed offset correction value in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetOffset(int16_t *Offset);
|
||||
|
||||
/**
|
||||
* @brief This function programs the xtalk correction value in cps (Count Per Second).\n
|
||||
* This is the number of photons reflected back from the cover glass in cps.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetXtalk(uint16_t XtalkValue);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current programmed xtalk correction value in cps
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetXtalk(uint16_t *Xtalk);
|
||||
|
||||
/**
|
||||
* @brief This function programs the threshold detection mode\n
|
||||
* Example:\n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,0,1): Below 100 \n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,1,1): Above 300 \n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,2,1): Out of window \n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,3,1): In window \n
|
||||
* @param dev : device address
|
||||
* @param ThreshLow(in mm) : the threshold under which one the device raises an interrupt if Window = 0
|
||||
* @param ThreshHigh(in mm) : the threshold above which one the device raises an interrupt if Window = 1
|
||||
* @param Window detection mode : 0=below, 1=above, 2=out, 3=in
|
||||
* @param IntOnNoTarget = 1 (No longer used - just use 1)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetDistanceThreshold(uint16_t ThreshLow,
|
||||
uint16_t ThreshHigh, uint8_t Window,
|
||||
uint8_t IntOnNoTarget);
|
||||
|
||||
/**
|
||||
* @brief This function returns the window detection mode (0=below; 1=above; 2=out; 3=in)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceThresholdWindow(uint16_t *window);
|
||||
|
||||
/**
|
||||
* @brief This function returns the low threshold in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceThresholdLow(uint16_t *low);
|
||||
|
||||
/**
|
||||
* @brief This function returns the high threshold in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceThresholdHigh(uint16_t *high);
|
||||
|
||||
/**
|
||||
* @brief This function programs the ROI (Region of Interest)\n
|
||||
* The ROI position is centered, only the ROI size can be reprogrammed.\n
|
||||
* The smallest acceptable ROI size = 4\n
|
||||
* @param X:ROI Width; Y=ROI Height
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetROI(uint8_t X, uint8_t Y, uint8_t opticalCenter);
|
||||
|
||||
/**
|
||||
*@brief This function returns width X and height Y
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetROI_XY(uint16_t *ROI_X, uint16_t *ROI_Y);
|
||||
|
||||
/**
|
||||
* @brief This function programs a new signal threshold in kcps (default=1024 kcps\n
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetSignalThreshold(uint16_t signal);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current signal threshold in kcps
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSignalThreshold(uint16_t *signal);
|
||||
|
||||
/**
|
||||
* @brief This function programs a new sigma threshold in mm (default=15 mm)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetSigmaThreshold(uint16_t sigma);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current sigma threshold in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSigmaThreshold(uint16_t *signal);
|
||||
|
||||
/**
|
||||
* @brief This function performs the temperature calibration.
|
||||
* It is recommended to call this function any time the temperature might have changed by more than 8 deg C
|
||||
* without sensor ranging activity for an extended period.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_StartTemperatureUpdate();
|
||||
|
||||
|
||||
/* VL53L1X_calibration.h functions */
|
||||
|
||||
/**
|
||||
* @brief This function performs the offset calibration.\n
|
||||
* The function returns the offset value found and programs the offset compensation into the device.
|
||||
* @param TargetDistInMm target distance in mm, ST recommended 100 mm
|
||||
* Target reflectance = grey17%
|
||||
* @return 0:success, !=0: failed
|
||||
* @return offset pointer contains the offset found in mm
|
||||
*/
|
||||
int8_t VL53L1X_CalibrateOffset(uint16_t TargetDistInMm, int16_t *offset);
|
||||
|
||||
/**
|
||||
* @brief This function performs the xtalk calibration.\n
|
||||
* The function returns the xtalk value found and programs the xtalk compensation to the device
|
||||
* @param TargetDistInMm target distance in mm\n
|
||||
* The target distance : the distance where the sensor start to "under range"\n
|
||||
* due to the influence of the photons reflected back from the cover glass becoming strong\n
|
||||
* It's also called inflection point\n
|
||||
* Target reflectance = grey 17%
|
||||
* @return 0: success, !=0: failed
|
||||
* @return xtalk pointer contains the xtalk value found in cps (number of photons in count per second)
|
||||
*/
|
||||
int8_t VL53L1X_CalibrateXtalk(uint16_t TargetDistInMm, uint16_t *xtalk);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/* Write and read functions from I2C */
|
||||
|
||||
VL53L1X_ERROR VL53L1_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data);
|
||||
VL53L1X_ERROR VL53L1_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data);
|
||||
VL53L1X_ERROR VL53L1_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data);
|
||||
VL53L1X_ERROR VL53L1_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data);
|
||||
VL53L1X_ERROR VL53L1_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data);
|
||||
VL53L1X_ERROR VL53L1_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data);
|
||||
VL53L1X_ERROR VL53L1_UpdateByte(VL53L1_DEV dev, uint16_t index, uint8_t AndData, uint8_t OrData);
|
||||
|
||||
VL53L1X_ERROR VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count);
|
||||
VL53L1X_ERROR VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count);
|
||||
|
||||
VL53L1X_ERROR VL53L1_I2CWrite(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes);
|
||||
VL53L1X_ERROR VL53L1_I2CRead(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes);
|
||||
VL53L1X_ERROR VL53L1_GetTickCount(uint32_t *ptick_count_ms);
|
||||
VL53L1X_ERROR VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us);
|
||||
VL53L1X_ERROR VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms);
|
||||
|
||||
VL53L1X_ERROR VL53L1_WaitValueMaskEx(VL53L1_Dev_t *pdev, uint32_t timeout_ms, uint16_t index, uint8_t value, uint8_t mask, uint32_t poll_delay_ms);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/* IO Device */
|
||||
TwoWire *dev_i2c;
|
||||
/* Digital out pin */
|
||||
int gpio0;
|
||||
int gpio1Int;
|
||||
/* Device data */
|
||||
VL53L1_Dev_t MyDevice;
|
||||
VL53L1_DEV Device;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _VL53L1X_CLASS_H_ */
|
||||
@@ -368,6 +368,7 @@ static const char DATA_ESPEASY_DEFAULT_MIN_CSS[] PROGMEM = {
|
||||
// #define USES_P107 // Si1145
|
||||
// #define USES_P110 // VL53L0X Time of Flight sensor
|
||||
// #define USES_P111 // RF522 RFID reader
|
||||
// #define USES_P113 // VL53L1X ToF
|
||||
|
||||
|
||||
// Special plugins needing IR library
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
#include "_Plugin_Helper.h"
|
||||
#ifdef USES_P113
|
||||
|
||||
// #######################################################################################################
|
||||
// ########################### Plugin 113 VL53L1X I2C Ranging LIDAR #################################
|
||||
// #######################################################################################################
|
||||
|
||||
// Changelog:
|
||||
// 2021-04-06, tonhuisman: Remove Interval optional attribute to avoid system overload, cleanup source
|
||||
// 2021-04-05, tonhuisman: Add VL53L1X Time of Flight sensor to main repo (similar to but not compatible with VL53L0X)
|
||||
|
||||
// needs SparkFun_VL53L1X library from https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library
|
||||
|
||||
# include "src/PluginStructs/P113_data_struct.h"
|
||||
|
||||
# define PLUGIN_113
|
||||
# define PLUGIN_ID_113 113
|
||||
# define PLUGIN_NAME_113 "Distance - VL53L1X (400cm) [TESTING]"
|
||||
# define PLUGIN_VALUENAME1_113 "Distance"
|
||||
# define PLUGIN_VALUENAME2_113 "Ambient"
|
||||
|
||||
|
||||
boolean Plugin_113(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
boolean success = false;
|
||||
|
||||
switch (function)
|
||||
{
|
||||
case PLUGIN_DEVICE_ADD:
|
||||
{
|
||||
Device[++deviceCount].Number = PLUGIN_ID_113;
|
||||
Device[deviceCount].Type = DEVICE_TYPE_I2C;
|
||||
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SINGLE;
|
||||
Device[deviceCount].Ports = 0;
|
||||
Device[deviceCount].PullUpOption = false;
|
||||
Device[deviceCount].InverseLogicOption = false;
|
||||
Device[deviceCount].FormulaOption = true;
|
||||
Device[deviceCount].ValueCount = 2;
|
||||
Device[deviceCount].SendDataOption = true;
|
||||
Device[deviceCount].TimerOption = true;
|
||||
Device[deviceCount].GlobalSyncOption = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_GET_DEVICENAME:
|
||||
{
|
||||
string = F(PLUGIN_NAME_113);
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_GET_DEVICEVALUENAMES:
|
||||
{
|
||||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_113));
|
||||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_113));
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
|
||||
{
|
||||
byte choice = PCONFIG(0);
|
||||
int optionValues[2] = { 0x29, 0x30 };
|
||||
addFormSelectorI2C(F("plugin_113_vl53l1x_i2c"), 2, optionValues, choice);
|
||||
|
||||
// addFormNote(F("SDO Low=0x29, High=0x30"));
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WEBFORM_LOAD:
|
||||
{
|
||||
unsigned int choiceMode2 = PCONFIG(1);
|
||||
{
|
||||
String optionsMode2[6];
|
||||
optionsMode2[0] = F("100ms (Normal)");
|
||||
optionsMode2[1] = F("20ms (Fastest)");
|
||||
optionsMode2[2] = F("33ms (Fast)");
|
||||
optionsMode2[3] = F("50ms");
|
||||
optionsMode2[4] = F("200ms (Accurate)");
|
||||
optionsMode2[5] = F("500ms");
|
||||
int optionValuesMode2[6] = { 100, 20, 33, 50, 200, 500 };
|
||||
addFormSelector(F("Timing"), F("plugin_113_vl53l1x_timing"), 6, optionsMode2, optionValuesMode2, choiceMode2);
|
||||
}
|
||||
|
||||
int choiceMode3 = PCONFIG(2);
|
||||
{
|
||||
String optionsMode3[2];
|
||||
optionsMode3[0] = F("Normal (~130cm)");
|
||||
optionsMode3[1] = F("Long (~400cm)");
|
||||
int optionValuesMode3[2] = { 0, 1 };
|
||||
addFormSelector(F("Range"), F("plugin_113_vl53l1x_range"), 2, optionsMode3, optionValuesMode3, choiceMode3);
|
||||
}
|
||||
addFormCheckBox(F("Send event when value unchanged"), F("plugin_113_vl53l1x_notchanged"), PCONFIG(3) == 1);
|
||||
addFormNote(F("When checked, 'Trigger delta' setting is ignored!"));
|
||||
|
||||
addFormNumericBox(F("Trigger delta"), F("plugin_113_trigger_delta"), PCONFIG(4), 0, 100);
|
||||
addUnit(F("0-100mm"));
|
||||
addFormNote(F("Minimal change in Distance to trigger an event."));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WEBFORM_SAVE:
|
||||
{
|
||||
PCONFIG(0) = getFormItemInt(F("plugin_113_vl53l1x_i2c"));
|
||||
PCONFIG(1) = getFormItemInt(F("plugin_113_vl53l1x_timing"));
|
||||
PCONFIG(2) = getFormItemInt(F("plugin_113_vl53l1x_range"));
|
||||
PCONFIG(3) = isFormItemChecked(F("plugin_113_vl53l1x_notchanged")) ? 1 : 0;
|
||||
PCONFIG(4) = getFormItemInt(F("plugin_113_trigger_delta"));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
initPluginTaskData(event->TaskIndex, new (std::nothrow) P113_data_struct(PCONFIG(0), PCONFIG(1), PCONFIG(2) == 1));
|
||||
P113_data_struct *P113_data = static_cast<P113_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P113_data) {
|
||||
success = P113_data->begin(); // Start the sensor
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_READ:
|
||||
{
|
||||
P113_data_struct *P113_data = static_cast<P113_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P113_data) {
|
||||
uint16_t dist = P113_data->readDistance();
|
||||
uint16_t ambient = P113_data->readAmbient();
|
||||
bool triggered = (dist > UserVar[event->BaseVarIndex] + PCONFIG(4)) || (dist < UserVar[event->BaseVarIndex] - PCONFIG(4));
|
||||
|
||||
if (P113_data->isReadSuccessful() && (triggered || (PCONFIG(3) == 1)) && (dist != 0xFFFF)) {
|
||||
UserVar[event->BaseVarIndex + 0] = dist;
|
||||
UserVar[event->BaseVarIndex + 1] = ambient;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_FIFTY_PER_SECOND:
|
||||
{
|
||||
P113_data_struct *P113_data = static_cast<P113_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P113_data) {
|
||||
if (P113_data->startRead()) {
|
||||
if (P113_data->readAvailable() && (Settings.TaskDeviceTimer[event->TaskIndex] == 0)) { // Trigger as soon as there's a valid
|
||||
// measurement and the time-out is set to 0
|
||||
Scheduler.schedule_task_device_timer(event->TaskIndex, millis() + 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
#endif // USES_P113
|
||||
@@ -966,6 +966,7 @@ To create/register a plugin, you have to :
|
||||
//#define USES_P108 // DDS238-x ZN MODBUS energy meter (was P224 in the Playground)
|
||||
// #define USES_P110 // VL53L0X Time of Flight sensor
|
||||
// #define USES_P111 // RC522 RFID reader
|
||||
// #define USES_P113 // VL53L1X ToF
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#include "../PluginStructs/P113_data_struct.h"
|
||||
|
||||
#ifdef USES_P113
|
||||
|
||||
P113_data_struct::P113_data_struct(uint8_t i2c_addr, int timing, bool range) : i2cAddress(i2c_addr), timing(timing), range(range) {}
|
||||
|
||||
// **************************************************************************/
|
||||
// Initialize VL53L1X
|
||||
// **************************************************************************/
|
||||
bool P113_data_struct::begin() {
|
||||
initState = true;
|
||||
|
||||
sensor.setI2CAddress(i2cAddress); // Initialize for configured address
|
||||
|
||||
if (sensor.begin() != 0) {
|
||||
String log = F("VL53L1X: Sensor not found, init failed for 0x");
|
||||
log += String(i2cAddress, HEX);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
initState = false;
|
||||
return initState;
|
||||
}
|
||||
|
||||
sensor.setTimingBudgetInMs(timing);
|
||||
|
||||
if (range) {
|
||||
sensor.setDistanceModeLong();
|
||||
} else {
|
||||
sensor.setDistanceModeShort();
|
||||
}
|
||||
|
||||
return initState;
|
||||
}
|
||||
|
||||
bool P113_data_struct::startRead() {
|
||||
if (initState && !readActive) {
|
||||
sensor.startRanging();
|
||||
readActive = true;
|
||||
distance = -1;
|
||||
}
|
||||
return readActive;
|
||||
}
|
||||
|
||||
bool P113_data_struct::readAvailable() {
|
||||
bool ready = sensor.checkForDataReady();
|
||||
|
||||
if (ready) {
|
||||
distance = sensor.getDistance();
|
||||
sensor.clearInterrupt();
|
||||
sensor.stopRanging();
|
||||
|
||||
// readActive = false;
|
||||
}
|
||||
return ready;
|
||||
}
|
||||
|
||||
uint16_t P113_data_struct::readDistance() {
|
||||
success = false;
|
||||
|
||||
# if defined(P113_DEBUG) || defined(P113_DEBUG_DEBUG)
|
||||
String log;
|
||||
# endif // if defined(P113_DEBUG) || defined(P113_DEBUG_DEBUG)
|
||||
# ifdef P113_DEBUG_DEBUG
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
log = F("VL53L1X : idx: 0x");
|
||||
log += String(i2cAddress, HEX);
|
||||
log += F(" init: ");
|
||||
log += String(initState, BIN);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
# endif // P113_DEBUG_DEBUG
|
||||
|
||||
success = true;
|
||||
readActive = false;
|
||||
|
||||
if (distance >= 8190) {
|
||||
# ifdef P113_DEBUG_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, "VL53L1X: NO MEASUREMENT");
|
||||
# endif // P113_DEBUG_DEBUG
|
||||
success = false;
|
||||
}
|
||||
|
||||
# ifdef P113_DEBUG
|
||||
log = F("VL53L1X: Address: 0x");
|
||||
log += String(i2cAddress, HEX);
|
||||
log += F(" / Timing: ");
|
||||
log += String(timing, DEC);
|
||||
log += F(" / Long Range: ");
|
||||
log += String(range, BIN);
|
||||
log += F(" / Distance: ");
|
||||
log += distance;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
# endif // P113_DEBUG
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
uint16_t P113_data_struct::readAmbient() {
|
||||
return sensor.getAmbientRate();
|
||||
}
|
||||
|
||||
bool P113_data_struct::isReadSuccessful() {
|
||||
return success;
|
||||
}
|
||||
|
||||
#endif // ifdef USES_P113
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef PLUGINSTRUCTS_P113_DATA_STRUCT_H
|
||||
#define PLUGINSTRUCTS_P113_DATA_STRUCT_H
|
||||
|
||||
#include "../../_Plugin_Helper.h"
|
||||
#ifdef USES_P113
|
||||
|
||||
# define P113_DEBUG // Enable debugging output (INFO loglevel)
|
||||
# define P113_DEBUG_DEBUG // Enable extended debugging output (DEBUG loglevel)
|
||||
|
||||
# ifdef LIMIT_BUILD_SIZE
|
||||
# ifdef P113_DEBUG_DEBUG
|
||||
# undef P113_DEBUG_DEBUG
|
||||
# endif // ifdef P113_DEBUG_DEBUG
|
||||
# endif // ifdef LIMIT_BUILD_SIZE
|
||||
|
||||
# include <Wire.h>
|
||||
# include <SparkFun_VL53L1X.h>
|
||||
|
||||
struct P113_data_struct : public PluginTaskData_base {
|
||||
public:
|
||||
|
||||
P113_data_struct(uint8_t i2c_addr,
|
||||
int timing,
|
||||
bool range);
|
||||
|
||||
bool begin();
|
||||
bool startRead();
|
||||
bool readAvailable();
|
||||
uint16_t readDistance();
|
||||
uint16_t readAmbient();
|
||||
bool isReadSuccessful();
|
||||
|
||||
private:
|
||||
|
||||
SFEVL53L1X sensor;
|
||||
|
||||
uint8_t i2cAddress;
|
||||
bool initState = false;
|
||||
int timing;
|
||||
bool range;
|
||||
bool success = false;
|
||||
bool readActive = false;
|
||||
uint16_t distance;
|
||||
};
|
||||
#endif // ifdef USES_P113
|
||||
#endif // ifndef PLUGINSTRUCTS_P113_DATA_STRUCT_H
|
||||
@@ -164,10 +164,10 @@ String getKnownI2Cdevice(byte address) {
|
||||
result = F("PCF8574,MCP23017,LCD,PN532");
|
||||
break;
|
||||
case 0x29:
|
||||
result = F("TSL2561,TCS34725,VL53L0X");
|
||||
result = F("TSL2561,TCS34725,VL53L0X,VL53L1X");
|
||||
break;
|
||||
case 0x30:
|
||||
result = F("VL53L0X");
|
||||
result = F("VL53L0X,VL53L1X");
|
||||
break;
|
||||
case 0x38:
|
||||
case 0x3A:
|
||||
|
||||
Reference in New Issue
Block a user