jpraus / arduino-opentherm

Arduino library and hardware shield to send and receive data from Opentherm devices
Other
160 stars 42 forks source link

Bug with f88 converter (negative values) #27

Open jjvandenberg opened 3 years ago

jjvandenberg commented 3 years ago

Hi,

I had to changed the type conversion for negative values from the unsigned type BYTE to CHAR to allow the sign (of the float) to traverse to valueHB.

void OpenthermData::f88(float value) { if (value >= 0) { valueHB = (byte) value;

float fraction = (value - valueHB);
valueLB = fraction * 256.0;

} else { //valueHB = (byte)(value - 1); valueHB = (char) (value -1) ; float fraction = (value - valueHB - 1); Serial.print("Fraction == ");Serial.println(fraction); valueLB = fraction * 256.0; } }

Thanks for the lib, it's great fun to be able to read and set a Chronotherm IV thermostat.