LCD custom characters defined at beginning

I'm writing my own library for the LCD with the idea to get in-depth knowledge of the process and the last thing that I didn't implement in it was the custom characters.

I came up to the problem, where if I don't reset the cursor and clear the display, I can't write anymore after the write to the CG-RAM .... , which forces me to create the custom characters at the beginning and then reset the cursor.

Then I checked the example of the official library to test if the same problem is present in it too and it is:

 lcd.begin(16, 2);

  // create a new character
  lcd.createChar(0, heart);

  // set the cursor to the top left.
  lcd.setCursor(0, 0);

  // Print a message to the LCD.
  lcd.print("Hi:");
  lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte

The characters are first created, then the cursor is reset to 0,0. If we skip that no character will be printed, but why?

Please post code that compiles.

And which of the several LiquidCrystal libraries are you using?

It’s down to the way the library is written . Whoever wrote it wanted it to work that way! You position the cursor and print .

I think you need to list your complete sketch to illustrate your point which is not fully clear .

You can look at the library files yourself and work out what is done and how with create character etc and how they are dealt with

There is a problem with the library, createChar calls the command for setting value to the CG-RAM, but doesn't return to DD-RAM.
Because of that, in their example they all setCursor, which does exactly that.
But that creates a problem.

  • If you want to create a character after you have written something to the display, you must revert to DD-RAM, but you must know the position of the cursor, which it was before writing to CG-RAM ...

The solution is simple :slight_smile: Just keep a record, where you cursor's position was and set the DD-RAM to it.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.