Skip to content

Conversation

@evaherrada
Copy link
Collaborator

@evaherrada evaherrada commented Nov 25, 2020

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.

@kattni
Copy link
Contributor

kattni commented Jan 5, 2021

@makermelissa Can you take a look at this and test it? Thanks!

@ladyada
Copy link
Member

ladyada commented Jan 5, 2021

i dont like this solution...we should have maybe something at a higher level check for the wrong values, but shimming a low level function is asking for trouble
@dherrada please revise at the example level!

@evaherrada
Copy link
Collaborator Author

@ladyada Will do

@evaherrada evaherrada mentioned this pull request Jan 11, 2021
@evaherrada evaherrada closed this Jan 11, 2021
@evaherrada evaherrada deleted the temp-stability branch January 11, 2021 16:40
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.

-92 degrees celsius randomly returned from imu's temperature field

4 participants