F() casts a PROGMEM character string as type __FlashStringHelper. .print() uses that as a cue to know that the argument is a disguised PROGMEM character string. If you pass that to a function that takes a regular character pointer you SHOULD get a compiler error (__FlashStringHelper is not a pointer). To make your function work I think you need to write it like this:
void repeaterPrint(int counter, __FlashStringHelper text)
{
for (int i = 0; i < counter; i++)
{
Serial.println(text);
}
}
void loop()
{
repeaterPrint(5, F("Hello World"));
}
Similarly, to declare an array of PROGMEM strings that you can Serial.print() you need to use the __FlashStringHelper type:
And I don't need the PROGMEM keyword for any of that?
The PROGMEM keyword is in the F() macro and in the Print object.
Delta_G:
And on the function example, if I want it to be able to work with either RAM or flash, I could just use an overload one with char* and one with __FlashStringHelper?
avr-gcc seems to not like the F() syntax in the array initialization
__FlashStringHelper string_table[] =
{
F("String 1"),
F("String 2")
}
and complains
tst.cpp:25:8: error: statement-expressions are not allowed outside functions nor in template-argument lists
Interesting. I do remember having some problems with it, which I guess were related to it not actually putting it in the program memory. That's something to work off of, though.