Open mrguen opened 6 years ago
I have multiple concerns about the correctness and CPU usage of this change. Sorry, no time right now to write a lengthy explanation.
But briefly, if the issue is merely incorrect output on the 1st measurement, that should be handled in the non-interrupt read() function. Burdening the CPU critical interrupt code with so many extra condition tests isn't the way.
This code fixes
Error on first measurement was because it needs a first interrupt to stamp the first capture. Hence in this code on the first capture, we only compute previous_capture.
An averaging parameter with a default value of 1 is passed to begin().
Was tested on Atmega328p . I could not test teensy, since I don't have one.