PDA

View Full Version : LCD menu



Fredrick
- 2nd February 2009, 01:34
I have 3 buttons and a 2x16 LCD and want to have an LCD menu and navigate with the 3 buttons.
I want to use 2 of the buttons for UPP/DOWN in the menu and the last one for Enter.

How do I do that in a smart way.

I could use a lot of IF THEN ELSE with some GOTOīs but i donīt feel that its the right way to do it.

So help me, how should I build the code.

Archangel
- 5th February 2009, 06:51
So help me, how should I build the code.

You could use Select case, you might even get 7 or 8 states out of those 3 switches.

Ioannis
- 5th February 2009, 08:40
Whatever you do If-Then will be there....

I don't like it either but don't see doing it other way.

Ioannis


P.S. I do it once with only 2 buttons as i lack the 3rd one. Very awkard...

Melanie
- 5th February 2009, 10:02
Yes, there is always another way...

One of my products (on an 18F2420) has a 5 level Menu structure, that is 170 items deep! With 3 Button Control and an LCD. It is on a product which sells 1000/month and which competitors can't figure how it's done! So I won't give you the code, because it'll hand them the secret (and I know they read this forum)... but I will generalise...

The Menu consists of a 8 Byte Table per line... the Table is held in program codespace (see elsewhere on this forum how to do that).

Byte 1 tell the Menu Subroutine what kind of Data Element we are dealing with... ie, Numeric, Numeric with Fixed Decimals, Alphanumeric, Date, Time etc.

Byte 2 is the Data Element Byte Length.

Byte 3 is the Minimum permitted value for any Numeric entry.

Byte 4 is the Maximum permitted value for any Numeric entry.

Byte 5 are Flags... these are Bits that Control frills, eg Cursor ON/OFF, Visible or Invisible Entry (like that required for Passwords) , whether Data-Entry is permitted or not, etc etc

Byte 6 points to the location in EEPROM where the first Byte of Data is to be found.

Byte 7 points to the Message in Program Codespace which will appear on your LCD prompting your Data-Entry (eg "Enter Time Delay").

Byte 8 points to a secondarry Message in Program Codespace for additional information (eg "Minutes").

The Menu Subroutine, sequentially reads the eight control bytes and acts on it accordingly. Once you have built your subroutine, it's a simple matter of adding just eight bytes (plus prompting messages) per Menu item. It's small, it's compact, and everything you need to learn how to do it is on this forum somewhere (though not in a ready cut & paste form). Clue: It does rely very heavilly on reading large Tables of Data from Program Codespace and manipulating Alphanumeric STRINGS (for all the LCD Messages) with PBP. Sort out how to do that first, and the rest is simple!

Ioannis
- 9th February 2009, 09:02
Nice one Mel. I suppose that this part is one ofthe memory hungry ones.

Ioannis