Here are pieces of code I used to put menu into PROGMEM. I also put error messages, etc, there.
You need some #includes to use PROGMEM:
#include <avr/io.h>
#include <avr/pgmspace.h>
Here I have a 7 line menu (80 characters per line) stored to PROGMEM, and a special pointer to get the data with:
const char PROGMEM usageMsg[][80] = { // all this text stored in flash
" Piezo touch sensor tuner.",
"Adjust vertical; enter W to subtract or X to add, and a number 0-255",
"Adjust timescaler; enter A to subtract or D to add, and 0-16535",
"to add 250 to vertical enter W250 in Serial Monitor and press enter",
"seperate multiple commands with spaces; ex: W25 D240",
" ** this message stored in flash ram **",
" ** and printed with a 1 byte buffer ** :-P"
};
PGM_P Msg; // pointer into flash memory
The full program stores -every- const char string (not C++ String!) in PROGMEM. It has serial user I/O error messages, etc, as well as the menu.
I made this function to print the stored strings one char at a time:
void printMsg( PGM_P FM )
{
do
{
B = pgm_read_byte( FM++ ); // FM++ is pointer math; look Ma, no indexes!
if ( B ) Serial.print( B );
}
while ( B ); // when it reaches the terminating zero, it exits
}
And this function just to print the whole menu:
void printHelp(void)
{
for ( byte i = 0; i < HELPLINES; i++ )
{
printMsg( usageMsg[ i ]);
Serial.println();
}
Serial.println();
}