Made temperature more stable on raspberry pi #64
Closed
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.
I added some overriding methods of UnaryStruct to _ReadOnlyUnaryStruct so it will now be more stable on the Raspberry Pi. Fixes #58
I added two overriding methods, __init__ and __get__. The init method just calls to super() and defines a variable that will be used later to compare to the current value. get then gets the result from super().__get__(). If it is running on CircuitPython, it just returns that value. However, if it is running on a Linux computer, then it checks to see if the current and previous values are exactly 128 apart. If they are, then it tries again. If they are 128 apart again, then it just takes that value, strips off the first 2 bits, making it the same as the last value, and returning it.
I have not tested this with a negative temperature value yet.