Menu for Display

This is explained in tutorial 8: Google Code Archive - Long-term storage for Google Code Project Hosting.
When you jump from your toplevel main menu to the date/time entry you need to call a special procedure (prepare_user_input()) which reads data from external sources and puts them into variables which are shared with m2tklib.

If you would use a list of M2_BUTTON elements as toplevel menu, then the callback procedure for the M2_BUTTON should
(A) read the data from RTC and (B) refer to the date entry menu by using setRoot() procedure.
Tutorial 8 uses M2_STRLIST instead of M2_BUTTON, but the idea is the same.

Oliver

Good Morning Oliver,
so I will look the documentation today and how ever I will proceed with a test and I'll let you know ...

So It fantistic this library ... thanks again for your support ... without I was do nothing ... thanks

have nice week,
gnux

Hi Oliver,
looking the example into your link I've understood how to pass the value :

  • from a menu to the variable

but I don't understand into example:

  • how pass the value from a variable to a menu ... :frowning:

when into the example call

"pwm_apply_user_input() "

inside

void pwd_fn_ok(m2_el_fnarg_p fnarg)
{
pwm_apply_user_input();
m2.setRoot(&top_el_pin_list);
}

so, if need to pass the value to my variable

[00][00] [00][00][00]
OK Cancel

how I can do ? this means that into ok function button I will fill my variable ? and then will be immediatly displayed ?

Could you kindly pass me a simple just to understand ?

thanks for the support,
gnux

Hi
Passing a variable to M2tklib is (somehow) automatic. During definition of an element, such as M2_U8NUM, you pass a pointer to a variable:

uint8_t v;
M2_U8NUM(el_num, "", 0, 255, &v);

Variable "v" is connected to M2tklib. M2tklib will ALWAYS display the value of v. At any time you may assign a value to "v" and after the next call to the "draw" procedure it will display the current content of "v"
Controll flow would be:

  1. Jump from top menu to sub dialog (e.g. time change menu)
  2. During jump: Assign current sensor value (in your case RTC value) to "v" (prepare_user_input)
  3. Let the use change "v" though m2tklib
  4. If user pressed cancel, go back to main menu without any further action
  5. If user presse ok, store value of "v" to the external device (e.g. RTC), jump back to main menu (apply_user_input).

Oliver

Ciao Oliver,
from the logical stand point it's ok ... but to be honest I don't know how to realize it ... so:

uint8_t v;
M2_U8NUM(el_num, "r1", 0, 255, &v);

this is ok, because i use it normally into the menu i fill "v" when I push button ...

Now you mean ... for example into "Ok" button do something like this:

void viewdate{
v = RTC.get(DS1307_HR,true);
}

M2_BUTTON(el_num_zero, "f4", " Ok", viewdate);

then automatically into there will be the current date time ...

I thinks that soon i will be able to the test my menu with display and button ... you was telling me that the button will active when "low",
correct ? is necessary a resistor ? if you can provide to me a little schema will be great :slight_smile: ... so my understanding is this ...

correct ? just the idea what means active low could i test with serial menu ?

so then just add to the sketch this code:

uint8_t uiKeySelectPin = 10;
uint8_t uiKeyNextPin = 9;

and modify this code :

M2tk m2(&top_el_expandable_menu, m2_es_arduino_serial, m2_eh_2bs, m2_gh_arduino_serial);

with this :

M2tk m2(&top_el_expandable_menu, m2_es_arduino, m2_eh_2bs, m2_gh_arduino);

In order to use 2 button ...

if i'd like to use additional 2 but buttons just put this:

M2tk m2(&top_el_expandable_menu, m2_es_arduino, m2_eh_4bs, m2_gh_arduino);

and then declare additional buttons ?

thanks 10000
gnux

Hi

  1. Ok button
    Almost correct, except that you need to use the correct function prototype (see element reference for M2_BUTTON on the wiki page) and probably you want to refer to a submenu. That means, that m2.setRoot() is missing
void viewdate(m2_el_fnarg_p fnarg){
v = RTC.get(DS1307_HR,true);
m2.setRoot(&<nameofsubmenu>)
}
M2_BUTTON(el_num_zero, "f4", " Ok", viewdate);
  1. External button
    Connect one end of the button to an arduino pin
    Connect the other end to ground (0V)
    A resistor is NOT needed.

  2. You need to assign the button with m2.setPin(, <arduino_pin_number>)
    see Google Code Archive - Long-term storage for Google Code Project Hosting.

  3. Adding a display.
    Please follow this tutorial: Google Code Archive - Long-term storage for Google Code Project Hosting.
    Note: The correct name for the graphics handler is "m2_gh_lc"!
    Also take care to use m2_SetLiquidCrystal() as shown in the tutorial!

Oliver

Good Morning Oliver :slight_smile: Great ! Thanks you ... :slight_smile:

so today I'll try and then I'll let you know :slight_smile:

Regards,
gnux

Hi

I was imprecise. All dialog menus are accessed via their root element. So the answer is "el_list_date_disp" if you want to jump from main menu to "el_list_date_disp".

Oliver

I've tried the function it's ok :slight_smile:

so I will try also with the button ... :slight_smile: but only a curiosity it's possible use the button with the serial ? or it's only possible via lcd ?

thanks,
gnux

Not sure if i got your question right, but it is like this:
Usually you will
attach 2 or more hardware buttons and a physical LCD
With the serial monitor option you can do:
attach 2 or more hardware buttons and simulate the LCD via the serial monitor
or
simulate 2 ore more buttons via serial monitor and attach a physical LCD
or
simulate 2 ore more buttons via serial monitor and simulate the LCD via the serial monitor

Oliver

Good Morning Oliver,
I've did some test with LCD ... now I would ask to you if is possible change LCD pin ?

because inside my sketch I'm using "Virtual Wire Library" where as default use a

PIN 11 for rx and PIN 12 for tx and PIN 10 for push to talk ... well I've tried to specify other pint to use with the function but the display still to work not properly ... If i comment the part related to Virtual Wire everything is working well ...

So, what could advise me to do ?

thanks for the support :slight_smile:

have nice a day,
gnux

So, now with this pin

LiquidCrystal lcd(10, 9, 3, 2, 1, 0);

can work ... but I didn't understand why for example im using arduino mega 2560 rev 3 if i try to use ... 22 24 38 40 42 44 cannot work ...

could be useful for arrange and use arduino at the top ...

so then when I'm in LCD mode I've strange issues with in a sub menu with a button ... so I retrive date time from RTC time to time it's ok and other times is not ok ...

this happened into serial menu ... it's very strange ... but the date should be correct ...

could i check ?
thanks gnux

Schermata 2013-01-31 a 18.44.11.png

Maybe have found seems a power connection issues now I need to check the circuit ... :slight_smile: i hope. ...

I don't think connecting the LCD to the main hardware serial port is a good idea.

I read though the last e-mails. For sure it seems to be strange, that the day number is 45, but what should be checked?

Oliver

Ok Oliver, thanks for the information,
then I can use each pins that I want for lcd ?

Changing pin for lcd it's working ...

warm regards :slight_smile:
gnux

Hi Oliver,
changing the pin 0 and 1 the menu it's working ok now (i will consider this for the future :slight_smile: ) ...

Very helpfull :slight_smile:

Good to read that you had some success :slight_smile:

Oliver

Thanks again :-), I'll let you know about the next steps :slight_smile:

Ciao Oliver :slight_smile: how are you,
so now that I've take more confidence with your menu I'd like to do a menu that when I turn on arduino put into display :
colums :
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

1°row| Arduino Welcome
2°row| Ver . 1.0
3°row| 06 - 02 - 2013
4°row| 10 : 23 : 55

and then just when I press the first time select button appears the other menu, then will be exit to all menu will return to this screen,

is possible from your point of view ? could you give me suggest ?

thanks for the support,
have nice day,
gnux