What is the best way to get an LCD menu buttons to program the buttons if you also want to use the buttons for changing the value of the menu item.
Thanks for the effort.
What is the best way to get an LCD menu buttons to program the buttons if you also want to use the buttons for changing the value of the menu item.
Thanks for the effort.
How many buttons do you have ?
5 buttons would give you separate buttons for up, down, left, right and accept. If you have less buttons then one or more need to have different uses in different contexts which becomes more difficult to program and use.
Dear UkHeliBob,
I have 4 buttons up /down / enter and escape.
Many thanks.
Just to clarify, do you want something like 3:50 into this video?
I was using up/down to highlight an item and then left and right to adjust values. It does require at least 5 buttons. If you only have up/down/enter/escape, then my program will not work for you.
@ Liudr
Yes, that is what I searching.
I can make one button more on my arduino that is now problem and than I have 5 buttons.
Do you use a special shield for the buttons?
Is on this sketch also a timer module?
I thought I saw in the beginning of the movie.
Many thanks.
bjoang:
Dear UkHeliBob,I have 4 buttons up /down / enter and escape.
Many thanks.
One way would be to implement a 'state machine'
Write down all the states that the menu can be in and the actions that each button will take when in that state. Something like this.
State 1 - cursor on menu item 1.
Up does nothing, down moves to state 3, enter moves to state 2, escape exits the menu
State 2 - entering value for menu item 1.
Up increments the value, down decrements the value, enter accepts the value and moves to state 3, escape exits the menu
State 3 - cursor on menu item 2.
Up moves to state 1, down moves to state 5, enter moves to state 4, escape exits the menu
State 4 - entering value for menu item 2.
Up increments the value, down decrements the value, enter accepts the value and moves to state 6, escape exits the menu
State 5 - cursor on menu item 3.
Up moves to state 3, down moves to state 6, enter moves to state 7, escape exits the menu
State 6 - entering value for menu item 3.
Up increments the value, down decrements the value, enter accepts the value and moves to state 7, escape exits the menu
etc, etc
As you can see the buttons have different meanings depending on the state. A good way to deal with this is to have a state variable and use select/case to execute the required actions depending on the state.
bjoang:
@ Liudr
Yes, that is what I searching.
I can make one button more on my arduino that is now problem and than I have 5 buttons.Do you use a special shield for the buttons?
Is on this sketch also a timer module?
I thought I saw in the beginning of the movie.Many thanks.
The shield is the phi-2 shield I designed, which does have a real time clock:
The programming, which is based on my phi_prompt interactive library, is non-trivial though.
bjoang:
What is the best way to get an LCD menu buttons to program the buttons if you also want to use the buttons for changing the value of the menu item.
I normally use a rotary encoder with built-in push button. Turn the encoder to scroll through the menu items, push it to select one, turn the encoder to alter the desired value, and push it again to confirm the change and return to the menu. Needs just 1 control rather than 3. Also, rotary encoders provide a much faster way of changing values than up/down push buttons.
Dear DC42,
It seems to me a good alternative and have also been to watching.
The room thermostat for my heating works that way.
I just do not know what they are here for encoder to use and how to put this program.
Is it possible that you dar a sketch picture of you so I can see how I should set up.
Thank you.
I have used Nick Gammon's sketch which works a charm. http://www.gammon.com.au/forum/?id=11130
Yes, I use a state machine to keep track of whether I am at the top-level menu or which parameter is being set.
I am also very intrested how you can program this on a easy way.
I know how you can change the cases in the top level but how can I change the valeu.
For sample.
I have a menu that I must give the time.
First I must take the hours than the minute and than the seconds.
Only for the hours the valeu must going from 0 to 23 and the minute from 0 to 60 and the seconds also from 0 to 60.
But how can I spring from the top level cases to the lower valeus fro changing?
I normally use a rotary encoder with built-in push button.
@dc42: is there a kind of "framework" for above setup? I mean a library where I add simply "the script" (menu items, variables, ranges, and the transition between the states, etc..)