I am developing in Arduino, some menus to get them on the screen. I declare the menus as tables of text strings defined in Program space as in the example. How can I pass the pointer Menu_Principal as a parameter to a function?
Thank you all very much in advance.
const char _str_opcion_0[] PROGMEM = "Opción Menú 1";
const char _str_opcion_1[] PROGMEM = "Opción Menú -2";
const char _str_opcion_2[] PROGMEM = "Opción Menú --3";
const char _str_opcion_3[] PROGMEM = "Opción Menú ---4";
const char _str_opcion_4[] PROGMEM = "Opción Menú ----5";
const char _str_opcion_5[] PROGMEM = "Opción Menú -----6";
const char _str_opcion_6[] PROGMEM = "Opción Menú ------7";
const char _str_opcion_7[] PROGMEM = "Opción Menú -------8";
const char _str_opcion_8[] PROGMEM = "Opción Menú --------9";
const char _str_opcion_9[] PROGMEM = "Opción Menú ---------A";
const char _str_opcion_A[] PROGMEM = "Opción Menú ----------B";
const char _str_opcion_B[] PROGMEM = "Opción Menú -----------C";
char* const Menu_Principal [] PROGMEM =
{
_str_opcion_0, _str_opcion_1, _str_opcion_2, _str_opcion_3, _str_opcion_4, _str_opcion_5,
_str_opcion_6, _str_opcion_7, _str_opcion_8, _str_opcion_9, _str_opcion_A, _str_opcion_B,
NULL
};
You can pass a pointer to a function just like the usual way you do, but you can't just use it without copying the content from the flash to memory first.
BTW,
PGM_Pis just a macro defined by avrlib forconst char*.