Pages: 1 ... 3 4 [5] 6 7 ... 15   Go Down
Author Topic: Menu for Display  (Read 14383 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ... :-(

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
Logged

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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:

Code:
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 :-) ... 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:

Code:
uint8_t uiKeySelectPin = 10;
uint8_t uiKeyNextPin = 9;

and modify this code :
Code:
M2tk m2(&top_el_expandable_menu, m2_es_arduino_serial, m2_eh_2bs, m2_gh_arduino_serial);
with this :
Code:
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:
Code:
M2tk m2(&top_el_expandable_menu, m2_es_arduino, m2_eh_4bs, m2_gh_arduino);
and then declare additional buttons ?





thanks 10000
gnux
« Last Edit: January 29, 2013, 08:42:02 am by gnusso » Logged

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
void viewdate(m2_el_fnarg_p fnarg){
v = RTC.get(DS1307_HR,true);
m2.setRoot(&<nameofsubmenu>)
}
M2_BUTTON(el_num_zero, "f4", " Ok", viewdate);

2) External button
Connect one end of the button to an arduino pin
Connect the other end to ground (0V)
A resistor is NOT needed.

3) You need to assign the button with m2.setPin(<keyfunction>, <arduino_pin_number>)
see http://code.google.com/p/m2tklib/wiki/fnref#setPin

4) Adding a display.
Please follow this tutorial: http://code.google.com/p/m2tklib/wiki/t02lc
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

Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good Morning Oliver :-) Great ! Thanks you ... :-)

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

Regards,
gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried the function it's ok :-)

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

thanks,
gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)

have nice a day,
gnux
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 (5.34 KB, 139x52 - viewed 39 times.)
« Last Edit: January 31, 2013, 12:45:51 pm by gnusso » Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49077
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)
gnux
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Very helpfull :-)
Logged

Pages: 1 ... 3 4 [5] 6 7 ... 15   Go Up
Jump to: