Trouble with PROGMEM a avr/pgmspace.h

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);
Serial.println(textSDFailed);
...

And what i get on lcd when print: Imgur: The magic of the Internet

Can someone help me?

Try with PROGMEM after the array definition. Static is not useful

const char textSDFailed[] PROGMEM = "Filesys failed";

It doesnt help at all. Lcd and even serial is the same.

Sorry forgot to mention the cast

 Serial.print((__FlashStringHelper *) textSDFailed);

for serial seems its working, but lcd.print is unchanged. still print the same 4lines

Post the full code then (you need the cast for the LCD too, you did that - right?)

im kinda beginer, got a huuge numbers of line but some lines with lcd print have like:

void Welcome() {
  lcd.noBlink();
  delay(250);
  lcd.setCursor(0,0);
  lcd.print(textApp);
  lcd.setCursor(0,2);
  lcd.blink();
  delay(500);
  lcd.setCursor(0,2);
  lcd.print(textInit);
  delay(750);
  lcd.noBlink();
}

.. what are those cast? can you bit explane to me

The « cast » is basically when you tell the compiler to « change » the type of a variable to something else

Here

 Serial.print([color=red](__FlashStringHelper *)[/color] textSDFailed);

I’m casting the textSDFailed pointer into a pointer to a __FlashStringHelper

You need the [color=red](__FlashStringHelper *)[/color] everywhere you print a PROGMEM char array

Ok, nice got it.
One more ask, can u make some macros, or define it before one, or i have to anywhere i want to call for exm. i want only call textFailed, but i have to with (__FlashStringHelper *) textFailed.
so i can use only textFailed whenever i have it (or other things) in libraries/files ?

Not sure i get exactly what you want

You could do

 const char textSDFailed[] PROGMEM = "Filesys failed";
#define textSDFailedForPrinting ((__FlashStringHelper *) textSDFailed)

Then you can use textSDFailedForPrinting when you want to print it

wanna make some functuon, define, declaration or whatever to replace (__FlashStringHelper *) with somethink simpler or dont use it even.

Smt like:

#define PP(s) ((__FlashStringHelper*)(s))

and then use only max PP(textSDFailed)

That would work too