Hello,
coiuld someone explain the filtersize settings to me ?
I can´t find a docu about it.
Thank you so much and have a great day
Sascha
Docu about Filtersize HC-SR04 Plugin
Moderators: grovkillen, Stuntteam, TD-er
- Sasch600xt
- Normal user
- Posts: 164
- Joined: 10 Sep 2018, 16:37
Docu about Filtersize HC-SR04 Plugin
"the flat earth society has members all around the globe"
Re: Docu about Filtersize HC-SR04 Plugin
It is the first parameter of this function in the NewPing library:
It looks like the number of pings performed and returning the median value. (for even number of pings it does not average 2 values, so strictly speaking it is only the median value for odd number of pings)
Code: Select all
unsigned long NewPingESP8266::ping_median(uint32_t it, unsigned int max_cm_distance) {
unsigned int uS[it], last;
uint32_t j, i = 0;
unsigned long t;
uS[0] = NO_ECHO;
while (i < it) {
t = micros(); // Start ping timestamp.
last = ping(max_cm_distance); // Send ping.
if (last != NO_ECHO) { // Ping in range, include as part of median.
if (i > 0) { // Don't start sort till second ping.
for (j = i; j > 0 && uS[j - 1] < last; j--) // Insertion sort loop.
uS[j] = uS[j - 1]; // Shift ping array to correct position for sort insertion.
} else j = 0; // First ping is sort starting point.
uS[j] = last; // Add last ping to array in sorted position.
i++; // Move to next ping.
} else it--; // Ping out of range, skip and don't include as part of median.
if (i < it && micros() - t < PING_MEDIAN_DELAY)
delay((PING_MEDIAN_DELAY + t - micros()) / 1000); // Millisecond delay between pings.
}
return (uS[it >> 1]); // Return the ping distance median.
}
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests