add method to f8.8, rename method from f8.8

This commit is contained in:
Yurii
2023-11-26 16:04:56 +03:00
parent eb2dcd7c09
commit 8ec3655340

View File

@@ -116,15 +116,19 @@ public:
} }
// converters // converters
float f88(unsigned long response) { float fromF88(unsigned long response) {
const byte valueLB = response & 0xFF; const byte valueLB = response & 0xFF;
const byte valueHB = (response >> 8) & 0xFF; const byte valueHB = (response >> 8) & 0xFF;
float value = (int8_t)valueHB; float value = (int8_t) valueHB;
return value + (float)valueLB / 256.0; return value + (float) valueLB / 256.0;
} }
int16_t s16(unsigned long response) { template <class T> unsigned int toF88(T val) {
return (unsigned int) (val * 256);
}
int16_t fromS16(unsigned long response) {
const byte valueLB = response & 0xFF; const byte valueLB = response & 0xFF;
const byte valueHB = (response >> 8) & 0xFF; const byte valueHB = (response >> 8) & 0xFF;