I'm using MPLAB X IDE with XC8 compiler and I would like to create a menu system to a GLCD module, but I'm having trouble initializing my MainMenuItemsList[]
array. I'm not getting error on compliling but if I'm debugging the project, I can see that only the first item is initialized. What can be the cause?
Here is the relevant code fragment:
typedef struct menuitem
{
char ItemName[10];
void (*handler)(void);
struct menu *ChildSubMenu;
}MenuItem;
typedef struct menu
{
char MenuName[10];
char NumberItems;
//struct menu *ParentMenu;
MenuItem *Items[12];
}Menu;
MenuItem MainMenuItemsList[12] = { {"SubMenu1", NULL, NULL},
{"SubMenu2", NULL, NULL},
{"SubMenu3", NULL, NULL},
{"SubMenu4", NULL, NULL},
{"SubMenu5", NULL, NULL},
{"SubMenu6", NULL, NULL},
{"SubMenu7", NULL, NULL},
{"SubMenu8", NULL, NULL},
{"SubMenu9", NULL, NULL},
{"SubMenu10", NULL, NULL},
{"SubMenu11", NULL, NULL},
{"SubMenu11", NULL, NULL}
};
Menu MainMenu = {"MainMenu",12,&MainMenuItemsList};
void drawMenu(Menu *menuToShow, unsigned char selectedIndex) { ... glcd_puts(menuToShow->Items[i]->ItemName,8,i+1,0,1,-2); ... }
And the call of the function:drawMenu(&MainMenu, 0);
Sorry but I don't know how to format the code block properly, but I tried it for several times. \$\endgroup\$