-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi,
When using the event based ping_timer function, I noticed that the code would not return any value if the distance was out of range. I looked into the library and found the check_timer() function and added/changed a few lines shown below. Is there a reason that you did not have it the way I changed it to?
Original Code
boolean NewPing::check_timer() {
if (micros() > _max_time) { // Outside the timeout limit.
timer_stop(); // Disable timer interrupt
return false; // Cancel ping timer.
}
if (!(*_echoInput & _echoBit)) { // Ping echo received.
timer_stop(); // Disable timer interrupt
ping_result = (micros() - (_max_time - _maxEchoTime) - 13); // Calculate ping time, 13uS of overhead.
return true; // Return ping echo true.
}
return false; // Return false because there's no ping echo yet.
}
New Code
boolean NewPing::check_timer() {
if (micros() > _max_time) { // Outside the timeout limit.
timer_stop(); // Disable timer interrupt
ping_result = NO_ECHO // Added by Nathan
return true; // Added by Nathan
}
if (!(*_echoInput & _echoBit)) { // Ping echo received.
timer_stop(); // Disable timer interrupt
ping_result = (micros() - (_max_time - _maxEchoTime) - 13); // Calculate ping time, 13uS of overhead.
return true; // Return ping echo true.
}
return false; // Return false because there's no ping echo yet.
}
Metadata
Metadata
Assignees
Labels
No labels