hemnath
Advanced Member level 3
Hi,
I have many menu sections which will display on LCD depending on the input parameter. Below is the sample.
Is this the efficient way of programming the menu structure? Or any other methods available to reduce the memory size and faster execution of program.
I have many menu sections which will display on LCD depending on the input parameter. Below is the sample.
Code:
void main_menu()
{
int i;
switch(i)
{
case 1: printf("text1");
break;
case 2: printf("text2");
break;
.
.
.
case 5: printf("text5");
break;
}
if(i == 1)
// do some action
else if (i == 2)
// do someother action
.
.
.
}
void sub_menu()
{
int i;
switch(i)
{
case 1: printf("text1");
break;
case 2: printf("text2");
break;
.
.
.
case 5: printf("text5");
break;
}
if(i == 1)
// do some action
else if (i == 2)
// do someother action
.
.
.
}
void sub_menu1()
{
.
.
.
}
// submenus goes on
Is this the efficient way of programming the menu structure? Or any other methods available to reduce the memory size and faster execution of program.