From 22c12c807597bb435bfb9bd81dda15ed9edac0a1 Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Mon, 13 Dec 2021 14:45:38 +0100 Subject: [PATCH] Updated Adafruit_VL53L0X. --- .github/workflows/pull-request.yml | 2 +- .../Libraries/.patches/Adafruit_VL53L0X.patch | 111 +++--------------- Sming/Libraries/Adafruit_VL53L0X | 2 +- samples/Distance_Vl53l0x/app/application.cpp | 2 +- 4 files changed, 22 insertions(+), 95 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2ad9711321..2ab7d91ddf 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -25,4 +25,4 @@ jobs: skip: "" # Use resource script entry ignore_words_file: "Tools/spelling/ignore.txt" check_filenames: true -# only_warn: 1 + only_warn: 1 diff --git a/Sming/Libraries/.patches/Adafruit_VL53L0X.patch b/Sming/Libraries/.patches/Adafruit_VL53L0X.patch index 81d5a6cd62..fcb74eaf6d 100644 --- a/Sming/Libraries/.patches/Adafruit_VL53L0X.patch +++ b/Sming/Libraries/.patches/Adafruit_VL53L0X.patch @@ -1,100 +1,27 @@ +diff --git a/README.md b/README.md +index c7c7435..f5cc654 100644 +--- a/README.md ++++ b/README.md +@@ -1,4 +1,6 @@ +-# Adafruit VL53L0X Library [![Build Status](https://github.com/adafruit/Adafruit_VL53L0X/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_VL53L0X/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_VL53L0X/html/index.html) ++# Adafruit VL53L0X Library ++ ++[![Build Status](https://travis-ci.com/adafruit/Adafruit_VL53L0X.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit_VL53L0X) + + + diff --git a/src/Adafruit_VL53L0X.cpp b/src/Adafruit_VL53L0X.cpp -index 5a1e650..6699d6e 100644 +index 00d0af2..8fd9bd2 100644 --- a/src/Adafruit_VL53L0X.cpp +++ b/src/Adafruit_VL53L0X.cpp -@@ -35,8 +35,8 @@ - #define VERSION_REQUIRED_MINOR 0 ///< Required sensor minor version - #define VERSION_REQUIRED_BUILD 1 ///< Required sensor build +@@ -36,8 +36,8 @@ + #define VERSION_REQUIRED_MINOR 0 ///< Required sensor minor version + #define VERSION_REQUIRED_BUILD 1 ///< Required sensor build --#define STR_HELPER( x ) #x ///< a string helper --#define STR( x ) STR_HELPER(x) ///< string helper wrapper +-#define STR_HELPER(x) #x ///< a string helper +-#define STR(x) STR_HELPER(x) ///< string helper wrapper +//#define STR_HELPER( x ) #x ///< a string helper +//#define STR( x ) STR_HELPER(x) ///< string helper wrapper /**************************************************************************/ - /*! -@@ -162,8 +162,33 @@ boolean Adafruit_VL53L0X::begin(uint8_t i2c_addr, boolean debug, TwoWire *i2c) { - Status = VL53L0X_SetLimitCheckEnable( pMyDevice, VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD, 1 ); - } - -- if( Status == VL53L0X_ERROR_NONE ) { -- Status = VL53L0X_SetLimitCheckValue( pMyDevice, VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD, (FixPoint1616_t)( 1.5 * 0.023 * 65536 ) ); -+ if(!longRange) { // 30mm to 1.2 meter -+ if( Status == VL53L0X_ERROR_NONE ) { -+ Status = VL53L0X_SetLimitCheckValue( pMyDevice, VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD, (FixPoint1616_t)( 1.5 * 0.023 * 65536 ) ); -+ } -+ } -+ else { // can detect as far as 1.5 to 2 meters on a nice white reflective surface -+ // @credits: https://github.com/satoshinm/Adafruit_VL53L0X/commit/72c71bd44091f95ef1211f9ff3928e675dda1348 -+ // Long range mode - based on https://github.com/johnbryanmoore/VL53L0X_rasp_python/blob/master/python_lib/vl53l0x_python.c#L292 -+ if (Status == VL53L0X_ERROR_NONE) { -+ Status = VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, (FixPoint1616_t)(0.1*65536)); -+ } -+ -+ if (Status == VL53L0X_ERROR_NONE) { -+ Status = VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, (FixPoint1616_t)(60*65536)); -+ } -+ -+ if (Status == VL53L0X_ERROR_NONE) { -+ Status = VL53L0X_SetMeasurementTimingBudgetMicroSeconds(pMyDevice, 33000); -+ } -+ -+ if (Status == VL53L0X_ERROR_NONE) { -+ Status = VL53L0X_SetVcselPulsePeriod(pMyDevice, VL53L0X_VCSEL_PERIOD_PRE_RANGE, 18); -+ } -+ -+ if (Status == VL53L0X_ERROR_NONE) { -+ Status = VL53L0X_SetVcselPulsePeriod(pMyDevice, VL53L0X_VCSEL_PERIOD_FINAL_RANGE, 14); -+ } - } - - if( Status == VL53L0X_ERROR_NONE ) { -@@ -268,3 +293,8 @@ void Adafruit_VL53L0X::printRangeStatus( VL53L0X_RangingMeasurementData_t* pRang - Serial.println( buf ); - - } -+ -+void Adafruit_VL53L0X::setLongRangeMode(bool flag) -+{ -+ longRange = flag; -+} -diff --git a/src/Adafruit_VL53L0X.h b/src/Adafruit_VL53L0X.h -index 6f06604..47841c7 100644 ---- a/src/Adafruit_VL53L0X.h -+++ b/src/Adafruit_VL53L0X.h -@@ -38,6 +38,7 @@ - class Adafruit_VL53L0X - { - public: -+ void setLongRangeMode(bool flag); - boolean begin(uint8_t i2c_addr = VL53L0X_I2C_ADDR, boolean debug = false, TwoWire *i2c = &Wire); - boolean setAddress(uint8_t newAddr); - -@@ -65,6 +66,7 @@ class Adafruit_VL53L0X - VL53L0X_Version_t Version; - VL53L0X_Version_t *pVersion = &Version; - VL53L0X_DeviceInfo_t DeviceInfo; -+ bool longRange = false; - }; - - #endif -diff --git a/src/vl53l0x_platform_log.h b/src/vl53l0x_platform_log.h -index 26387d0..d203b3c 100644 ---- a/src/vl53l0x_platform_log.h -+++ b/src/vl53l0x_platform_log.h -@@ -88,13 +88,13 @@ void trace_print_module_function(uint32_t module, uint32_t level, uint32_t funct - #define LOG_GET_TIME() (int)clock() - - #define _LOG_FUNCTION_START(module, fmt, ... ) \ -- trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); -+ trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld %s " fmt "\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); - - #define _LOG_FUNCTION_END(module, status, ... )\ - trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__) - - #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... )\ -- trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status,##__VA_ARGS__) -+ trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld %s %d " fmt "\n", LOG_GET_TIME(), __FUNCTION__, (int)status,##__VA_ARGS__) - - // __func__ is gcc only - //#define VL53L0X_ErrLog( fmt, ...) fprintf(stderr, "VL53L0X_ErrLog %s" fmt "\n", __func__, ##__VA_ARGS__) + /*! diff --git a/Sming/Libraries/Adafruit_VL53L0X b/Sming/Libraries/Adafruit_VL53L0X index cc4ca55e93..701b26431c 160000 --- a/Sming/Libraries/Adafruit_VL53L0X +++ b/Sming/Libraries/Adafruit_VL53L0X @@ -1 +1 @@ -Subproject commit cc4ca55e938891a2903a9fedd5e10c811da20579 +Subproject commit 701b26431ca7aac1cd3239ad3e86bd3d320e87c3 diff --git a/samples/Distance_Vl53l0x/app/application.cpp b/samples/Distance_Vl53l0x/app/application.cpp index a90a3af516..8035a9abd7 100644 --- a/samples/Distance_Vl53l0x/app/application.cpp +++ b/samples/Distance_Vl53l0x/app/application.cpp @@ -40,7 +40,7 @@ void init() // Create components. Wire.begin(SDA, SCL); - lox.setLongRangeMode(true); + lox.configSensor(Adafruit_VL53L0X::VL53L0X_SENSE_LONG_RANGE); if(!lox.begin()) { Serial.println(F("Failed to boot VL53L0X"));