From 4092d549d177e0f45b130bc2b86f869429224572 Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Thu, 30 Dec 2021 18:32:48 +0100 Subject: [PATCH 1/7] Add calibration project --- calibration/.vscode/c_cpp_properties.json | 235 ++++++++++++++++++ calibration/.vscode/extensions.json | 7 + calibration/.vscode/launch.json | 44 ++++ calibration/platformio.ini | 16 ++ calibration/src/OffsetAndXtalkCalibration.cpp | 65 +++++ 5 files changed, 367 insertions(+) create mode 100644 calibration/.vscode/c_cpp_properties.json create mode 100644 calibration/.vscode/extensions.json create mode 100644 calibration/.vscode/launch.json create mode 100644 calibration/platformio.ini create mode 100644 calibration/src/OffsetAndXtalkCalibration.cpp diff --git a/calibration/.vscode/c_cpp_properties.json b/calibration/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..f726f350 --- /dev/null +++ b/calibration/.vscode/c_cpp_properties.json @@ -0,0 +1,235 @@ +// +// !!! WARNING !!! AUTO-GENERATED FILE! +// PLEASE DO NOT MODIFY IT AND USE "platformio.ini": +// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags +// +{ + "configurations": [ + { + "name": "PlatformIO", + "includePath": [ + "/Users/kaibepperling/dev/Roode/calibration/include", + "/Users/kaibepperling/dev/Roode/calibration/src", + "/Users/kaibepperling/dev/Roode/calibration/.pio/libdeps/roode-calibration/VL53L1X_ULD/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_trace", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_update", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/asio", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bootloader_support", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bt", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/coap", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/console", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/driver", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/efuse", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-tls", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_adc_cal", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_event", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_client", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_server", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_https_ota", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_https_server", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_ringbuf", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_websocket_client", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/espcoredump", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ethernet", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/expat", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fatfs", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freemodbus", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freertos", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/heap", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/idf_test", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/jsmn", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/json", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/libsodium", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/log", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/lwip", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mbedtls", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mdns", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/micro-ecc", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mqtt", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nghttp", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nvs_flash", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/openssl", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protobuf-c", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protocomm", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/pthread", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/sdmmc", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/smartconfig_ack", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/soc", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spi_flash", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spiffs", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcp_transport", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcpip_adapter", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ulp", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/unity", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/vfs", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wear_levelling", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wifi_provisioning", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wpa_supplicant", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/xtensa-debug-module", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-face", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32-camera", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/cores/esp32", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/variants/d1_mini32", + "/Users/kaibepperling/.platformio/lib/VL53L1X", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/FS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdateServer/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SD/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Update/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src", + "/Users/kaibepperling/.platformio/packages/tool-unity", + "" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "/Users/kaibepperling/dev/Roode/calibration/include", + "/Users/kaibepperling/dev/Roode/calibration/src", + "/Users/kaibepperling/dev/Roode/calibration/.pio/libdeps/roode-calibration/VL53L1X_ULD/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_trace", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_update", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/asio", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bootloader_support", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bt", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/coap", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/console", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/driver", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/efuse", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-tls", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_adc_cal", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_event", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_client", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_server", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_https_ota", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_https_server", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_ringbuf", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_websocket_client", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/espcoredump", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ethernet", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/expat", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fatfs", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freemodbus", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freertos", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/heap", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/idf_test", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/jsmn", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/json", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/libsodium", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/log", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/lwip", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mbedtls", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mdns", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/micro-ecc", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mqtt", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nghttp", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nvs_flash", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/openssl", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protobuf-c", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protocomm", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/pthread", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/sdmmc", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/smartconfig_ack", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/soc", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spi_flash", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spiffs", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcp_transport", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcpip_adapter", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ulp", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/unity", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/vfs", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wear_levelling", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wifi_provisioning", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wpa_supplicant", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/xtensa-debug-module", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-face", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32-camera", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/cores/esp32", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/variants/d1_mini32", + "/Users/kaibepperling/.platformio/lib/VL53L1X", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/FS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdateServer/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SD/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/Update/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src", + "/Users/kaibepperling/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src", + "/Users/kaibepperling/.platformio/packages/tool-unity", + "" + ] + }, + "defines": [ + "PLATFORMIO=50204", + "ARDUINO_D1_MINI32", + "ESP32", + "ESP_PLATFORM", + "F_CPU=240000000L", + "HAVE_CONFIG_H", + "MBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"", + "ARDUINO=10805", + "ARDUINO_ARCH_ESP32", + "ARDUINO_VARIANT=\"d1_mini32\"", + "ARDUINO_BOARD=\"WeMos D1 MINI ESP32\"", + "" + ], + "cStandard": "c99", + "cppStandard": "c++11", + "compilerPath": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin/xtensa-esp32-elf-gcc", + "compilerArgs": [ + "-mlongcalls", + "" + ] + } + ], + "version": 4 +} diff --git a/calibration/.vscode/extensions.json b/calibration/.vscode/extensions.json new file mode 100644 index 00000000..0f0d7401 --- /dev/null +++ b/calibration/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/calibration/.vscode/launch.json b/calibration/.vscode/launch.json new file mode 100644 index 00000000..2045afb8 --- /dev/null +++ b/calibration/.vscode/launch.json @@ -0,0 +1,44 @@ +// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY +// +// PIO Unified Debugger +// +// Documentation: https://docs.platformio.org/page/plus/debugging.html +// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html + +{ + "version": "0.2.0", + "configurations": [ + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug", + "executable": "/Users/kaibepperling/dev/Roode/calibration/.pio/build/roode-calibration/firmware.elf", + "projectEnvName": "roode-calibration", + "toolchainBinDir": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin", + "internalConsoleOptions": "openOnSessionStart", + "preLaunchTask": { + "type": "PlatformIO", + "task": "Pre-Debug" + } + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (skip Pre-Debug)", + "executable": "/Users/kaibepperling/dev/Roode/calibration/.pio/build/roode-calibration/firmware.elf", + "projectEnvName": "roode-calibration", + "toolchainBinDir": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin", + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (without uploading)", + "executable": "/Users/kaibepperling/dev/Roode/calibration/.pio/build/roode-calibration/firmware.elf", + "projectEnvName": "roode-calibration", + "toolchainBinDir": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin", + "internalConsoleOptions": "openOnSessionStart", + "loadMode": "manual" + } + ] +} diff --git a/calibration/platformio.ini b/calibration/platformio.ini new file mode 100644 index 00000000..834e3582 --- /dev/null +++ b/calibration/platformio.ini @@ -0,0 +1,16 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:roode-calibration] +platform = espressif32 +board = wemos_d1_mini32 +framework = arduino +lib_deps = rneurink/VL53L1X_ULD@^1.2.3 +monitor_speed = 115200 diff --git a/calibration/src/OffsetAndXtalkCalibration.cpp b/calibration/src/OffsetAndXtalkCalibration.cpp new file mode 100644 index 00000000..8c8a0474 --- /dev/null +++ b/calibration/src/OffsetAndXtalkCalibration.cpp @@ -0,0 +1,65 @@ +#include "VL53L1X_ULD.h" + +VL53L1X_ULD sensor; +bool dataReady; + +void setup() +{ + Serial.begin(115200); + Wire.begin(); + + VL53L1_Error sensor_status = sensor.Begin(); + if (sensor_status != VL53L1_ERROR_NONE) + { + Serial.println("Could not initialize the sensor, error code: " + String(sensor_status)); + while (1) + { + } + } + Serial.println("Sensor initialized"); + + // Start the offset calibration + Serial.println("Place a target, 17 % grey, at 140 mm from the sensor a"); + Serial.println("The calibration may take a few seconds. The offset correction is applied to the sensor at the end of calibration."); + Serial.readString(); + int16_t foundOffset; + sensor_status = sensor.CalibrateOffset(140, &foundOffset); + + sensor.SetOffsetInMm(foundOffset); + + Serial.println("Calibrated offset: " + String(foundOffset)); + Serial.printf("Set this offset in the sensor configuration under offset: %d\n", foundOffset); + + /* The target distance : the distance where the sensor start to "under range" + Crosstalk calibration should be conducted in a dark environment, with no IR contribution. + The crosstalk calibration distance needs to be characterized as it depends on the system environment which + mainly includes: + • The cover glass material and optical properties + • The air gap value i.e. the distance between the sensor and the cover glass + Do a full sweep with the target from near to far, noting the resulting measurement. + At some point, the actual value and the measured value start to diverge. This is the crosstalk calibration + distance. + */ + uint16_t CalibrationDistance = 140; // crosstalk calibration distance + uint16_t foundXTalk; + sensor_status = sensor.CalibrateXTalk(CalibrationDistance, &foundXTalk); + Serial.println("Calibrated offset: " + String(foundXTalk)); + Serial.printf("Set this offset in the sensor configuration under crosstalk: %d\n", foundXTalk); + sensor.SetXTalk(foundXTalk); + sensor.StartRanging(); +} +void loop() +{ + if (dataReady) + { + // Get the results + uint16_t distance; + sensor.GetDistanceInMm(&distance); + + // After reading the results reset the interrupt to be able to take another measurement + sensor.ClearInterrupt(); + dataReady = false; + + Serial.println("Distance in mm: " + String(distance)); + } +} \ No newline at end of file From c0dae51c22c26008042dfefe213f618a7298c6f3 Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Thu, 30 Dec 2021 20:21:59 +0100 Subject: [PATCH 2/7] Add cover glass calibration --- components/roode/__init__.py | 6 +++++- components/roode/roode.cpp | 32 ++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/components/roode/__init__.py b/components/roode/__init__.py index 36c6a913..faafc9f0 100644 --- a/components/roode/__init__.py +++ b/components/roode/__init__.py @@ -40,6 +40,8 @@ CONF_USE_SAMPLING = "use_sampling" CONF_ROI = "roi" CONF_ROI_ACTIVE = "roi_active" +CONF_SENSOR_OFFSET_CALIBRATION = "sensor_offset_calibration" +CONF_SENSOR_XTALK_CALIBRATION = "sensor_xtalk_calibration" TYPES = [ CONF_RESTORE_VALUES, CONF_INVERT_DIRECTION, @@ -69,6 +71,8 @@ min=0, max=100 ), cv.Optional(CONF_ROI_CALIBRATION, default="false"): cv.boolean, + cv.Optional(CONF_SENSOR_OFFSET_CALIBRATION, default=-1): cv.int_, + cv.Optional(CONF_SENSOR_XTALK_CALIBRATION, default=-1): cv.int_, } ), cv.Exclusive( @@ -148,7 +152,7 @@ async def to_code(config): cg.add_library("EEPROM", None) cg.add_library("Wire", None) cg.add_library("rneurink", "1.2.3", "VL53L1X_ULD") - + validate_roi_settings(config) for key in TYPES: diff --git a/components/roode/roode.cpp b/components/roode/roode.cpp index f969bb92..5d15e10a 100644 --- a/components/roode/roode.cpp +++ b/components/roode/roode.cpp @@ -26,6 +26,10 @@ namespace esphome Wire.setClock(400000); // Initialize the sensor, give the special I2C_address to the Begin function + // Set a different I2C address + // This address is stored as long as the sensor is powered. To revert this change you can unplug and replug the power to the sensor + distanceSensor.SetI2CAddress(VL53L1X_ULD_I2C_ADDRESS); + sensor_status = distanceSensor.Begin(VL53L1X_ULD_I2C_ADDRESS); if (sensor_status != VL53L1_ERROR_NONE) { @@ -35,10 +39,30 @@ namespace esphome { } } - - // Set a different I2C address - // This address is stored as long as the sensor is powered. To revert this change you can unplug and replug the power to the sensor - distanceSensor.SetI2CAddress(VL53L1X_ULD_I2C_ADDRESS); + if (sensor_offset_calibration_ != -1) + { + ESP_LOGI(CALIBRATION, "Setting sensor offset calibration to %d", sensor_offset_calibration_); + sensor_status = distanceSensor.SetOffsetInMm(sensor_offset_calibration_); + if (sensor_status != VL53L1_ERROR_NONE) + { + ESP_LOGE(SETUP, "Could not set sensor offset calibration, error code: %d", sensor_status); + while (1) + { + } + } + } + if (sensor_xtalk_calibration_ != -1) + { + ESP_LOGI(CALIBRATION, "Setting sensor xtalk calibration to %d", sensor_xtalk_calibration_); + sensor_status = distanceSensor.SetXTalk(sensor_xtalk_calibration_); + if (sensor_status != VL53L1_ERROR_NONE) + { + ESP_LOGE(SETUP, "Could not set sensor offset calibration, error code: %d", sensor_status); + while (1) + { + } + } + } if (invert_direction_) { From b759e94c79a4add395fb7584b2b7f815df807bda Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Thu, 30 Dec 2021 20:22:28 +0100 Subject: [PATCH 3/7] Add cover glass calibration function --- .../OffsetAndXtalkCalibration.ino | 62 ++++++++++++++++++ calibration/middlegray.png | Bin 0 -> 51227 bytes components/roode/roode.h | 4 ++ 3 files changed, 66 insertions(+) create mode 100644 calibration/OffsetAndXtalkCalibration/OffsetAndXtalkCalibration.ino create mode 100644 calibration/middlegray.png diff --git a/calibration/OffsetAndXtalkCalibration/OffsetAndXtalkCalibration.ino b/calibration/OffsetAndXtalkCalibration/OffsetAndXtalkCalibration.ino new file mode 100644 index 00000000..7f90c4ab --- /dev/null +++ b/calibration/OffsetAndXtalkCalibration/OffsetAndXtalkCalibration.ino @@ -0,0 +1,62 @@ +#include "VL53L1X_ULD.h" + +VL53L1X_ULD sensor; +bool dataReady; + +void setup() +{ + Serial.begin(115200); + Wire.begin(); + + VL53L1_Error sensor_status = sensor.Begin(); + if (sensor_status != VL53L1_ERROR_NONE) + { + Serial.println("Could not initialize the sensor, error code: " + String(sensor_status)); + while (1) + { + } + } + Serial.println("Sensor initialized"); + + // Start the offset calibration + Serial.println("Place a target, 17 % grey, at 140 mm from the sensor a"); + Serial.println("The calibration may take a few seconds. The offset correction is applied to the sensor at the end of calibration."); + Serial.readString(); + int16_t foundOffset; + sensor_status = sensor.CalibrateOffset(140, &foundOffset); + + + Serial.println("Calibrated offset: " + String(foundOffset)); + Serial.println("Set this offset in the sensor configuration under offset: "); + + /* The target distance : the distance where the sensor start to "under range" + Crosstalk calibration should be conducted in a dark environment, with no IR contribution. + The crosstalk calibration distance needs to be characterized as it depends on the system environment which + mainly includes: + • The cover glass material and optical properties + • The air gap value i.e. the distance between the sensor and the cover glass + Do a full sweep with the target from near to far, noting the resulting measurement. + At some point, the actual value and the measured value start to diverge. This is the crosstalk calibration + distance. + */ + uint16_t CalibrationDistance = 140; // crosstalk calibration distance + uint16_t foundXTalk; + sensor_status = sensor.CalibrateXTalk(CalibrationDistance, &foundXTalk); + Serial.println("Calibrated offset: " + String(foundXTalk)); + Serial.println("Set this offset in the sensor configuration under crosstalk: "); +} +void loop() +{ + if (dataReady) + { + // Get the results + uint16_t distance; + sensor.GetDistanceInMm(&distance); + + // After reading the results reset the interrupt to be able to take another measurement + sensor.ClearInterrupt(); + dataReady = false; + + Serial.println("Distance in mm: " + String(distance)); + } +} diff --git a/calibration/middlegray.png b/calibration/middlegray.png new file mode 100644 index 0000000000000000000000000000000000000000..3d240f4eeff28c67e53d2407e8963ecb27858417 GIT binary patch literal 51227 zcmeI5O-NKx6vxj?Q}bJc5V2{5+P7#CnB~(c$3+^}rk$>=Kr~zwmiQPYbJMtJQ$*#e zoqdS8C}ax3owy5=D5`~lfsnYVpmTIa-Yh~}XpixCVdlL%%)oH(IluG2=brc8@VVy3 zqWsEy5h-elMq2eyY_Gf={bZuRIiQDq-O-CZA_e>H<;eX975bsm)7n@sW3yG?w3FT8 zo^?f@#|wV7?-iMO))a9sTz8fhoH7X)%IM`EN8W|{=LW`Kb?LV^ns>Km<6KYb?i|nd z_ubE>{%-bggTGsPxY+Ua>qhu7111=W;1~i7M1TP>5MZFP0%ZUURHGsvGeQ|0m6h8p z1X%olbu^x?|G_#M4~=JuFcy5kfCZmA0?HuZFj$_S%&OFh8gy4%I^!k1Mz8h8)CGL% zQWJ%j*+>v_3Auz^bp*H#4Acx*jI$UA1}Fm?0bqbKP%A(gpbUV4@h~HHU-4(1$?aYC zzcFJ;wchFK)Ttfw%7^^jaI|WVukVGg=J~o3XSQOpn#6L0w{= zY6hrFVihn@M<7-K1GNH#E6M;E7!Oefy9Ndco9|@vLewWy$VTl7g=`80YO<+nRWqQF zEi($)cG90`rw-1k>4Xbk^k2Dgb1n-T!iESaCbChN1eE`%E(|d8CXcze3_82uO-{#MsB{$ z4W}u&p@vg|z-@|mvH+CPX0+AmsCJ~<5%j7fa4pSWVen~b!70)qdK>=v?o>HGoZqbN+DpNjzEPSFi6-<%#Vcu6O2S~4Do;gFwnRX)QB-Ev1?Ti??paLS#WDQ-5eRKZ;Sl_;!2R^ literal 0 HcmV?d00001 diff --git a/components/roode/roode.h b/components/roode/roode.h index b51fa447..7a579a94 100644 --- a/components/roode/roode.h +++ b/components/roode/roode.h @@ -63,6 +63,8 @@ namespace esphome void set_manual_active(bool val) { manual_active_ = val; } void set_roi_active(bool val) { roi_active_ = val; } void set_roi_calibration(bool val) { roi_calibration_ = val; } + void set_sensor_offset_calibration(int val) { sensor_offset_calibration_ = val; } + void set_sensor_xtalk_calibration(int val) { sensor_xtalk_calibration_ = val; } void set_timing_budget(int timing_budget) { timing_budget_ = timing_budget; } void set_manual_threshold(int val) { manual_threshold_ = val; } void set_max_threshold_percentage(int val) { max_threshold_percentage_ = val; } @@ -128,6 +130,8 @@ namespace esphome bool manual_active_{false}; bool roi_active_{false}; bool roi_calibration_{false}; + int sensor_offset_calibration_{-1}; + int sensor_xtalk_calibration_{-1}; int sensor_mode{-1}; bool advised_sensor_orientation_{true}; bool use_sampling_{true}; From bd15e3e0172e483d036d5c367ef53089934e21ea Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Thu, 30 Dec 2021 20:22:49 +0100 Subject: [PATCH 4/7] Add long and max range budgets --- components/roode/roode.cpp | 29 +++++++++++++++++++++++------ components/roode/roode.h | 7 +++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/components/roode/roode.cpp b/components/roode/roode.cpp index 5d15e10a..047e045e 100644 --- a/components/roode/roode.cpp +++ b/components/roode/roode.cpp @@ -148,13 +148,14 @@ namespace esphome uint8_t dataReady = false; while (!dataReady) { - status += distanceSensor.CheckForDataReady(&dataReady); + sensor_status += distanceSensor.CheckForDataReady(&dataReady); delay(1); } // Get the results uint16_t distance; sensor_status += distanceSensor.GetDistanceInMm(&distance); + if (sensor_status != VL53L1_ERROR_NONE) { ESP_LOGE(TAG, "Could not get distance, error code: %d", sensor_status); @@ -162,6 +163,7 @@ namespace esphome } // After reading the results reset the interrupt to be able to take another measurement distanceSensor.ClearInterrupt(); + return distance; } @@ -501,7 +503,17 @@ namespace esphome } ESP_LOGI(SETUP, "Set long range mode. timing_budget: %d", time_budget_in_ms); break; - case 3: // custom mode + case 3: // max mode + time_budget_in_ms = time_budget_in_ms_max; + delay_between_measurements = time_budget_in_ms + 5; + sensor_status = distanceSensor.SetDistanceMode(Long); + if (sensor_status != VL53L1_ERROR_NONE) + { + ESP_LOGE(SETUP, "Could not set distance mode. mode: %d", Long); + } + ESP_LOGI(SETUP, "Set max range mode. timing_budget: %d", time_budget_in_ms); + break; + case 4: // custom mode time_budget_in_ms = new_timing_budget; delay_between_measurements = new_timing_budget + 5; sensor_status = distanceSensor.SetDistanceMode(Long); @@ -525,18 +537,23 @@ namespace esphome { if (average_zone_0 <= short_distance_threshold || average_zone_1 <= short_distance_threshold) { - setSensorMode(0, time_budget_in_ms_short); + setSensorMode(0); } if ((average_zone_0 > short_distance_threshold && average_zone_0 <= medium_distance_threshold) || (average_zone_1 > short_distance_threshold && average_zone_1 <= medium_distance_threshold)) { - setSensorMode(1, time_budget_in_ms_medium); + setSensorMode(1); } - if (average_zone_0 > medium_distance_threshold || average_zone_1 > medium_distance_threshold) + if ((average_zone_0 > medium_distance_threshold && average_zone_0 <= long_distance_threshold) || (average_zone_1 > medium_distance_threshold && average_zone_1 <= long_distance_threshold)) { - setSensorMode(2, time_budget_in_ms_long); + setSensorMode(2); } + if (average_zone_0 > long_distance_threshold || average_zone_1 > long_distance_threshold) + { + setSensorMode(3); + } + sensor_status = distanceSensor.SetTimingBudgetInMs(time_budget_in_ms); if (sensor_status != VL53L1_ERROR_NONE) { diff --git a/components/roode/roode.h b/components/roode/roode.h index 7a579a94..6c13b2f8 100644 --- a/components/roode/roode.h +++ b/components/roode/roode.h @@ -49,7 +49,8 @@ namespace esphome */ static int time_budget_in_ms_short = 15; // Lowest possible is 15ms with the ULD API (https://www.st.com/resource/en/user_manual/um2510-a-guide-to-using-the-vl53l1x-ultra-lite-driver-stmicroelectronics.pdf) static int time_budget_in_ms_medium = 33; // Works up to 3.1m - static int time_budget_in_ms_long = 100; // Works up to 4m in the dark on a white chart + static int time_budget_in_ms_long = 100; // Works up to 2300m + static int time_budget_in_ms_max = 200; // Works up to 3000m class Roode : public PollingComponent { @@ -98,6 +99,7 @@ namespace esphome uint16_t distance = 0; VL53L1_Error last_sensor_status = VL53L1_ERROR_NONE; VL53L1_Error sensor_status = VL53L1_ERROR_NONE; + ERangeStatus rangeStatus; int DIST_THRESHOLD_MAX[2] = {0, 0}; // max treshold of the two zones int DIST_THRESHOLD_MIN[2] = {0, 0}; // min treshold of the two zones int roi_width_{6}; // width of the ROI @@ -144,7 +146,8 @@ namespace esphome int number_attempts = 20; int timing_budget_{-1}; int short_distance_threshold = 1300; - int medium_distance_threshold = 3100; + int medium_distance_threshold = 2300; + int long_distance_threshold = 3000; bool status = false; int optimized_zone_0; int optimized_zone_1; From 83ef7d26a1cf819c2f11632950735126981e2142 Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Fri, 31 Dec 2021 11:22:29 +0100 Subject: [PATCH 5/7] Add medium_long mode --- components/roode/roode.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/roode/roode.h b/components/roode/roode.h index 6c13b2f8..d96110cb 100644 --- a/components/roode/roode.h +++ b/components/roode/roode.h @@ -47,10 +47,11 @@ namespace esphome The minimum inter-measurement period must be longer than the timing budget + 4 ms. Valid values: [15,20,33,50,100,200,500] */ - static int time_budget_in_ms_short = 15; // Lowest possible is 15ms with the ULD API (https://www.st.com/resource/en/user_manual/um2510-a-guide-to-using-the-vl53l1x-ultra-lite-driver-stmicroelectronics.pdf) - static int time_budget_in_ms_medium = 33; // Works up to 3.1m - static int time_budget_in_ms_long = 100; // Works up to 2300m - static int time_budget_in_ms_max = 200; // Works up to 3000m + static int time_budget_in_ms_short = 15; // Lowest possible is 15ms with the ULD API (https://www.st.com/resource/en/user_manual/um2510-a-guide-to-using-the-vl53l1x-ultra-lite-driver-stmicroelectronics.pdf) + static int time_budget_in_ms_medium = 33; + static int time_budget_in_ms_medium_long = 50; + static int time_budget_in_ms_long = 100; + static int time_budget_in_ms_max = 200; class Roode : public PollingComponent { @@ -147,7 +148,8 @@ namespace esphome int timing_budget_{-1}; int short_distance_threshold = 1300; int medium_distance_threshold = 2300; - int long_distance_threshold = 3000; + int medium_long_distance_threshold = 3000; + int long_distance_threshold = 4000; bool status = false; int optimized_zone_0; int optimized_zone_1; From 8068185dd7b3ce7afbaefaa0381da917bc218a35 Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Fri, 31 Dec 2021 11:42:10 +0100 Subject: [PATCH 6/7] Add correct medium_ling mode --- components/roode/roode.cpp | 27 ++++++++++++++++++--------- components/roode/roode.h | 11 ++++++----- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/components/roode/roode.cpp b/components/roode/roode.cpp index 047e045e..c227f9bb 100644 --- a/components/roode/roode.cpp +++ b/components/roode/roode.cpp @@ -493,7 +493,17 @@ namespace esphome } ESP_LOGI(SETUP, "Set medium mode. timing_budget: %d", time_budget_in_ms); break; - case 2: // long mode + case 2: // medium_long mode + time_budget_in_ms = time_budget_in_ms_medium_long; + delay_between_measurements = time_budget_in_ms + 5; + sensor_status = distanceSensor.SetDistanceMode(Long); + if (sensor_status != VL53L1_ERROR_NONE) + { + ESP_LOGE(SETUP, "Could not set distance mode. mode: %d", Long); + } + ESP_LOGI(SETUP, "Set medium long range mode. timing_budget: %d", time_budget_in_ms); + break; + case 3: // long mode time_budget_in_ms = time_budget_in_ms_long; delay_between_measurements = time_budget_in_ms + 5; sensor_status = distanceSensor.SetDistanceMode(Long); @@ -503,7 +513,7 @@ namespace esphome } ESP_LOGI(SETUP, "Set long range mode. timing_budget: %d", time_budget_in_ms); break; - case 3: // max mode + case 4: // max mode time_budget_in_ms = time_budget_in_ms_max; delay_between_measurements = time_budget_in_ms + 5; sensor_status = distanceSensor.SetDistanceMode(Long); @@ -513,7 +523,7 @@ namespace esphome } ESP_LOGI(SETUP, "Set max range mode. timing_budget: %d", time_budget_in_ms); break; - case 4: // custom mode + case 5: // custom mode time_budget_in_ms = new_timing_budget; delay_between_measurements = new_timing_budget + 5; sensor_status = distanceSensor.SetDistanceMode(Long); @@ -545,21 +555,20 @@ namespace esphome setSensorMode(1); } - if ((average_zone_0 > medium_distance_threshold && average_zone_0 <= long_distance_threshold) || (average_zone_1 > medium_distance_threshold && average_zone_1 <= long_distance_threshold)) + if ((average_zone_0 > medium_distance_threshold && average_zone_0 <= medium_long_distance_threshold) || (average_zone_1 > medium_distance_threshold && average_zone_1 <= medium_long_distance_threshold)) { setSensorMode(2); } - if (average_zone_0 > long_distance_threshold || average_zone_1 > long_distance_threshold) + if ((average_zone_0 > medium_long_distance_threshold && average_zone_0 <= long_distance_threshold) || (average_zone_1 > medium_long_distance_threshold && average_zone_1 <= long_distance_threshold)) { setSensorMode(3); } - - sensor_status = distanceSensor.SetTimingBudgetInMs(time_budget_in_ms); - if (sensor_status != VL53L1_ERROR_NONE) + if (average_zone_0 > long_distance_threshold || average_zone_1 > long_distance_threshold) { - ESP_LOGE(CALIBRATION, "Could not set timing budget. timing_budget: %d ms, status: %d", time_budget_in_ms, sensor_status); + setSensorMode(4); } } + int Roode::getSum(int *array, int size) { int sum = 0; diff --git a/components/roode/roode.h b/components/roode/roode.h index d96110cb..f909dceb 100644 --- a/components/roode/roode.h +++ b/components/roode/roode.h @@ -45,13 +45,14 @@ namespace esphome The timing budget and inter-measurement period should not be called when the sensor is ranging. The user has to stop the ranging, change these parameters, and restart ranging The minimum inter-measurement period must be longer than the timing budget + 4 ms. + // Lowest possible is 15ms with the ULD API (https://www.st.com/resource/en/user_manual/um2510-a-guide-to-using-the-vl53l1x-ultra-lite-driver-stmicroelectronics.pdf) Valid values: [15,20,33,50,100,200,500] */ - static int time_budget_in_ms_short = 15; // Lowest possible is 15ms with the ULD API (https://www.st.com/resource/en/user_manual/um2510-a-guide-to-using-the-vl53l1x-ultra-lite-driver-stmicroelectronics.pdf) + static int time_budget_in_ms_short = 15; // max range: 1.3m static int time_budget_in_ms_medium = 33; static int time_budget_in_ms_medium_long = 50; static int time_budget_in_ms_long = 100; - static int time_budget_in_ms_max = 200; + static int time_budget_in_ms_max = 200; // max range: 4m class Roode : public PollingComponent { @@ -147,9 +148,9 @@ namespace esphome int number_attempts = 20; int timing_budget_{-1}; int short_distance_threshold = 1300; - int medium_distance_threshold = 2300; - int medium_long_distance_threshold = 3000; - int long_distance_threshold = 4000; + int medium_distance_threshold = 2000; + int medium_long_distance_threshold = 2700; + int long_distance_threshold = 3400; bool status = false; int optimized_zone_0; int optimized_zone_1; From e6eb6df67d62a394d7e3362b531c1c2d80740807 Mon Sep 17 00:00:00 2001 From: Kai Bepperling Date: Fri, 31 Dec 2021 11:48:38 +0100 Subject: [PATCH 7/7] Push exit event even if counter is 0 --- components/roode/roode.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/roode/roode.cpp b/components/roode/roode.cpp index c227f9bb..9f7d36f7 100644 --- a/components/roode/roode.cpp +++ b/components/roode/roode.cpp @@ -301,14 +301,14 @@ namespace esphome { peopleCounter--; sendCounter(peopleCounter); - ESP_LOGD("Roode pathTracking", "Exit detected."); - if (entry_exit_event_sensor != nullptr) - { - entry_exit_event_sensor->publish_state("Exit"); - } DistancesTableSize[0] = 0; DistancesTableSize[1] = 0; } + ESP_LOGD("Roode pathTracking", "Exit detected."); + if (entry_exit_event_sensor != nullptr) + { + entry_exit_event_sensor->publish_state("Exit"); + } } else if ((PathTrack[1] == 2) && (PathTrack[2] == 3) && (PathTrack[3] == 1)) {