I am working on a project where I need to use custom font only. I already defined all the Latin alphabets as byte arrays, so that I can simply copy the array value to the variable that's to be written. Below is a snippet of my code.
void menuInit() {
byte customChar1[8];
byte customChar2[8];
byte customChar3[8];
byte customChar4[8];
byte customChar5[8];
byte customChar6[8];
byte customChar7[8];
byte customChar8[8];
for (int i = 0; i <= 7; i++) {
customChar1[i] = H[i];
customChar2[i] = E[i];
customChar3[i] = A[i];
customChar4[i] = T[i];
}
lcd.createChar(0, customChar1);
lcd.createChar(1, customChar2);
lcd.createChar(2, customChar3);
lcd.createChar(3, customChar4);
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.write(byte(1));
lcd.write(byte(2));
lcd.write(byte(3));
for (int i = 0; i <= 7; i++) {
customChar1[i] = C[i];
customChar2[i] = O[i];
customChar3[i] = O[i];
customChar4[i] = L[i];
}
lcd.createChar(0, customChar1);
lcd.createChar(1, customChar2);
lcd.createChar(2, customChar3);
lcd.createChar(3, customChar4);
lcd.setCursor(0, 1);
lcd.write(byte(0));
lcd.write(byte(1));
lcd.write(byte(2));
lcd.write(byte(3));
Arduino LCD documentation says that I need to write byte(int)
in lcd.write()
in order to print the created custom character. However, if I do that, I get two rows of "COOL" displayed on my LCD. It is probably because both the first row and second row are making reference to the same address. Is there any way I can copy the byte values to somewhere else and let it stay as it is?