EmbeddedRelated.com
Forums

Menus on LCD for embedded systems

Started by murp...@yahoo.com March 2, 2008
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.

Thanking you an advance.
M
On Sun, 2 Mar 2008 09:34:11 -0800 (PST), "murphy001@yahoo.com"
<murphy001@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.
An ordinary state machine is often all that's needed. The arrow keys move an indicator up or down among the selections. When ENTER is pressed, change the state variable and set a flag that a new state has been entered. When you loop back to re-enter the state machine at the new state, draw the new screen and reset the flag, then handle the key presses. -- Rich Webb Norfolk, VA
You'll need a menu/esc key too.
Without one, you can't navigate.

Look into using arrays to pointers of functions.
Its easy to associate a menu selection with an index to function you want to 
execute.

<murphy001@yahoo.com> wrote in message 
news:eba2190a-450a-4af9-8e2d-f3c0799f85fa@s37g2000prg.googlegroups.com...
> 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. > > Thanking you an advance. > M
On Sun, 02 Mar 2008 18:55:18 GMT, in comp.arch.embedded "Moon Shine"
<mshine@msn.biz> wrote:

>You'll need a menu/esc key too. >Without one, you can't navigate. > >Look into using arrays to pointers of functions. >Its easy to associate a menu selection with an index to function you want to >execute. > ><murphy001@yahoo.com> wrote in message >news:eba2190a-450a-4af9-8e2d-f3c0799f85fa@s37g2000prg.googlegroups.com... >> 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. >> >> Thanking you an advance. >> M >
http://www.thescripts.com/forum/thread212571.html and something i found, i can't remember where from I stuck here http://es.geocities.com/mart_in_medina/AVRButterfly_application_rev07.zip could be from avrfreaks martin
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
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".
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.
>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
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
"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