InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.71k stars 927 forks source link

shakewake: Slightly improve accuracy #1726

Closed FintasticMan closed 1 year ago

FintasticMan commented 1 year ago

The (accumulated) speed was calculated by dividing first and multiplying/adding after, which results in more rounding errors than if you multiply/add first and then divide. The values aren't big enough to overflow.

github-actions[bot] commented 1 year ago
Build size and comparison to main: Section Size Difference
text 409252B -16B
data 996B 0B
bss 63356B 0B
JF002 commented 1 year ago

@FintasticMan What improvement does this PR bring to the user? Or how should we test it?

FintasticMan commented 1 year ago

This change doesn't affect the user much, if at all. It's just a small change that makes the maths closer what was intended according to the comment in the code.

FintasticMan commented 1 year ago

Merged with #826.