Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error on first measurement + added averaging parameter #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mrguen
Copy link

@mrguen mrguen commented Apr 30, 2018

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.

@PaulStoffregen
Copy link
Owner

I have multiple concerns about the correctness and CPU usage of this change. Sorry, no time right now to write a lengthy explanation.

@PaulStoffregen
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants