samd: Size-optimize the temperature code with an 0.5 to 2.0 degree relative additional error #7045
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.
Convert most of the math to integer, and don't be too prissy about rounding.
I used a standalone program together with my particular device's calibration values of
and found the "errors" at 0..60°C, meaning the difference relative to the existing reference code.
At 25°C the first commit introduces an 0.5°C relative change. The second commit introduces a 1°C relative change, while the biggest change over the whole 0°C—60°C range was 2°C.
The total size savings appears to be 268 bytes, based on
nm --print-size
of themcu_processor_get_temperature
function in the trinket m0 build.I also tested that the temperature value remains plausible-looking on a PyRuler.