-2

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?

gre_gor
  • 6,669
  • 9
  • 47
  • 52
HumbleBumble
  • 45
  • 1
  • 7
  • 1
    Please read [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question) before attempting to ask more questions. –  Jul 24 '17 at 14:11

1 Answers1

1

Most character-mode LCDs come with a standard font in ROM and the ability to make a few custom characters (typically 8). Refer to your datasheet, but what you want is not possible in any LCD I've seen in the past ten years.

Graphical LCDs are different, as you "draw" on them whatever you want.

TomServo
  • 7,248
  • 5
  • 30
  • 47
  • Yes. I am pretty sure that you are right, but my manager wants to me to do this and I find it quite frustrating. – HumbleBumble Jul 24 '17 at 14:14
  • 2
    Show him the datasheet and explain that it is not possible. – TomServo Jul 24 '17 at 14:15
  • So I suppose what I really wanted to ask was: If a character is being displayed from a certain address of CG RAM on LCD, will any changes made in the exact CG RAM address will affect the character being displayed already? From what I am observing, it seems like LCD cannot latch the values already being displayed. Thanks again for your insight. – HumbleBumble Jul 24 '17 at 20:13
  • @SaxMaster Hard to say. Looking at your code, I'm wondering what the LCD library does. Typically `lcd.setCursor(0, 0);` would set the target RAM address for the next command to the 0th character, 0th row... but hard so say since I don't know your library. Looks like you're trying to do the right thing, but perhaps you should check the library call for setCursor... Also maybe use 4 of your custom chars for "HEAT" and 3 for "COOL" – TomServo Jul 24 '17 at 20:28
  • Yes. setCursor(int col, int row) performs: command(LCD_SETDDRAMADDR | (col + _row_offsets[row])); My manager's idea is that once the character is displayed it would not be flushed away when the RAM is replaced with other characters, but it is very hard to tell, as Arduino's liquidcrystal library is not doing anything super fancy. Thank you for your idea. – HumbleBumble Jul 24 '17 at 20:42
  • http://www.avrfreaks.net/forum/more-7-custom-characters-lcd-hitachi-44780 I found this thread interesting. – HumbleBumble Jul 24 '17 at 20:48
  • Looks promising. Perhaps define your 7 characters HEATCOL up front and them don't keep redefining them. That may be why the one you defined last, shows up twice... – TomServo Jul 24 '17 at 20:51