From 8ec36553404f3b914853a7d5eafd52ece3b56ddd Mon Sep 17 00:00:00 2001 From: Yurii Date: Sun, 26 Nov 2023 16:04:56 +0300 Subject: [PATCH] add method to f8.8, rename method from f8.8 --- lib/CustomOpenTherm/CustomOpenTherm.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/CustomOpenTherm/CustomOpenTherm.h b/lib/CustomOpenTherm/CustomOpenTherm.h index c143314..c4f818c 100644 --- a/lib/CustomOpenTherm/CustomOpenTherm.h +++ b/lib/CustomOpenTherm/CustomOpenTherm.h @@ -116,15 +116,19 @@ public: } // converters - float f88(unsigned long response) { + float fromF88(unsigned long response) { const byte valueLB = response & 0xFF; const byte valueHB = (response >> 8) & 0xFF; - float value = (int8_t)valueHB; - return value + (float)valueLB / 256.0; + float value = (int8_t) valueHB; + return value + (float) valueLB / 256.0; } - int16_t s16(unsigned long response) { + template unsigned int toF88(T val) { + return (unsigned int) (val * 256); + } + + int16_t fromS16(unsigned long response) { const byte valueLB = response & 0xFF; const byte valueHB = (response >> 8) & 0xFF;