Arduino Mega 2560 with Adafruit ST7565 - RAM is full

Hi everyone,

I’ve got a “little” problem: I’m using an Arduino Mega 2560 with a graphic lcd (ST7565 by Adafruit, the one with RGB backlight). I have to print a lot of strings (several pictures, 5 menus and an overview screen), and I’m running out of SRAM (well, I suppose this since the program at a certain point crashes and does nothing, and the lcd backlight changes randomly; if some random strings or variables are removed from the program everything works). The bmps are already in progmem space.

So the question is: how to put these strings in flash memory instead of SRAM to free memory?

I’ve altrady tried this:

glcd.print(0, 0, F("String to be printed"));
glcd.print(0, 0, (char*)F("String to be printed"));
glcd.print(0, 0, (char)F("String to be printed"));

The first doesn’t even compile, the second prints random characters, while the third prints absolutely nothing.

I’ve also tried to include <avr/pgmspace.h> and to use PROGMEM keyword but then, when it comes to print those variables/strings, even using pgm_read_byte it prints random characters.

What should I do now? Just upgrade to a Due?

Thanks in advance,

Davide

What library are you using?

Most Adafruit libraries inherit Adafruit_GFX.h which in turn inherits Print.h

So I would not expect your print method. Print.h accepts F() arguments.

Attach your code. Most Apps can put anonymous strings in Flash and print(F()) accordingly.
Likewise, most libraries handle Fonts in Flash.

So it really comes down to what you are doing.

David.