Pages

Monday, July 8, 2013

An AVR Atmega LCD Menu builder library

Updated to version 02

lcdmenu1 is a simple and small lcd menu builder for AVR Atmega.



It works with only 4 buttons (up, down, right, left), additional buttons can be added.
It can also store values to eeprom


User can use button up and down to list menu categories, right and left to browse child and parent.
If an item is selected, the right button makes the menu enter in edit-mode.
In this mode button up and down changes the item value, left exit without save to eeprom, right exit and save to eeprom.
The menu costructor is based upon Dean Camera micro-menu. It works on 2x16 lcd using the Peter Fleury lcd library for HD44780, but it can also be change to fit other lcd resolution.
It is test on 2x16 HD44780 device, sample code is provided.

The main function is the builder function:

lcdmenu1_makemenu(name, next, prev, parent, sibling, selectfunc, enterfunc, exitfunc, text);
name is the name of the menuitem
next is the pointer to next menuitem
prev is the pointer to the prev menuitem
parent is the parent of the menuitem
sibling is the child of the menuitem
enterfunc is the function to be called when user enter this menuitem
exitfunc is the function to be called when user exit this menuitem
text is the text view on lcd for the menuitem

The sample  code provided build menu item, menu folder, menu subfoder.


This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

17 comments:

  1. Hello Gironi, does this code work for Atmega32 as well or I need to port the code along with the port pins I am using in my project?

    ReplyDelete
    Replies
    1. you have to change some pin but it should compile and works.

      Delete
  2. Hi Davide
    Thanks for your help. But when I compile the code. There is one error: variable 'micromenu_nullitem' must be const in order to be put into read-only section by means of '__attribute__((progmem))'.
    how I can fix this error?
    Thank you very much

    ReplyDelete
    Replies
    1. Hello, i've just recompile this as a new project and i can not encounter this error. Are you using avrgcc? I tell you this because IAR and other commercial compilers have the __flash keyword, this means you can have const variables in ram.

      Delete
    2. I am running into the same error as ZHOU JACK, I am using the avrgcc compiler. Any Ideas?

      Delete
    3. Try with Eclipse with the AVR plugin and win-avr (if you are on windows).

      Delete
    4. Works now! thank you Davide

      Delete
    5. You're welcome. Happy to help you ;)

      Delete
    6. Hi Davide, Can you please port into atmel studio or microchip studio, i am also facing similar error..!

      Delete
  3. Good day Great program works well just want to know were and how I can enter my own code and then select your menu ,edit it and then go back to my application to display temperature or adc value etc.

    Thanks Werner

    ReplyDelete
    Replies
    1. Hello, thank you for your feedback. You can take a look at the /* built menu */ region of the main.c sample. Also, the main.c sample could be a good starting point for your menu.

      Delete
  4. Hi Davide, Can you please port into atmel studio or microchip studio, i am also facing similar error..!

    ReplyDelete
    Replies
    1. Hello, I'm sorry but I've no time for porting. You can do it by yourself, that's will not be so difficult.

      Delete