Go Down

Topic: LCD menu options (best route) (Read 9 times) previous topic - next topic

jman31

#30
Jan 21, 2010, 03:44 pm Last Edit: Jan 21, 2010, 03:47 pm by jman31 Reason: 1
Next questions for anyone NOT sick of me yet! ::) ;D

I managed to get two menu tiers working with two separate buttons. I tried to make a third tier menu and going back to the first button again. Here is the code I used. I redefined switchpin as buttonStateThree hoping that that would separate it from buttonStateOne, and added this code. I am seeing "Time" cases, but once again they refuse to behave properly.

Secondly, with the direction I have gone is there any way to have another button that would go "back" through the menu options of all of these tiers?

Code: [Select]
 //Time duration Choosing
if(buttonThreeState == HIGH && previousButtonThreeState == LOW && ledState == LED2 && colorState == COLOR1){   //sets button one to the TIME2 loop    
   
   switch(durationState){
   case TIME1:
     lcd.clear();
     lcd.print("Time 1");
     durationState = TIME2; //transition to color2 state
     break; //end of color1 case
   case TIME2:
     lcd.clear();
     lcd.print("Time 2");
     durationState = TIME3; //transition to color3 state
     break; //end of color2 case
   case TIME3:
     lcd.clear();
     lcd.print("Time 3");
     durationState = TIME4; //transition back to color1 state
     break; //end of color3 case
   case TIME4:
     lcd.clear();
     lcd.print("Time 4");
     durationState = TIME1; //transition back to color1 state
     break; //end of color3 case      
     previousButtonThreeState = buttonThreeState;
   }  
 }
 previousButtonOneState = buttonOneState;
 previousButtonTwoState = buttonTwoState;
 previousButtonThreeState = buttonThreeState;
}

Groove

My suggestion would be to separate "what the menu item does"  from "what I did to get to the menu item" (i.e the navigation controls).
A menu hierarchy can be simply written as a series of functions with infinite loops containing switch statements containing menu functions.
Menu functions can be simple actions, or function calls to sub-menus.

Once you break out of the loop at any given level, the function returns, taking you to the menu above.
Per Arduino ad Astra

AlphaBeta

I completly understand if you want to do it yourself, but as per Grooves suggestion:
http://www.arduino.cc/playground/Code/Menu this is a framework that I wrote to separate the navigation and the action.

Have a play with the example, and do not hesitate to ask any questions.  :)
(about either the library or other things:)

Good luck

jman31

#33
Jan 21, 2010, 09:58 pm Last Edit: Jan 21, 2010, 10:00 pm by jman31 Reason: 1
Trust me I have been eyeing that for two days now, but I am so new to this programming stuff that I have no idea where to start in implementing it. I actually would rather use a tried-and-true method than stumble through it myself. I will see if I can make it work for me. I installed the menu this morning and gave it a look, but a lot of it confuses me.

jman31

I may not even understand what I am asking here so please bear with me. How do I know what a library is intended to do. AlphaBeta, I see where you included your menu libraries in the sample code you included, but how does the end user know what you coded into these libraries, and then be able to use them?  :-?

Go Up