diff --git a/src/knx/dptconvert.cpp b/src/knx/dptconvert.cpp index 1c5a734..9ed1154 100644 --- a/src/knx/dptconvert.cpp +++ b/src/knx/dptconvert.cpp @@ -416,11 +416,11 @@ int busValueToUnsigned8(const uint8_t* payload, size_t payload_length, const Dpt switch (datatype.subGroup) { 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; 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; 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); else payload[index / 2] = (payload[index / 2] & 0x0F) | ((value << 4) & 0xF0); -} \ No newline at end of file +}