hex_to_bin() may be used to convert hexdecimal digit to its binary
representation.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
shift = 0;
value = 0;
while (*esc && cgoffset < 8) {
+ int half;
+
shift ^= 4;
- if (*esc >= '0' && *esc <= '9') {
- value |= (*esc - '0') << shift;
- } else if (*esc >= 'A' && *esc <= 'F') {
- value |= (*esc - 'A' + 10) << shift;
- } else if (*esc >= 'a' && *esc <= 'f') {
- value |= (*esc - 'a' + 10) << shift;
- } else {
- esc++;
+
+ half = hex_to_bin(*esc++);
+ if (half < 0)
continue;
- }
+ value |= half << shift;
if (shift == 0) {
cgbytes[cgoffset++] = value;
value = 0;
}
-
- esc++;
}
lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));