Serial.print_P feature request

feature request: I'd like to see a version of Serial.print and Serial.println (call 'em Serial.print_P and Serial.println_P) that accept a PROGMEM string as an argument, so that constant strings (menus, prompts, etc) can more easily be used to save RAM.

-j

I guess this got buried pretty fast two years ago and I'm kinda surprised it hasn't come up since then.

_P versions of all of the Serial functions would be really helpful.

Is there a place to submit patches to the Arduino libraries? I'd be willing to write the code.

You would not add this to the serial but to the print library. Thus everything inheriting from it could use it. I did this some time ago with some homemade patch. It is pretty easy to do. If you are interested I can dig up the code.

Udo

It would be nice to do by overloading print() and println() rather than adding functions with different names. If it's not possible to distinguish progmem strings by types, perhaps we could wrap them in a simple class? For example:

Serial.print(F("constant string"))

where F() is a class constructor (or a macro that substitutes in a class constructor).

I believe Mikal Hart did some work along these lines.

Patches on the Google Code issue list would be the best way to move this forward: http://code.google.com/p/arduino/issues/list