Making a MENU for a LCD

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi i have a 20x4 LCD and know how to control it. But i would like to build a menu in it.
Like it starts with 4 options if you choose option 1
you get submenu 1 and so on.

Do there exist libraries for this ? or does somebody has some rough example code...

thanx

Chris

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If when using the display/menu that is all you are interested in then you can fall down through the menu structure using switch statements at each option choice. Any background tasks could be called as functions when the switches are being scanned.

Do refrain from the temptation to use a fixed delay routine just to hang about if waiting for an action. Use one of the timers to enable a loop in which background tasks can be excercised.

Keep it simple it will not bite as hard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have a look at Tiny Menu

http://www.avrfreaks.net/index.p...

Might give some ideas

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanx for the replys

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did it in that way:

I have a structure for every menu point.
This structure contains the menu point text and it's coordinates (where it should be on the lcd).
Furthermore it contains information what should happen, if one of the buttons is pressed. For every button one control information. Either just jump to another state (menu entry) or call a function (via function array, so you can use ordinary number values and a flag to either jump to a state (via state array) or a function via function number).
The big advantage of this system is that you write once the interpreter and the whole menu structure is controlled via structures!
Furthermore it's great to debug and to test!
e.g. you are at state "1" and you would like to jump to state "6" if you press button up! The only thing to do is: link the "button up" info for state "1" to state "6" ... finished -> no code change

It's also great to build a dynamic menu which depends e.g. from uart input.

Just copy e.g. state "10" to ram, create a new state in ram and link state "10" to the new one.
The only two additional things for this mechanism is a table which signalizes if a state is in (eep)rom or RAM (for the state 10) and a ram part of the state reference table.

May be it's useful for you!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bingo600 wrote:
Have a look at Tiny Menu http://www.avrfreaks.net/index.p... Might give some ideas /Bingo

hi

thank u....but can i help me....i can not used source code ....please can help me...i want creat menu lcd 16*2 and atmega and 2 button ...

thankkkkkk

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
i can not used source code

What do you mean by that??

 

please can help me

It's not clear what your problem is

 

 

i want create menu lcd 16*2 and atmega and 2 button

http://www.lmgtfy.com?q=menu+LCD+16x2+ATmega

 

Note that the techniques for doing a menu on an LCD do not depend on what microcontroller you use - the same principles apply whether you use an 8051 or a PIC or whatever ...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:

and 2 button ...

 

Doing a menu with just two buttons is quite a challenge if the menu is anything but simple.

 

Have you drawn out a flow-chart to show how it will work?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
i can not used source code ...

That is indeed one of the more curious "clarifications" I have ever seen.

 

Usually, we ask fir AVR model and clock speed to start with.  I guess we know "atmega" and a character LCD, but no idea how connected.

 

The next questions are language, toolchain, and version.

 

:0A0000001AC0FECFFDCFFCCFFBCFEE
:10000A00FACFF9CF99C2F7CFF6CFF5CFF4CFF3CF26
:10001A00F2CFF1CFF0CFEFCFEECFEDCFECCFEBCFEA
:10002A00EACFE9CFE8CFE7CFE6CF0000F894EE2792
:10003A00EFBBE5BFF8E1A895A4B7A77FA4BFF093EB
:10004A006000E09360008DE0A2E0BB27ED938A9503
:10005A00E9F780E092E0A0E0B1E0ED930197E9F7DB
:10006A00E4E3F0E085919591009761F0A591B5914F
:10007A0005901590BF01F00105900D920197E1F7E7
:10008A00FB01F0CFE0E0EEBBE0E0EABDE0E0EBBD73
:10009A00EFEFEDBFE2E0EEBFC0E8D1E000C0E0E87C
:1000AA00E0936100E0E0E0936100E4B7E0FD04C0A2
:1000BA00E4B7E1FD01C0E4B7E0E0E4BFE0E8E093C3
:1000CA006100E0E0E0936100E5B9E4B9E8B9E7B9B5
:1000DA00EBB9EAB9E4BDE5BDE6BDE7BDE8BDE0932D
:1000EA008000E0938100E0938500E0938400E09330
:1000FA008700E0938600E0938900E0938800E0930C
:10010A008B00E0938A00E093B600E093B000E0939E
:10011A00B100E093B200E093B300E093B400E0933F
:10012A006900EDBBE0936800E0936E00E0936F0016
:10013A00E0937000E0E8E0BFE0E0E0937B00E0E2FB
:10014A00E5B9EFE1E4B9E0E0E8B9EFE3E7B9E4E003
:10015A00EBB9EAEFEAB9E0E0E4BDE5BDE6BDE7BD2B
:10016A00E8BDE0938000E0938100E0938500E0938E
:10017A008400E0938700E0938600E0938900E0938F
:10018A008800E0938B00E0938A00E093B600E2E0F7
:10019A00E093B000E7E0E093B100E0E0E093B20062
:1001AA00E3E2E093B300E0E0E093B400E093690097
:1001BA00EDBBE0936800E0936E00E0936F00E2E02D
:1001CA00E0937000E0E8E0BFE0E0E0937B00EBE75B
:1001DA00F0E0FA93EA93B2D1A895EAE1E0936000DD
:1001EA00EAE0E0936000A895789440E04424A8955A
:1001FA00F298F198F09B90C0F098F19AE091800102
:10020A00EF5FE0938001A0918001A23378F0E0E0F3
:10021A00E0938001F29AE0918101EF5FE09381011E
:10022A00E894F39B6894AEB3A3F9AEBBA0918201A4
:10023A00B09183018091840190918501F5D1A4F454
:10024A00E0918201F09183016091840170918501AE
:10025A00319760407040E0938201F093830160938C
:10026A0084017093850109C0E0E0E0938201E09384
:10027A008301E0938401E0938501A0918601B09106
:10028A0087018091880190918901CED1A4F4E091EF
:10029A008601F091870160918801709189013197F7
:1002AA0060407040E0938601F09387016093880173
:1002BA007093890109C0E0E0E0938601E093870129
:1002CA00E0938801E0938901E091A901E093AA01F2
:1002DA002BD10E2F0A93EDE9F1E0FA93EA93D5D0E8
:1002EA00E093A901E091AA01A091A901EA27EA23D2
:1002FA00E093AB01E091AA01EA27A091AA01EA23BF
:10030A00E093AC010BD10E2F0A93E2E9F1E0FA93E4
:10031A00EA93BBD0E093A801E0E0F199E1E0A09173
:10032A00AC01EA2301F1E091AC01E27061F0E091E5
:10033A00A801F0E0A2E0B0E05DD1E0E0E093800146
:10034A00F39AF2984424E091AC01E47061F0E091F0
:10035A00A801F0E0A4E0B0E04DD1E0E0E093800134
:10036A00F39AF2984424E42DE03081F54198F19B08
:10037A0005C0A0918001A0E0A03009F001C0329A26
:10038A00E0E0F299E1E0AE2FE0E0F399E1E0EA2360
:10039A00E1F0A2E0B0E01FD166277727A4E6B0E03B
:1003AA0080E090E000D1E0938A01F0938B016093A2
:1003BA008C0170938D01E0938201F0938301609325
:1003CA00840170938501E1E04E2E5DC0E13049F56C
:1003DA00419A4298E0918201F091830160918401EF
:1003EA00709185011DD1E1F4A4E0B0E0F4D0662754
:1003FA007727A0E7B7E180E090E0D5D0E0938E01BF
:10040A00F0938F016093900170939101E0938601BC
:10041A00F09387016093880170938901E2E04E2E80
:10042A0032C0E23079F54198F29B05C0F39B02C0D5
:10043A00429801C0429AE0918601F0918701609149
:10044A00880170918901ECD0E1F4A2E0B0E0C3D058
:10045A0066277727A4E6B0E080E090E0A4D0E09396
:10046A008A01F0938B0160938C0170938D01E09364
:10047A008201F09383016093840170938501E1E026
:10048A004E2E01C04424B3CEFFCFD4D0AA81BB8163
:10049A0019960C9119E0113088F0E12FAA81BB81DD
:1004AA00F0E0EA0FFB1F0F01E12FF0E0AE0FBF1FD4
:1004BA001197EC91D001EC931150EDCFEC81AA8108
:1004CA00BB81EC93BD010C90AA81BB811A96EC9179
:1004DA00E025DB01EC9310E01A3050F4E12FAA81F9
:1004EA00BB81F0E0AE0FBF1FEC910E231F5FF4CF6C
:1004FA0010E01B3060F4E12FAA81BB81F0E0EA0F23
:10050A00FB1FDF01EC91E027EC931F5FF2CFAA817A
:10051A00BB811A96EC9191D0259608950A93E9B178
:10052A00E0950E2FE02F06C00A93E3B1E095E6703E
:10053A000E2FE02F09910895F09A1895E991F991F3
:10054A00309639F08AE993E00197F1F7A895319747
:10055A00C9F70895E095F09560957095EF5FFF4FA4
:10056A006F4F7F4F08957A9F702D6B9F700DF89F84
:10057A00700DE99F700D6A9F602D710DFB9F600DD4
:10058A00711DE89F600D711D8827FA9FF02D610D7E
:10059A00781FEB9FF00D611D781FEA9FE02DF10D8A
:1005AA00681F781F089504D0DEDF0EF4D3DF0895A4
:1005BA00E89477FF02C0CEDF689497FF0BC000244F
:1005CA00A095B095809590951196801D901D00F884
:1005DA00039400FA0895119602D0FE2F1197F99903
:1005EA00FECFFF93FFB7F894A1BDF89AE0B5FFBF1D
:1005FA00FF91089507D01196EF93EF2F03D0EF9153
:10060A0011970895F999FECF9FB7F894A1BDF89A6A
:10061A0080B5E81719F0E0BDFA9AF99A9FBF0895D4
:10062A00309760407040089500240A160B060806A9
:10063A00090608951A930A9308951981088108955D
:00000001FF

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your menu structure will depend on your user input controls.  A minimum control structure would be two buttons:  one button scrolls through the menu items and the other selects the current menu item. 

 

With an LCD, the current selection of the menu is the one that has reversed text.  Every press of the scroll_button advances the menu item by incrementing the variable for current_menu_selection_item, turns the old selected text back to non-highlighted (normal) text, and highlights (inverts) the text for the next item on the menu list.  If you get to the end of the list, start again from the beginning.

 

If you have more than four items on the menu list, then with a 20x4 LCD you will be rewriting the 80 chars of the screen entire screen with new menu listings with each press of the scroll button.

 

Implementing an encoder allows fast bi-directional scrolling as most cheap encoders have 12-24 positions per revolution of the shaft.  Cheap encoders create narrow spikes that quickly disappear  when the shaft is turned.  Normally one uses pin-change or user interrupts to detect shaft rotation.   Cheap encoders use four resistors and two capacitors to debounce and extend the spikes created by shaft rotation.  Cheap being less than a US dollar in cost from mainstream electronic components distributors like DigiKey.

 

If you use a TFT touch screen like on a smart-phone, then you can encode the touch input and display into one unit.  In this case, use a menu that has boxes for the menu items.  Have an array of structures with each element in the array holding the top, bottom, left, and right corners of each menu item.  Use this info to draw the menu box on the TFT display, and also to test whether any screen press is inside the co-ordinates of the menu box.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank all

I want to create a menu like this by pressing the UP and DOWN button and the eNTER button inside it

https://raw.githubusercontent.co...

Attachment(s): 

Last Edited: Mon. Sep 11, 2017 - 07:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
I want to create a menu like this ...

But you do not want any source code?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
I want to create a menu like this by pressing the UP and DOWN button and the eNTER button inside it https://raw.githubusercontent.co...

...where the code is at https://github.com/osakechan/not...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just how do you expect to do it WITHOUT source code? Maybe more important: what do YOU mean by "source code"?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oh my god
i want just source code menu scroll lcd 16*2....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

??? All the source code and detailed explanation is at the github link.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
i want creat menu lcd 16*2 and atmega and 2 button 

So why did you then post a schematic with four buttons:

sky_man847 wrote:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
i want creat menu lcd 16*2 and atmega and 2 button 

Buth the picture you posted is not 16x2:

sky_man847 wrote:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
oh my god

i want just source code menu scroll lcd 16*2 (sic) ....

But, as already pointed out to you, the source code for that very menu is at:

 

https://github.com/osakechan/notoriousPID

 

and you started by referring to http://www.avrfreaks.net/project... - which also contains source code.

 

So what more do you want??

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

not problem button.just creat menu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

please go to site :http://www.justexecuteit.com/sel...

how used code?my codevision erorr ...not compile

Last Edited: Tue. Sep 12, 2017 - 06:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sky_man847 wrote:
please go to site :http://www.justexecuteit.com/sel... 

Is that your own code, or just something you have found?

 

my codevision erorr ...not compile

You mean, you get an error message (or messages) when you try to compile it with CodeVision?

 

So what message(s), exactly, do you get?

 

Copy the message(s) from CodeVision and Paste it/them here - don't try to manually re-type them.

 

Note the instructions here for posting source code & images: http://www.avrfreaks.net/comment...

 

Last Edited: Tue. Sep 12, 2017 - 07:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank all.....resolved