From 494af2b0671f59e182e6b224ca283131e6117e46 Mon Sep 17 00:00:00 2001 From: Paul Wieland Date: Sun, 29 Dec 2024 22:08:28 -0500 Subject: [PATCH] Fix out of range data --- components/ratgdo/sensor/ratgdo_sensor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/ratgdo/sensor/ratgdo_sensor.cpp b/components/ratgdo/sensor/ratgdo_sensor.cpp index b97863d..8a5217f 100644 --- a/components/ratgdo/sensor/ratgdo_sensor.cpp +++ b/components/ratgdo/sensor/ratgdo_sensor.cpp @@ -80,7 +80,7 @@ namespace ratgdo { VL53L4CX_MultiRangingData_t* pDistanceData = &distanceData; uint8_t dataReady = 0; int objCount = 0; - int16_t maxDistance = 0; + int16_t maxDistance = -1; int status; if (this->distance_sensor_.VL53L4CX_GetMeasurementDataReady(&dataReady) == 0 && dataReady) { @@ -91,6 +91,7 @@ namespace ratgdo { VL53L4CX_TargetRangeData_t *d = &pDistanceData->RangeData[i]; if (d->RangeStatus == 0) { maxDistance = std::max(maxDistance, d->RangeMilliMeter); + maxDistance = maxDistance <= 25 ? -1 : maxDistance; // ignore the dust protection sticker } }