The menu array is a type MENU. MENU type is declare in the InvIoT_U1.h file.
With an array you can declares the choices of your menus and what function it will run.
Here is an example of a single row menu array:
MENU menuOptions[]={
{0," M e n u ",'t',0,0},
{0,"Print Hello",'f',helloWorld,0},
{0,"Turn Led Red ",'f',turnLedRed,0},
{0,"Turn Led Green ",'f',turnLedGreen,0},
{0,"Turn Led Off",'f',turnLedOff,0},
{255,"",' ',0},
};
SYNTAX
It looks complicated, but its not! After looking few examples it gets easy. But I still have to explain here all the syntax details for building menus.
Every item of the array contains:
<byte>,<String>,<char>,<Fuction name>,<byte>
<byte> Menu Group.
The root menu starts with 0.
255 declares the end of the menu array.
If there are submenus, this will be the sub menu group number.
<String> Text String
This is going to be printed on LCD.
<char> Menu Type
't' char declares Menu Title. This will be on top of the screen, not choosable, and is the Title of this menu group.
'f' char declares a Menu Function. This will be one of the choices you will have to choce from.
'm' char declares that is going to a Sub Menu. An arrow will be printed on LCD at the end of this line, to declare that there is a Sub Menu going to.
<Function Name> The function to run if you make that choice.
If this is for Menu Title ('t' char on previous field), enter 0.
If this is for Sub Menu choice ('m' char on previous field), enter 0.
If this is for Menu Function ('f' char on previous field), enter the name of the function to run when you make this choice.
<Byte> Return To.
If this is a Menu Title ('t' char) for a SubMenus, enter the Menu Group to return to when pressing the Cancel button.
If this is a single row menu (no submenus), enter 0 on this field so it will return to root menu.
If this is a submenu Title, enter the Menu Group you will like to go back to, when you press the Cancel button. Cancel button is on the right bottom corner of the InvIoT_U1 module.
If this is a Menu Function ('f' char), enter the Menu Group to return to, when exiting the function.
And finaly, if you exit a function and you want to return to the Screen Saver, and not to the menu, enter 255. This will be explain later in the ScreenSaver section