Hi,
while having a look at the just mentioned events.cpp
, I wonder whether all these comparisons are a typo.
to = micros();
while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}}
while(digitalRead(pin) != stat){if((micros() - st) > timeout){return 0;}}
st = micros();
while(digitalRead(pin) == stat){if((micros() - st) > timeout){return 0;}}
return micros()-st;
to
is initialized but never used, and st
used before being initialized. I assume, to
stands for “start timeout” and all three comparisons with “timeout” should read:
{if((micros() - to) > timeout){return 0;}}
instead to cover an overall timeout.
-- Reuti