Hello
I'm trying to implement a simple menu to modify 2 variables (Volume and Contrast) using a rotary encoder hooked to TIM3 (encoder mode). What I want to achieve is when I press on the rotary switch it toggles between the 2 variables and then rotating the encoder, I can modify their respective values. My problem is I can't find a way to restore the saved counter when I toggle the switch. I tried to use 2 temporary variables, but it when I restore them to the TIM3→CNT doesn't update
Please don't laugh on my code, I'm not a programmer by trade! I hope that someone cleaver in programming help me to resolve this issue!
Thanks in advance
{
void rencoder(void)
{
pb_scan();
if(pushb==31)
{
menucounter++;
if(menucounter>2) menucounter=0;
}
switch(menucounter)
case(0):
volume=TIM3->CNT;//how to save this value without affecting the contrast variable
break;
case(1):
contrast=TIM3->CNT;
break;
}
}