BigBobby:
Well my format strings never need to be RAM...even in the rare case I need to pick between two of them I can use ? : to pick between two in flash. As for my %s arguments, I have them in RAM but for %S I have them in PROGMEM. Heh...since my function name != printf() I can get away with those things and still be compatible C. Really, the way my custom printf() really saves me resources is by understanding iQ and fixed point decimal numbers. My customers usually have their own custom printfs too for the same reasons so they don't mind me doing this stuff. Going to c++ would be a jump though.
I'll read through the github links tomorrow. I really appreciate all of this effort to help me!
For printing, my suggestion is to grab the "Print" package from GitHub and then REPLACE your Arduino "Print.cpp" and "Print.h" with the new ones (save backups of the old ones, of course).
It's completely compatible with the old code (in fact, most of it IS the old code), it's just that NEW features are added such as "print_P" (along with println_P), a "print_E" which can print strings in EEPROM, the ability to print int64_t and uint64_t variables and a "print number" re-write that uses no SRAM buffer.
As far as using printf, note that printf already exists in AVR-GCC.... the only reason it doesn't work "out of the box" is that stdin, stdout and stderr are not "connected" to anything.
That's where the "Stdinout" library comes in. If you include that library in your code, an object named "STDIO" is pre-instantiated and it supports a few functions:
STDIO.open (device);
STDIO.close ();
STDIO.getStream (FILE *);
The first one connects "device" to stdin, stdout and stderr... for example:
STDIO.open (Serial);
Now, if you do "printf ("Hello\n"); it's sent to the serial port. Likewise, "getc" and other input functions will READ from Serial.
You can also specify different devices... for example:
STDIO.open (Serial, LCD);
Connects "Serial" to stdin and "LCD" to stdout and stderr. So, a simple "printf ("%c", fgetc (stdin));" would read serial input and display it on the LCD screen.
Lastly, you can do all three individually. Let's say you wanted to read serial input, write to an LCD and send any error info to serial output (using "fprintf (stderr, "string....").
You would do this:
STDIO.open (Serial, LCD, Serial);
That connects stdin and stderr to serial, and stdout to LCD. The parameters are:
STDIO.open (stdin, stdout, stderr);
STDIO.close(); just releases any resources used by the standard IO paths (typically around 40 bytes).
It's all documented in the package, along with two demo programs.