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;
}
}