Ok, so i managed to get "pgm_read_byte_near" and "pgm_read_word_near" working fine.
But, i still have problems when reading a prog_uchar[30] defined.
When i try to read it, it shows crazy characters and won't stop. (i'm using serial.print for my tests ...)
For now, i use this code :
MY TABLE with its struct initialization
struct STRUCT_MENU {
byte STRUCT_MENU_MENU_LEVEL;
byte STRUCT_MENU_MENU_REF;
byte STRUCT_MENU_SUBMENU_LEVEL;
prog_uchar STRUCT_MENU_MENU_TEXT[20];
boolean STRUCT_MENU_EXECUTABLE;
byte STRUCT_MENU_VALUE_TYPE;
int STRUCT_MENU_VALUE;
};
const STRUCT_MENU LCD_MENU_TREE [] PROGMEM = {
// MAIN MENU TEXT
{0, 1, 1, "Main Menu", false, 0, 0},
// 1st LEVEL MENUs
{1, 1, 11, "Configuration", false, 0, 0},
{1, 2, 12, "Tests", false, 0, 0},
{1, 3, 0, "About ...", true, 0, 101},
// 2nd LEVEL MENUs
{11, 1, 0, "Mode AUTO", false, 0, 1101},
{11, 2, 22, "Conditions", false, 0, 0},
{11, 3, 23, "System", false, 0, 0},
{12, 1, 0, "Light", true, 0, 1201},
{12, 2, 0, "Fans", true, 0, 1202},
{12, 3, 0, "CO2 valve", true, 0, 1203},
The code i'm using for reading /&&/ printing values from my table :
for (int i = 0; i < 21; i++) {
int BYTE_TEMP = pgm_read_word_near(&LCD_MENU_TREE[i].STRUCT_MENU_VALUE);
Serial.print("BYTE (");
Serial.print(i);
Serial.print(") - VALUE : ");
Serial.print(BYTE_TEMP);
Serial.print(" - TEXT : ");
char buffer[30];
strcpy_P(buffer, (char*)pgm_read_word(&(LCD_MENU_TREE[i].STRUCT_MENU_MENU_TEXT)));
Serial.println(buffer);
}
The outputs looks like this :
-> READ : TABLE from FLASH
BYTE (0) - VALUE : 0 - TEXT : g·ñøÏúô»ô`ÿoOOOÀ#ðéÀw#!ðè/v/Àf#qðè/pà`à*ðfwÚ÷ù
BYTE (1) - VALUE : 0 - TEXT : :
BYTE (2) - VALUE : 0 - TEXT : UT : DISABLED
BYTE (3) - VALUE : 101 - TEXT : ð_?qðGûað?yUòÏFñÀñÏè»'f'w'Ëôï
ÐÀϱßSSSSSSSSSSSSSSSSSSSSSSSS<ETC ETC ETC ......................................>
It seems that some code from a previous program i had flashed a while ago is showing on the output !!!
I must have some kind of problems while reading the value.
Perhaps the "strcpy_P" function needs to be changed by another one ?
Thanks for your help !