One variable transformed to multiple ones

Hi, I am now trying to transform my one variable (count of steps from encoder) into multiple ones. The count should transform into other variables based on logiclevel of button, or the page, where the user just is. One thing, that I can't figure out is how to store the last state of each variable and come back to it.
From start all the variables will be zero. Then I will go to page 2, by using encoder. That would mean, that StepCounter is sitting at 2. At page two I would like to change text, that's in array. The array is indexed by subcount_1. To show the values correctly I would need to set the stepcounter back to zero. But If did this and changed the buttonlogiclevel, it would take me back to page 1. Thats the problem, I am trying to solve.

This is the code, that I currently have. The problem is, as I stated before, that the variables are not independent. Would be really glad, if someone showed some function or math, that can solve this.

  if(buttonLogicLevel == LOW){
    pageIndex = stepCounter;
  }
  if(buttonLogicLevel == HIGH){
    if(pageIndex == 2){
      subCount_1 = StepCounter;
    }
    if(pageIndex == 3){
      subCount_2 = StepCounter;
    }
  }

Hello
Well, I guess the application of some structured array´s could help.

pretty sure you'll need code to recognize a button press, not simply button state


when i did a multi-level menu, i used an array to keep track of which menu item the code was at at each level.

each menu level was defined by a table. each element had parameters for that menu item.

in general, there needs to be a way to advance to the next menu item at a level, return to the previous menus and select the menu item. various types of menus are possible from simple binary to entering text. this can be done with 4 buttons.

it's not a question of arrays and/or structures, but how to use them to manage the menu processing.

my menu code is 488 lines (a lot for editing text), but the file describing the menus for my application (train throttle) is only 80, but expected to grow.

the menu includes the tedious ability to enter/edit WiFi SSIDs and passwords. it is presumably complete and only the data describing new menus would need to be added.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.