Reply by murp...@yahoo.com March 6, 20082008-03-06
On Mar 4, 5:48 am, Dave Hansen <i...@hotmail.com> wrote:
> On Mar 2, 11:34 am, "murphy...@yahoo.com" <murphy...@yahoo.com> wrote: > > > > > Hi > > > I want to have menus (with sub menus and so on) on aLCD(graphicsLCD > > and I can have about > > 4 lines on it) of anembeddedsystem. I am programming in C (MPLAB C18 > > does not > > support C++). Thesystemhas three keys, UP, DOWN and ENTER. I have > > searched a > > lot on the internet for data structures and methods for such > > applications. I have found that lot of > > people say pointer to functions can make life really simple in such > >menudriven > > systems. > > > Can any one share an small example (in C) from which I can take over. > > I would like to > > have following things in themenucode: > > 1. Menus can be easily added or removed without having to change lot > > of code. > > The book "Front Panel" by Niall Murphy is useful. A bit dated, but > the concepts are solid. > > It covers a bit more than simple data-driven menus, however. > > Regards, > > -=Dave
Hi Thanks a million for the very useful hints. Let us consider a practical example: Main Menu: 1.Setup 2.Options 3.Exit Setup Sub Menu: 1.Setup_1 2.Setup_2 3.Exit Functions to be called for first two options: fnSetup_1(), fnSetup_1() Options Sub Menu: 1.Option_1 2.Option_2 3.Exit Function to be called for options menau: fnOptions_1(), fcOptions_2() 1. First we have to define data structures for menus. They should have a string to be displayed and information about how many items are there in that menu(this will be used by the Display function that displayes the menu items on LCD when ever there is change). Next comes the function to be called. We must have a variable to show which item is currently selected. Any other thing? The data structures should be such that if we want to remove a particular menu item, it should be accomplished with little code change. 2. Initalise the Menu structure variables with strings, data etc. 3. Make a function (DisplayMenu) to display menu items when ever the LCD is to be updated, say after a option is selected. It should be able to print the Current menu item in Inverse video/or some indication of "current selection". 4. A switch statement to process the key events (UP, DOWN and ENTER). It will change the current selection depending upton the key pressed. Then the LCD should be updated. Suggestions for code for above things are welcome. Thanking you in advance With Best regards M
Reply by Dave Hansen March 3, 20082008-03-03
On Mar 2, 11:34 am, "murphy...@yahoo.com" <murphy...@yahoo.com> wrote:
> Hi > > I want to have menus (with sub menus and so on) on a LCD (graphics LCD > and I can have about > 4 lines on it) of an embedded system. I am programming in C (MPLAB C18 > does not > support C++). The system has three keys, UP, DOWN and ENTER. I have > searched a > lot on the internet for data structures and methods for such > applications. I have found that lot of > people say pointer to functions can make life really simple in such > menu driven > systems. > > Can any one share an small example (in C) from which I can take over. > I would like to > have following things in the menu code: > 1. Menus can be easily added or removed without having to change lot > of code. >
The book "Front Panel" by Niall Murphy is useful. A bit dated, but the concepts are solid. It covers a bit more than simple data-driven menus, however. Regards, -=Dave
Reply by Andrew Smallshaw March 3, 20082008-03-03
On 2008-03-03, rickman <gnuarm@gmail.com> wrote:
> > A menu interface can be very simple. But with only four lines on your > screeen (you don't say how wide) your menus will be rather short and > as a result they may have to be deep. Deep menus are confusing for a > user. I wrote a program for a Luminary Micro eval board which had a > graphic display with only two lines max. I wrote my code to treat the > OLED display as a window over a larger menu or other display. It also > had a thumbwheel for scrolling, which you will have to use buttons > for. A wheel was great for this as it gave quick response in a way > that would become very comfortable. I have never seen a menu system > with up/down push buttons that was nice to use. Regardless, my point > is that you might want to consider using menus with more than four > entries if you application is at all complex. This is much preferred > to having four or more levels of menus which will tend to confuse an > operator.
Scrolling down the screen isn't really a problem in a well designed menu. Sure it means that you don't have the same level of visual cues available instantly but you can soon fix that tby scrolling up and down a bit. Most embedded apps are far simpler than hosted apps so there shouldn't be that much of a problem at any rate. However, one addition that your users will really appreciate in this circumstance is an 'up' or 'back' button to move up the menu hierarchy - selecting menu options to do this is annoyingly clumbersome and the sheer effort of getting out may result in a user not bothering to go into that menu in the first instance. One example that comes to mind to me from a user persepctive is the Meade Autostar telescope controller. You can find a full description of this, including the menu layout at http://www.meade.com/lxd75/lxd75.pdf if you are interested. That only has a two line display and a relatively complex menu structure but it is very simple to use in practice, and this is one area where the user is possibly justified in not wanting to refer to the manual (to avoid loss of night vision). I think the key there is having buttons available - arrow keys laid out in an intuitive cross, a dedicated "mode" key that goes back to the previous menu, and a numeric keypad for, well, numeric entry instead of attempting to force that into a menu layout. To return to the OP's original question, which was more about code, I don't have any to hand but it doesn't need to be difficult. Begin with something along the lines of: typedef struct { char *menuLabel; void (*action)(void); } MenuItem; For each menu, create a null temrinated MenuItem array. Move back and forth about the array (and menu) with a simple index. When selected, execute menu[i].action(), or whatever you have called your menu and index. I would flesh this out a little more but am in a hurry to get off, post back if you need further hints. -- Andrew Smallshaw andrews@sdf.lonestar.org
Reply by antedeluvian51 March 3, 20082008-03-03
>I wrote an article on this very topic. Although it was based around the >Rabbit micro, it is coded in C and the concepts should not prove every >difficult to port. It appeared in the Nov 2003 issue of Circuit Cellar >(issue 160) > >http://www.circuitcellar.com/magazine/160toc.htm > >entitled >"Hierarchical Menus in Embedded Systems". CC's model is to charge a >nominal amount for the article, however the code is available for free
at
>the ftp site >ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2003/160/ > >-Aubrey Kagan > >
You can find some of the preliminary discussion that led to the article here http://archive.chipcenter.com/eexpert/rashby/rashby054.html and here http://archive.chipcenter.com/eexpert/rashby/rashby056.html -Aubrey
Reply by Not Really Me March 3, 20082008-03-03
"Rich Webb" <bbew.ar@mapson.nozirev.ten> wrote in message 
news:se4os31edtmkdja90tjj8qhfqco9upeeaa@4ax.com...
> On Mon, 3 Mar 2008 05:43:08 -0800 (PST), rickman <gnuarm@gmail.com> > wrote: > >>On Mar 2, 12:34 pm, "murphy...@yahoo.com" <murphy...@yahoo.com> wrote: >>> Hi >>> >>> I want to have menus (with sub menus and so on) on a LCD (graphics LCD >>> and I can have about >>> 4 lines on it) of an embedded system. I am programming in C (MPLAB C18 >>> does not >>> support C++). The system has three keys, UP, DOWN and ENTER. I have >>> searched a >>> lot on the internet for data structures and methods for such >>> applications. I have found that lot of >>> people say pointer to functions can make life really simple in such >>> menu driven >>> systems. >>> >>> Can any one share an small example (in C) from which I can take over. >>> I would like to >>> have following things in the menu code: >>> 1. Menus can be easily added or removed without having to change lot >>> of code. >> >>A menu interface can be very simple. But with only four lines on your >>screeen (you don't say how wide) your menus will be rather short and >>as a result they may have to be deep. > > Depends a bit on whether the OP's display is a 4x16 or a 4x20 (or > larger, but the 4x20 is pretty common) but he could use two columns > for the menus, giving him items 1-7 plus a Back or Quit entry. > > Yeah, they'll be terse but we've gotten pretty well trained for that > with the legends on things like consumer remote controls. > > Err, controls for consumer electronics, not controls for consumers. > > -- > Rich Webb Norfolk, VA
Many years ago (back when I was a young dinosaur) we did a menu with a 2 x 40 LCD. Top line was status/data, bottom line was commands. Left, right and enter keys only. When a highlighted command was "entered", the line changed to the relevant subcommands. This can go on as deep as you want. Each line had a "back" or "done", possibly both. Orginal idea was borrowed from an HP development box in the early 80's. They had a full CRT, but the menu was on the bottom line, and there was a keyboard key directly under each of the menu items. Press a key, the menu line changed. Scott
Reply by Rich Webb March 3, 20082008-03-03
On Mon, 3 Mar 2008 05:43:08 -0800 (PST), rickman <gnuarm@gmail.com>
wrote:

>On Mar 2, 12:34 pm, "murphy...@yahoo.com" <murphy...@yahoo.com> wrote: >> Hi >> >> I want to have menus (with sub menus and so on) on a LCD (graphics LCD >> and I can have about >> 4 lines on it) of an embedded system. I am programming in C (MPLAB C18 >> does not >> support C++). The system has three keys, UP, DOWN and ENTER. I have >> searched a >> lot on the internet for data structures and methods for such >> applications. I have found that lot of >> people say pointer to functions can make life really simple in such >> menu driven >> systems. >> >> Can any one share an small example (in C) from which I can take over. >> I would like to >> have following things in the menu code: >> 1. Menus can be easily added or removed without having to change lot >> of code. > >A menu interface can be very simple. But with only four lines on your >screeen (you don't say how wide) your menus will be rather short and >as a result they may have to be deep.
Depends a bit on whether the OP's display is a 4x16 or a 4x20 (or larger, but the 4x20 is pretty common) but he could use two columns for the menus, giving him items 1-7 plus a Back or Quit entry. Yeah, they'll be terse but we've gotten pretty well trained for that with the legends on things like consumer remote controls. Err, controls for consumer electronics, not controls for consumers. -- Rich Webb Norfolk, VA
Reply by antedeluvian51 March 3, 20082008-03-03
>Hi > >I want to have menus (with sub menus and so on) on a LCD (graphics LCD >and I can have about >4 lines on it) of an embedded system. I am programming in C (MPLAB C18 >does not >support C++). The system has three keys, UP, DOWN and ENTER. I have >searched a >lot on the internet for data structures and methods for such >applications. I have found that lot of >people say pointer to functions can make life really simple in such >menu driven >systems. >
I wrote an article on this very topic. Although it was based around the Rabbit micro, it is coded in C and the concepts should not prove every difficult to port. It appeared in the Nov 2003 issue of Circuit Cellar (issue 160) http://www.circuitcellar.com/magazine/160toc.htm entitled "Hierarchical Menus in Embedded Systems". CC's model is to charge a nominal amount for the article, however the code is available for free at the ftp site ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2003/160/ -Aubrey Kagan
Reply by rickman March 3, 20082008-03-03
On Mar 2, 12:34 pm, "murphy...@yahoo.com" <murphy...@yahoo.com> wrote:
> Hi > > I want to have menus (with sub menus and so on) on a LCD (graphics LCD > and I can have about > 4 lines on it) of an embedded system. I am programming in C (MPLAB C18 > does not > support C++). The system has three keys, UP, DOWN and ENTER. I have > searched a > lot on the internet for data structures and methods for such > applications. I have found that lot of > people say pointer to functions can make life really simple in such > menu driven > systems. > > Can any one share an small example (in C) from which I can take over. > I would like to > have following things in the menu code: > 1. Menus can be easily added or removed without having to change lot > of code.
A menu interface can be very simple. But with only four lines on your screeen (you don't say how wide) your menus will be rather short and as a result they may have to be deep. Deep menus are confusing for a user. I wrote a program for a Luminary Micro eval board which had a graphic display with only two lines max. I wrote my code to treat the OLED display as a window over a larger menu or other display. It also had a thumbwheel for scrolling, which you will have to use buttons for. A wheel was great for this as it gave quick response in a way that would become very comfortable. I have never seen a menu system with up/down push buttons that was nice to use. Regardless, my point is that you might want to consider using menus with more than four entries if you application is at all complex. This is much preferred to having four or more levels of menus which will tend to confuse an operator.
Reply by Mike Silva March 3, 20082008-03-03
On Mar 2, 11:27=A0pm, Gene S. Berkowitz <first.l...@verizon.net> wrote:
> In article <qKCyj.17409$0w.10...@newssvr27.news.prodigy.net>, > msh...@msn.biz says... > > > You'll need a menu/esc key too. > > Without one, you can't navigate. > > Sure you can; you just need to make "Exit" or "Done" a choice in each > menu... > > --Gene
And "Back".
Reply by Gene S. Berkowitz March 3, 20082008-03-03
In article <qKCyj.17409$0w.10804@newssvr27.news.prodigy.net>, 
mshine@msn.biz says...

> You'll need a menu/esc key too. > Without one, you can't navigate.
Sure you can; you just need to make "Exit" or "Done" a choice in each menu... --Gene