fix for showing 3-byte values - #475

This commit is contained in:
proddy
2020-09-03 21:32:29 +02:00
parent 66d105f99f
commit d6f4e4bdf4
3 changed files with 5 additions and 2 deletions

View File

@@ -101,7 +101,7 @@ class Telegram {
// s is to override number of bytes read (e.g. use 3 to simulat a uint24_t)
void read_value(Value & value, const uint8_t index, uint8_t s = 0) const {
uint8_t size = (!s) ? sizeof(Value) : s;
int8_t abs_index = ((index - offset + size - 1) >= message_length - 1) ? -1 : (index - offset);
int8_t abs_index = ((index - offset + size - 1) >= message_length) ? -1 : (index - offset);
if (abs_index < 0) {
return; // out of bounds, we don't change the value
}