-
Notifications
You must be signed in to change notification settings - Fork 18
readTemperature now returns float. #20
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
Conversation
Implemented float temperature reading. Now LSM6SOXClass::readTemperature reads in float reference.
Changes according to last commit. readTemperature is now float type.
|
Memory usage change @ 8b377d4
Click for full report table
Click for full report CSV |
aentinger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but this whole PR is a no-go.
You are changing an API on which others are already relying upon. Furthermore its done in the most complicated and invasive manner. This PR needs a complete rework with a separate function readTemperatureFloat, or I'll never approve it.
| return 0; | ||
| } | ||
|
|
||
| temp_raw += ((int16_t)temp_H & 0b0000000011111111); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0x00FF is incredibly easier to read than 0b0000000011111111, please fix.
| static int const TEMPERATURE_OFFSET_DEG = 25; | ||
|
|
||
| temperature_deg = (static_cast<int>(temperature_raw) / TEMPERATURE_LSB_per_DEG) + TEMPERATURE_OFFSET_DEG; | ||
| float fs = 125.0; /* -40 to 85 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name fs does not feel like an improvement over TEMPERATURE_LSB_per_DEG. P
|
Implemented via #19 . |
I've re-written readTemperature according to the datasheet. It seems the 16 bit temperature ADC stores bits to two separate 8 bit spaces. Converting them to signed int and again to float with temperature range, -40 to 85, then adjusting with + 25.0 seems to be yielding a close enough temperature.