Arduino - Trouble with PROGMEM a avr/pgmspace.h

836 Views Asked by At

im trying to use progmem instead on static char to save some valueble space. Everything seems fine, but serial and lcd show some weird newline symbol instead of my text.

What im trying to do:

...
#include <avr/pgmspace.h>
const static char PROGMEM textSDFailed[]        = "Filesys failed";
const static char PROGMEM textSDAvailable[]     = "Filesys is avail.";
...
lcd.print(textSDFailed);
...

And what i get on lcd when print: https://i.stack.imgur.com/V81Pn.jpg

Can someone help me?

1

There are 1 best solutions below

4
On BEST ANSWER

You can use the print which takes a progmem string. The overloaded print for progmem string has __FlashStringHelper* as parameter. This is normally for the Arduino F() macro.

For repeated use of the cast I do:

#define FSH_P const __FlashStringHelper*

Then I use it this way:

  lcd.print((FSH_P) textSDFailed);

If you can, use the F macro directly:

  lcd.print(F("Filesys failed"));