├── .github └── workflows │ └── Continuous-Integration.yml ├── LICENSE.md ├── README.md ├── examples ├── VL53L3CX_Sat_HelloWorld │ └── VL53L3CX_Sat_HelloWorld.ino └── VL53L3CX_Sat_HelloWorld_Interrupt │ └── VL53L3CX_Sat_HelloWorld_Interrupt.ino ├── extras └── codespell-ignore-words-list.txt ├── keywords.txt ├── library.properties └── src ├── ComponentObject.h ├── RangeSensor.h ├── vl53lx_class.cpp ├── vl53lx_class.h └── vl53lx_def.h /.github/workflows/Continuous-Integration.yml: -------------------------------------------------------------------------------- 1 | name: VL53L3CX Continuous Integration 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths-ignore: 7 | - '*' 8 | - '**.md' 9 | - '**.txt' 10 | pull_request: 11 | paths-ignore: 12 | - '*' 13 | - '**.md' 14 | - '**.txt' 15 | jobs: 16 | astyle_check: 17 | runs-on: ubuntu-latest 18 | name: AStyle check 19 | steps: 20 | # First of all, clone the repo using the checkout action. 21 | - name: Checkout 22 | uses: actions/checkout@main 23 | 24 | - name: Astyle check 25 | id: Astyle 26 | uses: stm32duino/actions/astyle-check@main 27 | 28 | # Use the output from the `Astyle` step 29 | - name: Astyle Errors 30 | if: failure() 31 | run: | 32 | cat ${{ steps.Astyle.outputs.astyle-result }} 33 | exit 1 34 | codespell: 35 | name: Check for spelling errors 36 | runs-on: ubuntu-latest 37 | steps: 38 | - name: Checkout 39 | uses: actions/checkout@main 40 | 41 | # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md 42 | - name: Spell check 43 | uses: codespell-project/actions-codespell@master 44 | with: 45 | check_filenames: true 46 | check_hidden: true 47 | # In the event of a false positive, add the word in all lower case to this file: 48 | ignore_words_file: ./extras/codespell-ignore-words-list.txt 49 | lib_build: 50 | runs-on: ubuntu-latest 51 | name: Library compilation 52 | steps: 53 | # First of all, clone the repo using the checkout action. 54 | - name: Checkout 55 | uses: actions/checkout@main 56 | 57 | - name: Compilation 58 | id: Compile 59 | uses: stm32duino/actions/compile-examples@main 60 | with: 61 | board-pattern: "NUCLEO_L476RG" 62 | 63 | # Use the output from the `Compile` step 64 | - name: Compilation Errors 65 | if: failure() 66 | run: | 67 | cat ${{ steps.Compile.outputs.compile-result }} 68 | exit 1 69 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | COPYRIGHT(c) 2020 STMicroelectronics 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 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. 7 | 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. 8 | 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. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VL53L3CX 2 | Arduino library to support the VL53L3CX Time-of-Flight ranging sensor with advanced multi-object detection. 3 | 4 | ## API 5 | 6 | This sensor uses I2C to communicate. And I2C instance is required to access to the sensor. 7 | The APIs provide simple distance measure and multi-object detection in both polling and interrupt modes. 8 | 9 | ## Examples 10 | 11 | There are 2 examples with the VL53L3CX library. 12 | 13 | In order to use these examples you need to connect the VL53L3CX satellite sensor directly to the Nucleo board with wires as explained below: 14 | - pin 1 (Interrupt) of the VL53L3CX satellite connected to pin A2 of the Nucleo board 15 | - pin 2 (SCL_I) of the VL53L3CX satellite connected to pin D15 (SCL) of the Nucleo board with a Pull-Up resistor of 4.7 KOhm 16 | - pin 3 (XSDN_I) of the VL53L3CX satellite connected to pin A1 of the Nucleo board 17 | - pin 4 (SDA_I) of the VL53L3CX satellite connected to pin D14 (SDA) of the Nucleo board with a Pull-Up resistor of 4.7 KOhm 18 | - pin 5 (VDD) of the VL53L3CX satellite connected to 3V3 pin of the Nucleo board 19 | - pin 6 (GND) of the VL53L3CX satellite connected to GND of the Nucleo board 20 | - pins 7, 8, 9 and 10 are not connected. 21 | 22 | * VL53L3CX_Sat_HelloWorld: This example code is to show how to get multi-object detection and proximity 23 | values of the VL53L3CX satellite sensor in polling mode. 24 | 25 | * VL53L3CX_Sat_HelloWorld_Interrupt: This example code is to show how to get multi-object detection and proximity 26 | values of the VL53L3CX satellite sensor in interrupt mode. 27 | 28 | ## Note 29 | 30 | The VL53L3CX is a fully integrated miniature module with a low power microcontroller with advanced digital firmware. 31 | Detection with full field of view (FoV) is up to 300 cm +. It works with many types of glass roofing materials. 32 | Xshutdown (reset) and stop GPIO are integrated to optimize remote operation. 33 | 34 | ## Documentation 35 | 36 | You can find the source files at 37 | https://github.com/stm32duino/VL53L3CX 38 | 39 | The VL53L3CX datasheet is available at 40 | https://www.st.com/content/st_com/en/products/imaging-and-photonics-solutions/proximity-sensors/vl53l3cx.html 41 | -------------------------------------------------------------------------------- /examples/VL53L3CX_Sat_HelloWorld/VL53L3CX_Sat_HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file VL53L3CX_Sat_HelloWorld.ino 4 | * @author SRA 5 | * @version V1.0.0 6 | * @date 30 July 2020 7 | * @brief Arduino test application for the STMicrolectronics VL53L3CX 8 | * proximity sensor satellite based on FlightSense. 9 | * This application makes use of C++ classes obtained from the C 10 | * components' drivers. 11 | ****************************************************************************** 12 | * @attention 13 | * 14 | *

© COPYRIGHT(c) 2020 STMicroelectronics

15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************** 39 | */ 40 | /* 41 | * To use this sketch you need to connect the VL53L3CX satellite sensor directly to the Nucleo board with wires in this way: 42 | * pin 1 (Interrupt) of the VL53L3CX satellite connected to pin A2 of the Nucleo board 43 | * pin 2 (SCL_I) of the VL53L3CX satellite connected to pin D15 (SCL) of the Nucleo board with a Pull-Up resistor of 4.7 KOhm 44 | * pin 3 (XSDN_I) of the VL53L3CX satellite connected to pin A1 of the Nucleo board 45 | * pin 4 (SDA_I) of the VL53L3CX satellite connected to pin D14 (SDA) of the Nucleo board with a Pull-Up resistor of 4.7 KOhm 46 | * pin 5 (VDD) of the VL53L3CX satellite connected to 3V3 pin of the Nucleo board 47 | * pin 6 (GND) of the VL53L3CX satellite connected to GND of the Nucleo board 48 | * pins 7, 8, 9 and 10 are not connected. 49 | */ 50 | /* Includes ------------------------------------------------------------------*/ 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | 61 | #define DEV_I2C Wire 62 | #define SerialPort Serial 63 | 64 | #ifndef LED_BUILTIN 65 | #define LED_BUILTIN 13 66 | #endif 67 | #define LedPin LED_BUILTIN 68 | 69 | // Components. 70 | VL53LX sensor_vl53lx_sat(&DEV_I2C, A1); 71 | 72 | 73 | /* Setup ---------------------------------------------------------------------*/ 74 | 75 | void setup() 76 | { 77 | // Led. 78 | pinMode(LedPin, OUTPUT); 79 | 80 | // Initialize serial for output. 81 | SerialPort.begin(115200); 82 | SerialPort.println("Starting..."); 83 | 84 | // Initialize I2C bus. 85 | DEV_I2C.begin(); 86 | 87 | // Configure VL53LX satellite component. 88 | sensor_vl53lx_sat.begin(); 89 | 90 | // Switch off VL53LX satellite component. 91 | sensor_vl53lx_sat.VL53LX_Off(); 92 | 93 | //Initialize VL53LX satellite component. 94 | sensor_vl53lx_sat.InitSensor(0x12); 95 | 96 | // Start Measurements 97 | sensor_vl53lx_sat.VL53LX_StartMeasurement(); 98 | } 99 | 100 | void loop() 101 | { 102 | VL53LX_MultiRangingData_t MultiRangingData; 103 | VL53LX_MultiRangingData_t *pMultiRangingData = &MultiRangingData; 104 | uint8_t NewDataReady = 0; 105 | int no_of_object_found = 0, j; 106 | char report[64]; 107 | int status; 108 | 109 | do 110 | { 111 | status = sensor_vl53lx_sat.VL53LX_GetMeasurementDataReady(&NewDataReady); 112 | } while (!NewDataReady); 113 | 114 | //Led on 115 | digitalWrite(LedPin, HIGH); 116 | 117 | if((!status)&&(NewDataReady!=0)) 118 | { 119 | status = sensor_vl53lx_sat.VL53LX_GetMultiRangingData(pMultiRangingData); 120 | no_of_object_found=pMultiRangingData->NumberOfObjectsFound; 121 | snprintf(report, sizeof(report), "VL53LX Satellite: Count=%d, #Objs=%1d ", pMultiRangingData->StreamCount, no_of_object_found); 122 | SerialPort.print(report); 123 | for(j=0;j
© COPYRIGHT(c) 2020 STMicroelectronics
15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************** 39 | */ 40 | 41 | 42 | //On some boards like the Arduino Uno the pin used by the sensor to raise interrupts (A2) 43 | //can't be mapped as an interrupt pin. For this this reason this sketch will not work 44 | //unless some additional cabling is done and the interrupt pin is changed. 45 | /* 46 | * To use this sketch you need to connect the VL53L3CX satellite sensor directly to the Nucleo board with wires in this way: 47 | * pin 1 (Interrupt) of the VL53L3CX satellite connected to pin A2 of the Nucleo board 48 | * pin 2 (SCL_I) of the VL53L3CX satellite connected to pin D15 (SCL) of the Nucleo board with a Pull-Up resistor of 4.7 KOhm 49 | * pin 3 (XSDN_I) of the VL53L3CX satellite connected to pin A1 of the Nucleo board 50 | * pin 4 (SDA_I) of the VL53L3CX satellite connected to pin D14 (SDA) of the Nucleo board with a Pull-Up resistor of 4.7 KOhm 51 | * pin 5 (VDD) of the VL53L3CX satellite connected to 3V3 pin of the Nucleo board 52 | * pin 6 (GND) of the VL53L3CX satellite connected to GND of the Nucleo board 53 | * pins 7, 8, 9 and 10 are not connected. 54 | */ 55 | /* Includes ------------------------------------------------------------------*/ 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | #define DEV_I2C Wire 67 | #define SerialPort Serial 68 | 69 | #ifndef LED_BUILTIN 70 | #define LED_BUILTIN 13 71 | #endif 72 | #define LedPin LED_BUILTIN 73 | 74 | #define interruptPin A2 75 | 76 | // Components. 77 | VL53LX sensor_vl53lx_sat(&DEV_I2C, A1); 78 | 79 | volatile int interruptCount=0; 80 | 81 | void measure() 82 | { 83 | interruptCount=1; 84 | } 85 | 86 | void setup() 87 | { 88 | VL53LX_Error status; 89 | // Led. 90 | pinMode(LedPin, OUTPUT); 91 | pinMode(interruptPin, INPUT_PULLUP); 92 | attachInterrupt(interruptPin, measure, FALLING); 93 | 94 | // Initialize serial for output. 95 | SerialPort.begin(115200); 96 | SerialPort.println("Starting..."); 97 | 98 | // Initialize I2C bus. 99 | DEV_I2C.begin(); 100 | 101 | // Configure VL53LX satellite component. 102 | sensor_vl53lx_sat.begin(); 103 | 104 | // Switch off VL53LX satellite component. 105 | sensor_vl53lx_sat.VL53LX_Off(); 106 | 107 | // Initialize VL53LX satellite component. 108 | status = sensor_vl53lx_sat.InitSensor(0x12); 109 | if(status) 110 | { 111 | SerialPort.println("Init sensor_vl53lx_sat failed..."); 112 | } 113 | 114 | sensor_vl53lx_sat.VL53LX_StartMeasurement(); 115 | } 116 | 117 | void loop() 118 | { 119 | VL53LX_MultiRangingData_t MultiRangingData; 120 | VL53LX_MultiRangingData_t *pMultiRangingData = &MultiRangingData; 121 | uint8_t NewDataReady = 0; 122 | int no_of_object_found = 0, j; 123 | char report[64]; 124 | if (interruptCount) 125 | { 126 | int status; 127 | 128 | interruptCount=0; 129 | // Led blinking. 130 | digitalWrite(LedPin, HIGH); 131 | 132 | status = sensor_vl53lx_sat.VL53LX_GetMeasurementDataReady(&NewDataReady); 133 | if((!status)&&(NewDataReady!=0)) 134 | { 135 | status = sensor_vl53lx_sat.VL53LX_GetMultiRangingData(pMultiRangingData); 136 | no_of_object_found=pMultiRangingData->NumberOfObjectsFound; 137 | snprintf(report, sizeof(report), "Count=%d, #Objs=%1d ", pMultiRangingData->StreamCount, no_of_object_found); 138 | SerialPort.print(report); 139 | for(j=0;j
© COPYRIGHT(c) 2015 STMicroelectronics
13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | 40 | /* Define to prevent recursive inclusion -------------------------------------*/ 41 | 42 | #ifndef __COMPONENT_OBJECT_CLASS_H 43 | #define __COMPONENT_OBJECT_CLASS_H 44 | 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | 48 | #include 49 | 50 | 51 | /* Classes ------------------------------------------------------------------*/ 52 | 53 | /** An abstract class for Generic components. 54 | */ 55 | class ComponentObject { 56 | public: 57 | /** 58 | * @brief Initializing the component. 59 | * @param[in] init pointer to device specific initialization structure. 60 | * @retval "0" in case of success, an error code otherwise. 61 | */ 62 | virtual int Init() = 0; 63 | 64 | /** 65 | * @brief Getting the ID of the component. 66 | * @param[out] id pointer to an allocated variable to store the ID into. 67 | * @retval "0" in case of success, an error code otherwise. 68 | */ 69 | virtual int ReadID() = 0; 70 | }; 71 | 72 | #endif /* __COMPONENT_OBJECT_CLASS_H */ 73 | 74 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 75 | -------------------------------------------------------------------------------- /src/RangeSensor.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file RangeSensor.h 4 | * @author AST / EST 5 | * @version V0.0.1 6 | * @date 13-April-2015 7 | * @brief This file contains the abstract class describing in general 8 | * the interfaces of a range sensor 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2015 STMicroelectronics

13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Define to prevent from recursive inclusion --------------------------------*/ 40 | #ifndef __RANGE_SENSOR_CLASS_H 41 | #define __RANGE_SENSOR_CLASS_H 42 | 43 | /* Includes ------------------------------------------------------------------*/ 44 | #include 45 | 46 | /* Classes ------------------------------------------------------------------*/ 47 | /** An abstract class for range sensors 48 | */ 49 | class RangeSensor : public ComponentObject { 50 | public: 51 | /** 52 | * @brief Get current range [mm] 53 | * @param[out] piData Pointer to where to store range to 54 | * @return 0 in case of success, an error code otherwise 55 | */ 56 | virtual int GetDistance(uint32_t *piData) = 0; 57 | }; 58 | 59 | #endif /* __RANGE_SENSOR_CLASS_H */ 60 | --------------------------------------------------------------------------------