Go Down

Topic: Menu for Display (Read 20073 times) previous topic - next topic


Hi All,
do you know something simply procedure to implement for inizialize arduino from a keypad and display the on a display ?

I'm trying to find a base code from start to implement it,

thanks in advance,



Did the keypad (make/model ?) come with any example programs ?
What do you mean by "inizialize arduino from a keypad" ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.


Yes I'm using the Keypad.h with Adafruit Keypad,

So My focus is built a sketch that for example when I push * appear the menu i then i start to set my parameters,



Ok thanks,
what I was thinking to was to implement a case with if etc etc,
but If is there more simply routines to call should better and more inside the software i thinks, i will check and then I'll to you know,



I've tried to something with Library Menu but I retrieve several issues with the library ...


I will see the other suggestion ...



liudr has once started a new section in playground:

I also made a list of menu tools some time ago:
Library Name:             LCDMenu2
Download:             http://arduino.cc/forum/index.php/topic,73816.0.html

Library Name:             LCDMenu
Download:             http://arduino.cc/forum/index.php/topic,96104.0.html

Library Name:             MenuBackend
Download:             http://wiring.uniandes.edu.co/source/trunk/wiring/firmware/libraries/MenuBackend/

Library Name:             LCDMenu
Download:             http://www.metalgecko.com/arduino/LCDMenu.zip (does not exist any more)

Library Name:             Arduino_LCD_Menu
Download:             https://github.com/DavidAndrews/Arduino_LCD_Menu

Library Name:             MENWIZ
Download:             https://github.com/brunialti/MENWIZ

Library Name:             phi_prompt
Download:             http://liudr.wordpress.com/libraries/phi_prompt/

Library Name:             MenuSample
Download:             http://sourceforge.net/projects/arduinowifly/files/MenuSample/

Library Name:             M2tklib
Download:             http://code.google.com/p/m2tklib/

Library Name:             OpenMoCo Menu Manager
Download:             http://arduino.cc/forum/index.php/topic,131614.0.html, http://dynamicperception.com/software/openmoco-avr-libraries

I can say that discussions on MENWIZ and phi_prompt had been very active on the Display forum. I also get a lot of feedback on my own menu lib (M2tklib) and you are always wellcome to contact me if you have any trouble with M2tklib.



If you want I can try to use your library for the menu "M2tklib" in this way will be happy togheter :-) ... so i'll learn how to use the menu and you maybe you i'll can be to improve your library ...

So, with the menu I'm starting from zero point ... anyway i'll download the library and I'll start try to understand how it's working ...

thanks in advance,



So, for start I've available 2 kind of display,

- the first one is  a LCD (4 Rows with 20 character) --> 7 pins
- the second one is a LCD (2 Rows with 16 character) --> 2 pin I2C bus

Which is the best and simple to use :-) ?



With M2tklib only LiquidCrystal lib is supported, so you need to use your 7 pin 4x20 LCD.
Also take care to download M2tklib for LiquidCrystal.



I've downloaded:

- m2tklib_arduino_lc_1.09.zip

and now I'm looking the examples,


So, I've understand how structered the menu ..., for the input I've available a keypad that has the characters from 0 to 9 plus * and #

Could i use it ?

if yes how I can define the push button ? and how I can call the right procedure ?

thansk :-) you see that I'm very young with that :-)




By default M2tklib supports aktive low push buttons: Connect an Arduino pin to a push button and the other end of the push button to ground.

A keypad can be used, but you need to define your own "event source", which is not really described at the moment. Let me know if your really want to use your keypad. In this case we need to study the datasheet for the keypad and write a specific event source.

Another way is to simulate input by using the serial monitor.
With the serial monitor you can test your menus without extra input hardware. Instead, input on the serial monitor is used to navigate through the menues. For example look at the Combo.pde:
You will find the following line:
Code: [Select]
M2tk m2(&list_element, m2_es_arduino, m2_eh_2bs, m2_gh_lc);
Add "_serial" to the event source:
Code: [Select]
M2tk m2(&list_element, m2_es_arduino_serial, m2_eh_2bs, m2_gh_lc);
This enables the serial monitor to navigate through the menu. Remember to activate the serial monitor in your Arduino IDE.
This can be done for all examples, and of course it might be a good starting point for your projects, if you have not yet decided which hardware buttons to use.

Learning M2tklib:

Looking at the examples is a good starting point. And it seems that the examples are already working (I am glad the M2tklib works in your environment). I also suggest to look at the first three tutorials:

Tutorial 1: General setup
Tutorial 2: How to apply the above mentioned push buttons
Tutorial 3: How to build a simple menu/dialog
I also suggest to read
Tutorial 7: How to use the serial monitor interface
as mentioned above for quick success without additional input hardware



Thanks Oliver,
Then I need to define 2 push button in arduino correct ?

and I not understood bad i can test my menu into Arduino serial monitor without lcd before to deploy it with the display,
this I think it's very useful ...

So, I will read the documentation and then I'll start immediately ...
So i think that for the moment I can implement 2 button without problem for be more confortable ... what do you mean ? Then when I'll be able to manage it maybe we can pass to keypad ...

Thanks for your precious support,


Jan 18, 2013, 02:12 pm Last Edit: Jan 18, 2013, 02:33 pm by gnusso Reason: 1
Hi Oliver,
So, after reading your indication I've seen how to proceed more or less but I've some question for you. I'd Like to structure my Menu in this way:

Menu --> Activate pushing "Select"
 - "Date/Time 1"
     ". Set D/T 1-1"
     ". View D/T 1-2"

 - "Timer 2":
    ". E/D 2-1"
    ". Sel. Dev. 2-2"
     ". Start  D/T 2-3"
     ". Stop D/T 2-4"

for the moment i think should be enough :-)

But the problem is how to do that ? How i can call the procedure, Retrive Value etc?





M2tklib requires at least 2 buttons. Make sure that you use the correct event handler. With two buttons, the "2bs" handler.
Existing event handler are described here http://code.google.com/p/m2tklib/wiki/fnref#M2tk.

With M2tklib you can describe a dialog / user entry form. Such a form is composed of several elements. These elements have a hierarchie, including one element, which is the root element.

In tutorial 2 (http://code.google.com/p/m2tklib/wiki/t03) you see the following user entry form:

Code: [Select]

void fn_ok(m2_el_fnarg_p fnarg) {
  /* do something with the number */
M2_LABEL(el_label, NULL, "Num: ");
M2_U32NUM(el_num, "a1c4", &number);
M2_BUTTON(el_ok, "", " ok ", fn_ok);
M2_LIST(list) = { &el_label, &el_num, &el_ok };
M2_HLIST(top_el_hlist, NULL, list);

The root element is "top_el_hlist", it contains "list" and list contains "el_label", "el_num" and "el_ok". So, basically it looks like this:
  - U32NUM

The toplevel element "top_el_hlist" is the most important element. If you want to display this complete dialog  box, you must make the toplevel element "top_el_hlist" the so called "root" element.

Making a toplevel element as a root element is just like jumping to this dialog box. There are several ways to make an element the root element: M2_ROOT or m2.setRoot() are two common options. The 2L-Menu element is another option to make other elements the root element. Just add the root element next to the menu title (including &). See the example pde.



Jan 18, 2013, 08:11 pm Last Edit: Jan 18, 2013, 08:14 pm by olikraus Reason: 1
Here is an example for a date entry dialog box:
Code: [Select]

/* edit date dialog */

uint8_t dt_day;
uint8_t dt_month;
uint8_t dt_year;

void dt_get_from_RTC(void)
  dt_day = RTC.day;
  dt_month = RTC.month;
  dt_year = (RTC.year-2000);

void dt_put_to_RTC(void)
  RTC.fillByYMD(dt_year+2000, dt_month, dt_day);

void dt_ok_fn(m2_el_fnarg_p fnarg)

M2_U8NUM(el_dt_day, "c2", 1,31,&dt_day);
M2_LABEL(el_dt_sep1, NULL, ".");
M2_U8NUM(el_dt_month, "c2", 1,12,&dt_month);
M2_LABEL(el_dt_sep2, NULL, ".");
M2_U8NUM(el_dt_year, "c2", 0,99,&dt_year);

M2_LIST(list_date) = { &el_dt_day, &el_dt_sep1, &el_dt_month, &el_dt_sep2, &el_dt_year };
M2_HLIST(el_date, NULL, list_date);

M2_ROOT(el_dt_cancel, NULL, "cancel", &el_top)
M2_BUTTON(el_dt_ok, NULL, "ok", dt_ok_fn);
M2_LIST(list_dt_buttons) = {&el_dt_cancel, &el_dt_ok };
M2_HLIST(el_dt_buttons, NULL, list_dt_buttons);

M2_LIST(list_dt) = {&el_date, &el_dt_buttons };
M2_VLIST(el_top_dt, NULL, list_dt);

The "dt_put_to_RTC" procedure will be different for your, but the element hierarchy might be the same.
The top level element is "el_top_dt".

This means that your data for the 2L-Menu might look like this:

Code: [Select]
m2_menu_entry m2_2lmenu_data[] =
  { "Date/Time 1", NULL },
   { ". Set Date 1-1", &el_top_dt },
  { NULL, NULL },

The 2L-Menu is another element hierarchy. For example:

Code: [Select]
M2_2LMENU(el_2lmenu,"l4F3e15W43",&m2_2lmenu_first,&m2_2lmenu_cnt, m2_2lmenu_data,65,102,'\0');
M2_SPACE(el_space, "W1h1");
M2_VSB(el_vsb, "l4W2r1", &m2_2lmenu_first, &m2_2lmenu_cnt);
M2_LIST(list_2lmenu) = { &el_2lmenu, &el_space, &el_vsb };
M2_HLIST(el_hlist, NULL, list_2lmenu);
M2_ALIGN(top_el_expandable_menu, "-1|1W64H64", &el_hlist);

The toplevel (root) element is "top_el_expandable_menu".


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131