lib_slcd: fix encode/decode of binary nibble to/from ascii hex

Binary nibble to/from ascii hex conversion was buggy on both
lib_slcdencode and lib_slcddecode libraries.

This bug caused the slcd library to fail to decode 5-byte sequence command
which have 'count' argument value bigger than 0x9.

Signed-off-by: Federico Braghiroli <federico.braghiroli@gmail.com>
This commit is contained in:
Federico Braghiroli 2023-12-10 17:06:55 +01:00 committed by Xiang Xiao
parent 387e9d64ac
commit 8b9c64eecf
2 changed files with 2 additions and 2 deletions

View File

@ -87,7 +87,7 @@ static uint8_t slcd_nibble(uint8_t ascii)
}
else
{
return ascii - 'a';
return ascii - 'a' + 10;
}
}

View File

@ -60,7 +60,7 @@ static uint8_t slcd_nibble(uint8_t binary)
}
else
{
return 'a' + binary;
return 'a' + binary - 10;
}
}