Skip to content

Commit

Permalink
uint16_to_float and int16_to_float function intermediate type changed…
Browse files Browse the repository at this point in the history
… from uint32_t to uint16_t and from int32_t to int16_t
  • Loading branch information
txubelaxu committed Nov 22, 2024
1 parent 2c6b01d commit e5855b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/jk_rs485_bms/jk_rs485_bms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t>(byteArray[0]) << 0) | (static_cast<uint16_t>(byteArray[1]) << 8);
uint16_t uintValue = (static_cast<uint16_t>(byteArray[0]) << 0) | (static_cast<uint16_t>(byteArray[1]) << 8);

float floatValue = static_cast<float>(uintValue);

Expand All @@ -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<int16_t>(byteArray[0]) << 0) | (static_cast<int16_t>(byteArray[1]) << 8);
int16_t intValue = (static_cast<int16_t>(byteArray[0]) << 0) | (static_cast<int16_t>(byteArray[1]) << 8);

float floatValue = static_cast<float>(intValue);

Expand Down

0 comments on commit e5855b5

Please sign in to comment.