user2874122 user2874122 - 6 months ago 54
C Question

Display hex values on LCD

I have data stored in

text_buf[4] = {0x1d, 0x72, 0x2f, 0x32}
.When I send it to display on LCD, it displays some garbage. I understand that LCD displays only string, how do I make it to display hex values that is stored in
? Are there any C examples for this? Please do let me know.


Use snprintf() family to format your text_buf (or any data) to a char array and call your LCD's display routine.

char line[256];
snprintf(line, sizeof(line), "%02x %02x %02x %02x\n", text_buf[0], text_buf[1], text_buf[2], text_buf[3]);
LCD_print(line); // LCD's display routine

Reference for format sequence.