Closed senhtry closed 4 years ago
Hi, thank you for finding this bug. Yeah, I've never really worked with negative temperatures. Should I incorporate your code or do you wish to create a pull request?
Hi, thank you for finding this bug. Yeah, I've never really worked with negative temperatures. Should I incorporate your code or do you wish to create a pull request?
You can simply use my code :)
Since OpenTherm protocol use the Two's complement (https://en.wikipedia.org/wiki/Two%27s_complement), it's necessary to minus 1 for negative number.
Example :
A temperature of -5.25°C in f8.8 format is represented by the 2-byte value FAC0 hex (FAC0hex = - (10000hex-FAC0hex) = - 0540hex = - 1344dec, dividing by 256 gives -5.25)
With your old code, you will get the wrong FBC0 hex instead of correct FAC0 hex.