Pages: [1]   Go Down
Author Topic: dynamicly define option # in different menu #  (Read 420 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello there,
I'm stuck in finding my way how to do the following.
With a button I can do the following:
pressing it short = changing an option within a menu
pressing it long = changing between menu's.

So now I need to define
menu1 has 2 options,  menu2 has 3 option, and menu3 = 6 options.
and of course add some actions to the choice I've made.

I'm a bit green when it gets deep in arrays and how to use them this way. I only know the basic how to put information in an array and how to read a value from an array nr.

If someone could give me a hand smiley-wink
Maybe I'm looking in a wrong direction and don't have to use arrays.

I was thinking:
int menu[] = {2, 3, 6};
but how to increment the option when in the selected menu....

Thanx!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's great when you type, you think..
And just when I pressed send I came up with my own answer:

Code:
int menu[] = {2, 3, 6};


// CHANGE OPTION - START
int option_switch() {
if (my_option == menu[my_menu] )      
        my_option = 1;     // if you are at the last menu, go back to the initial menu number
        else
increase_option_number:
        my_option ++;      // increase the menu number if it's not allready at max.
  Serial.print("Changing to option nr: ");
  Serial.print(my_option);
  Serial.print("\n");  
}
// CHANGE OPTION - STOP

// CHANGE MENU - START
int menu_switch(){
if (my_menu == 2)      // I only defined 2 menu's, you can add more by increasing this my_menu number)
        my_menu = 1;     // if you are at the last menu, go back to the initial menu number
        else
increase_menu_number:
        my_menu ++;      // increase the menu number if it's not allready at max.
  Serial.print("Changing to menu nr: ");
  Serial.print(my_menu);
  Serial.print("\n");  
}
// CHANGE MENU - STOP
Logged

Pages: [1]   Go Up
Jump to: