This commit is contained in:
thelsing 2020-06-23 00:21:00 +02:00 committed by GitHub
parent d3788d3ee4
commit 5855f35eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -416,11 +416,11 @@ int busValueToUnsigned8(const uint8_t* payload, size_t payload_length, const Dpt
switch (datatype.subGroup) switch (datatype.subGroup)
{ {
case 1: case 1:
value = (uint8_t)(unsigned8FromPayload(payload, 0) * 100.0 / 255.0); value = (uint8_t)round(unsigned8FromPayload(payload, 0) * 100.0 / 255.0);
return true; return true;
case 3: case 3:
value = (uint8_t)unsigned8FromPayload(payload, 0) * 360.0 / 255.0; value = (uint8_t)round(unsigned8FromPayload(payload, 0) * 360.0 / 255.0);
return true; return true;
case 6: case 6:
@ -1839,4 +1839,4 @@ void bcdToPayload(uint8_t* payload, size_t payload_length, int index, uint8_t va
payload[index / 2] = (payload[index / 2] & 0xF0) | (value & 0x0F); payload[index / 2] = (payload[index / 2] & 0xF0) | (value & 0x0F);
else else
payload[index / 2] = (payload[index / 2] & 0x0F) | ((value << 4) & 0xF0); payload[index / 2] = (payload[index / 2] & 0x0F) | ((value << 4) & 0xF0);
} }