pvvx / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometers and Telink Flasher
https://github.com/pvvx/pvvx.github.io/tree/master/ATC_MiThermometer
Other
2.75k stars 196 forks source link

Avoid integer precsion loss in denominator of battery calculation #525

Open Cossid opened 1 week ago

Cossid commented 1 week ago

Avoid integer precision loss in denominator of battery calculation while remaining within uint16_t size constraints.

This keeps the entire calculation within uint16_t constraints while not causing an integer rounding in the denominator.

Fixes #524

Feel free to reject this if you feel this is too hacky, as I understand it makes it less clear at the expense of being more technically correct.