|
Main /
LK162-12The LK162-12 The datasheet NotesThe I2C bus and the display require that all the data be send in hexadecimal, so we had to write a bit of code to convert a string to the correct format for display. The C++ code is as follows: char *text = "Hello World!"; char temp[32]; char toput[128] = "0x"; int i = 0; while(text[i] != '\0' && i < 32) { if (text[i] == '\n' ) { // handles newlines by printing CR and LF sprintf(temp, "%s", "0D0A"); } else { sprintf(temp, "%2x", text[i]); } strcat(toput, temp); i++; } The string |