I'm using a rotary encoder to navigate a menu and use "switch" statements to control the 3 functions of the encoder.
void navigateMenus()
{
MenuItem currentMenu=menu.getCurrent();
switch (lastButtonPushed)
{
case encoderPushButton: // enter pin
if(!(currentMenu.moveDown()))//if the current menu has a child and enter has been pressed then navigate menu to item below
{
menu.use();
}
else //otherwise, if menu has no child and enter has been pressed---- the current menu is used
{
menu.moveDown();
}
break;
case buttonPinEsc:
lcd.clear();
menu.toRoot(); //back to main
break;
case 1: //Encoder right rotation
menu.moveRight();
break;
case 2: //Encoder left rotation
menu.moveLeft();
break;
}
lastButtonPushed=0; //reset the lastButtonPushed variable
}
To get this far I have the rotary encoder set up as below
void readEncoder() //read the encoder and set lastButtonPushed to values used by navigateMenu()
{
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == HIGH) && (n == LOW))
{
if (digitalRead(encoder0PinB) == LOW)
{
lastButtonPushed = 1;
}
else
{
lastButtonPushed = 2;
}
}
encoder0PinALast = n;
}
What I would like to know is can I also use the same rotary action to increase a parameter instead of moving Right (case 1) or Left (case 2) through a menu. If it is possible, how would it be done?
I have a lot of views but no one has responed. can anyone offer any help on this matter