Correct implementation of forced measurements #91
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.
Issue
The current implementation does not allow you to trigger the sensor correctly and with as little overhead as possible.
A measurement always results in unnecessary computation followed by the actual forcing and then by a read-out of the old value, as the sensor needs at least 5.5ms to acquire even a single measurement.
Description of changes/fixes
These patches introduce the
force()
function to trigger a sensor measurement. The result can then be read out in the usual way at any later point in time (till it is triggered again). To know if the device is busy measuring or what mode it is in, it also introduces access to the state and mode register through thebusy()
andmode()
function call.It also includes a patch to support the use on none-default Wire interfaces and some minor cleanups.
All the examples were updated as well.
If necessary, I can also split the commit in separate requests.
Steps to test
busy()
or itsmode()
no longer being forced.@kvoit significantly contributed to this work.