0

Some years ago I stumble with a problem while using the 2x16 LCD. What happened was that there was a limit to how may byte arrays I could declare. So my project came to a halt because I needed to create more custom characters to advance any further...

The lcd accept custom characters to store them but I suppose there is a limit to this, am I wrong?

I'm trying to create a set of custom characters that move on screen. Since there are a lot of animations I need several of them to have a smooth animation. The problem resides in the limit of characters I can pre-establish after executing lcd.begin()

I don't post code because to my understanding that is not relevant and because sincerely is a crap since I wrote it down when I was learning programming some years ago. I want to resolve this so I can rewrite the code.

LCD version: QAPASS 1602A

Here is an example:

byte Ghost[8] = { 0b00000, 0b01110, 0b01110, 0b10101, 0b11111, 0b11111, 0b11111, 0b10101 };

lcd.createChar(0, Ghost);

So the right question is: Do I need to reset the LCD chip then declare the new characters to the lcd to make it available? How?

1

there was a limit to how may byte arrays I could declare.

If the problem was that you ran out of free RAM, then the fix is to move those byte arrays into program space.

Atmega 328 processors (Uno) are very RAM-limited. Fortunately you can assign constant data - fixed character strings, lookup tables for math, fonts, CRC calculation, etc - to be stored in program space which is much more generous. The upside is you can free lots of RAM in an application like yours that needs lots of constant data. The downside is that access to the data is a little bit slower:

// Definitions for data in program space
#include <avr/pgmspace.h>

// Place the character table in Flash
byte const Ghost[8] PROGMEM = { 
   0b00000,
   0b01110,
   0b01110,
   0b10101,
   0b11111,
   0b11111,
   0b11111,
   0b10101
};


// Read a byte of character data
OneByte = pgm_read_byte(&Seg7_segtbl[index]);

Update:

LCD version: QAPASS 1602

If that has an Hitachi HD44780 controller on it, its datasheetsays it has a 64-byte character RAM - more than enough for a full display of 2 x 16 unique characters, but if you need a wider choice of characters than a set of 64, you may need to re-load the RAM with a custom sub-set for any given screen-full. For animating, though, you'll probably need all of the individual parts of each animation in the LCD RAM at once; reloading during animation will most likely disturb the smoothness. One possibility is to load part of a subset between animation frames - if that's even possible. (I haven't studied this controller to that level of detail).

9
  • 1
    Thanks sir! So &Seg7_segtbl[index] where index means a specific value of the constant byte variable stored in flash memory... This can come in handy but I think my problem is more related to the lcd itself. I heard that the lcd can store custom characters on its own but obviously it has a limit. – DarkXDroid Feb 28 '17 at 14:15
  • 1
    Correct (about the address expression). To help with your LCD, we'll need to know what LCD and driver chip you're using (manufacturer and part#), and more specifics about the the problem you have: what are you trying to do and how did you do it? And what were you expecting to would happen, and what happened instead? – JRobert Feb 28 '17 at 14:35
  • Check my edit and I'm grateful for the tips and your time – DarkXDroid Feb 28 '17 at 14:57
  • 1
    Typical HD44780-based 2x16 LCD support 8 programmable characters, not 16. They show up as characters #0 to 7 and again as characters #8 to 15. Definitely not 64 programmable characters, not 32, not 16 – just 8 of them. – James Waldby - jwpat7 Feb 28 '17 at 17:46
  • @jwpat Then perhaps I misinterpreted the datasheet or I found the wrong one? But Itook that spec from the datasheet. – JRobert Feb 28 '17 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.