mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-24 05:29:17 +01:00
Simplified char to nibble function
This commit is contained in:
parent
358ebf88f4
commit
ed293c2628
@ -956,22 +956,13 @@ char* getDatabaseFieldFromRow(const char* dbstr, uint8_t fieldnum)
|
|||||||
|
|
||||||
unsigned char getNibbleFromChar(char num)
|
unsigned char getNibbleFromChar(char num)
|
||||||
{
|
{
|
||||||
if(num >= '0' && num <= '9')
|
char ret_char = num & 0x0F;
|
||||||
|
if(num > '9')
|
||||||
{
|
{
|
||||||
return (num - '0');
|
ret_char += 9;
|
||||||
}
|
|
||||||
else if(num >= 'A' && num <= 'F')
|
|
||||||
{
|
|
||||||
return (num - 'A' + 10);
|
|
||||||
}
|
|
||||||
else if(num >= 'a' && num <= 'f')
|
|
||||||
{
|
|
||||||
return (num - 'a' + 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char getByteFromChars(char msn, char lsn)
|
unsigned char getByteFromChars(char msn, char lsn)
|
||||||
|
Loading…
Reference in New Issue
Block a user