high ceiling & day light sensor adjustments

Ceilings that are higher than the sensor capabilities result in out of range (-1) readings.
Daylight, water on the floor and other environment changes can also cause the sensor to read out of range. This change results in 30 readings of -1 to be VehicleDetected false.
This commit is contained in:
Paul Wieland 2024-12-06 14:40:34 -05:00
parent f58247e029
commit b2f6ec1379
2 changed files with 6 additions and 8 deletions

View File

@ -65,7 +65,7 @@ namespace ratgdo {
observable<uint32_t> closing_delay { 0 };
observable<int16_t> target_distance_measurement { -1 };
std::vector<int16_t> distance_measurement { std::vector<int16_t>(10, -1) }; // the length of this vector determines how many in-range readings are required for presence detection to change states
std::vector<int16_t> distance_measurement { std::vector<int16_t>(30, -1) }; // the length of this vector determines how many in-range readings are required for presence detection to change states
observable<int16_t> last_distance_measurement { 0 };
observable<uint16_t> openings { 0 }; // number of times the door has been opened

View File

@ -88,15 +88,13 @@ namespace ratgdo {
objCount = pDistanceData->NumberOfObjectsFound;
maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter;
/* if(maxDistance < 0) maxDistance = -1;
* if the sensor is pointed at glass, there are many error readings which will fill the
/*
* if the sensor is pointed at glass, there are many error -1 readings which will fill the
* vector with out of range data. The sensor should be sensitive enough to detect the floor
* in most situations, unless its mounted really far away.
* If this doesn't work, then the vector size will have to increase substantially
* in most situations, but daylight and/or really high ceilings can cause long distance
* measurements to be out of range.
*/
if (maxDistance > 0) {
this->parent_->set_distance_measurement(maxDistance);
}
// ESP_LOGD(TAG,"# obj found %d; distance %d",objCount, maxDistance);