From e5855b51bf6dc4038d1b52e94d10e98770a4e5ce Mon Sep 17 00:00:00 2001 From: Txu Date: Fri, 22 Nov 2024 10:42:48 +0100 Subject: [PATCH] uint16_to_float and int16_to_float function intermediate type changed from uint32_t to uint16_t and from int32_t to int16_t --- components/jk_rs485_bms/jk_rs485_bms.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/jk_rs485_bms/jk_rs485_bms.cpp b/components/jk_rs485_bms/jk_rs485_bms.cpp index 4f449d6c..62b2a829 100644 --- a/components/jk_rs485_bms/jk_rs485_bms.cpp +++ b/components/jk_rs485_bms/jk_rs485_bms.cpp @@ -31,7 +31,7 @@ float int32_to_float(const uint8_t* byteArray) { float uint16_to_float(const uint8_t *byteArray) { // Combine the bytes into an int32_t - uint32_t uintValue = (static_cast(byteArray[0]) << 0) | (static_cast(byteArray[1]) << 8); + uint16_t uintValue = (static_cast(byteArray[0]) << 0) | (static_cast(byteArray[1]) << 8); float floatValue = static_cast(uintValue); @@ -40,7 +40,7 @@ float uint16_to_float(const uint8_t *byteArray) { float int16_to_float(const uint8_t *byteArray) { // Combine the bytes into an int32_t - int32_t intValue = (static_cast(byteArray[0]) << 0) | (static_cast(byteArray[1]) << 8); + int16_t intValue = (static_cast(byteArray[0]) << 0) | (static_cast(byteArray[1]) << 8); float floatValue = static_cast(intValue);