I have a 4x20 LCD that I am trying to get a menu to display.
This is what I have so far
On my header file
C:
typedef enum
{
UIModesSetting,
Time,
Pump,
Solar,
Waterfall,
Clean
}MainModes;
On my source file
C:
void UIModeSet(void)
{
switch(UIModesSetting)
{
case Time:
{
UITimerSet();
}
case Pump:
{
//UIPumpSet();
}
case Solar:
{
//UISolarSet();
}
case Waterfall:
{
}
case Clean:
{
}
} /*end of shift()*/
}
I have four buttons as inputs : Mode, Up, Down, Enter. What I am trying to do is when I push the mode button the main menu will be displayed then scroll up or down with the corresponding button push then display the sub-menu when enter button is pushed .
P.S How do I get code to display as code and not text when posting?
I just type in the HTML tags...
Change to "code=asm " if you are using asm..
Menu control is quite easy.. What I do is cycle through a menu and once the correct item has been selected then enter the function. I only use two lines and scroll through the menuitems one by one..
Ian Rogers what is the propose of the "[5][10]"? I know that they are for array length, but why the 5 & 10?
It did compile with no errors now I just need to work on the up-down scroll.
do
{
scroll2 = scroll + 1;
sprintf(buff, "%s", DisplayText[scroll]);
LineOne; //goto display address
putsXLCD(buff);
sprintf(buff, "%s", DisplayText[scroll2]);
LineTwo; //goto display address
while(BusyXLCD());
putsXLCD(buff);
if (ButtonStatus.Up == On && ButtonStatus.Pushed == Off)
{
ButtonStatus.Pushed = On;
scroll++;
if (scroll >= 5) scroll = 0;
else if (scroll2 >= 5) scroll2 = 0;
}
else if (ButtonStatus.Down == On && ButtonStatus.Pushed == Off)
{
ButtonStatus.Pushed = On;
scroll--;
if (scroll < 0)scroll = 4;
else if (scroll2 < 0)scroll2 = 4;
}
else if (ButtonStatus.Enter == On && ButtonStatus.Pushed == Off)
{
MainModes(UIModesSetting) = DisplayText[scroll];
ButtonStatus.Pushed = On;
UIModeSet();
}
}
while(ButtonStatus.Mode != On && ButtonStatus.Pushed == Off);
Using the enum list that I posted in #1 as the main menu, how do I point to sub-menus for instance from "Timer" I have a menu that has "Timer1 - 8" to set and use 8 different timers?
When I set up my menu... Like I said I scroll though one at a time... When the user presses the "MENU" key the menu is invoked.
The top line displays the menulevel and the bottom the menuitem.. I have five main menu items, the fifth is the "exit" menuitem, the fourth is a sub menuitem that takes me to a calibration menu..
When I press "MENU" I cycle though each menuitem.. If I press "ENTER" then that menuitem is selected, and a new menulevel may be started. Sometimes there is only one setting per menuitem and other times, many!
The neatest way is to coincide the menuitems with data structures so each menuitem is enumerated to the data structure. This way when you work on a menuitem, the data is automatically selected and each menuitem is like a similar object. I group menu's together that hold very similar functions.
Once you have the basic menu system working as an individual object, it's easier to change viewing device..
I am porting my menusystem to a graphical display and keeping the same "menu feel" which should help my customers when using the new interface.
The neatest way is to coincide the menuitems with data structures so each menuitem is enumerated to the data structure. This way when you work on a menuitem, the data is automatically selected and each menuitem is like a similar object. I group menu's together that hold very similar functions.
In post #7 you showed me how to display the menu using an enumerated list. I have an enum list and a switch statment for all the sub-menu list item, I am just unsure how to move to display the list items from the selection on the main menu. For instance if I select "Time" I want to move to the timer menu. Ian Rogers can you help me with this?
display menu text
setup menu variables
while( forever)
get a key
if key = x do this
if key = y do this
if key = z do this
if key = enter
if menuitem = a do this
if menuitem = b do this
if menuitem = c do this
if menuitem = d call menu2
display text[menuitem]
All my text is kept in an external flash chip and I read the entire screen and the display.
I have written text fetching routines... a,b and c will have associate cal data structures so storage is simple
To raise a sub menu it will be a menu item which will call... say "menu2" and then once done it will return here..