We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi you all. I need to creat an LCD based user interface. Therefore , I decided to use a struct for each LCD menu:
typedef struct Menu { char lcd_first_line[16]; char lcd_second_line[16]; struct Menu * child_pointer; float menu_number; // pointer to run function }MenuItem;
MenuItem xdata main_menu[5];
Do you need to locate this at a specific address? If not, it's just straight 'C' initialisation - see K&R!
That is, like this:
typedef struct Menu { char lcd_first_line[16]; char lcd_second_line[16]; struct Menu * child_pointer; float menu_number; // pointer to run function }MenuItem; MenuItem xdata main_menu[5] = { { "menu", "00000", &main_menu[1], 3.0 }, { "menu", "11111", &main_menu[2], 3.0 }, { "menu", "22222", &main_menu[3], 3.0 }, { "menu", "33333", &main_menu[4], 3.0 }, { "menu", "44444", &main_menu[0], 3.0 }, };
If you want the data to reside in the code space, then make the declaration const MenuItem code main_menu[5] = If you want the data to reside in xdata, then you'll need to be sure your startup code executes the code in INIT.A51 to actually copy the initializer values from ROM to the xdata RAM.