Add parameterized 'timeout' to 'pulseIn' function #2158
+111
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The 'pulseIn' function has a static 3 second timeout, I added another version to mimic Arduino. This has third parameter that specifies the number of microseconds to wait before timing out. Link to open issue is in 'Reference' section.
Solution
Adds addition parameter to a copied function and uses this value to calculate the number of systems ticks to wait, then uses this value in all of the timeout comparison statements
Steps to Test
This is my first contribution to Particle device-os, so I have yet to add testing
References
I'm new, so similar to the tests, I have yet to add an addition to the docs. But the opened issue can be found here:
https://github.com/particle-iot/device-os/issues/1379
Completeness