Pages: 1 2 [3]   Go Down
Author Topic: LCD menu options (best route)  (Read 8646 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Next questions for anyone NOT sick of me yet! :smiley ;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:
 //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;
}
« Last Edit: January 21, 2010, 09:47:56 am by jman31 » Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Per Arduino ad Astra

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley
(about either the library or other things:)

Good luck
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 21, 2010, 04:00:09 pm by jman31 » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 2 [3]   Go Up
Jump to: