I'm trying to create a menu based on rotary encoder with LCD but im getting some weird issue.
First of all, i'm using a common part of code to handle a rotary encoder (still learning) and it's working fine - the "menuOption" reacts smooth and instantly.
But when i'm trying to put that 'menuOption' into the function then it's working like the rotary encoder has missing steps. For example without funtcion when i turn the encoder then it displays at serial output values without any problem, but in function i have to rotate it multiple times in one direction to jump into different value.
The function is:
int lcd_menu(int option){
Serial.print(option);
Serial.print("\n");
switch(option){
case 0:
displayText("Motor spd");
//motorMenu();
break;
case 1:
displayText("Curing spd");
//curingMenu();
break;
case 2:
displayText("Start");
//curingMenu();
break;
default:
displayText("Error");
break;
}
}
I'm also have a little function to set correct Value of the encoder (menu etc):
int setCorrectValue(int value){
if(value > menuMax){
value = 0;
}
if(value < 0){
value = menuMax;
}
return value;
}
And right now i'm totally dont know why it happens. It's also happened when i'm using a 'if' statement with comparing the 'menuOption' with value for example 'menuOption' == 1, to perform specific action.
Could someone tell me what i'm missing? Connection to the arduino is very easy - GND and + are connected to the 5V (main GND with arduino also), then CLK and DT and SW are connected to the D8, D9, D10 pins.
Yea, the MotorMenu contain the delay but it's under comment, take a look at the /* and */ at the beginning and ending of function. And take a look at the "//motorMenu();" it's commented. So the function is not called.
And no, it's not ignoring the encoder for a second or more, it's behave like skipping steps while i'm rotating the encoder. I have to rotate it multiple times to increment or decrement the values.
And yeah, i know how to write a nonblocking code using millis() (I’m not a master in that but I can do that and I’ve got it in my main code) but, i'm testing it right now and i dont want to run the whole code under the tested feature.
Like i said. i've got problem here:
switch(option){
case 0:
displayText("Motor spd");
//motorMenu();
break;
case 1:
In switch-case: when i'm trying using it like that it's skipping and i have to rotate it multiple times to increment or decrement values. Without function with switch-case (clear serial output) or if statement it's working fine.
And also I’ve tried to put if or switch case just under the rotary encoder block (without function) but it’s working similar - multiple rotates to increment value - so there is no delay or any other blocking the code. And without it, it’s increment normally.
This text is so compact and leaves out so much information that I don't understand your text.
Each and every "it" should be replaced by the real name that specifies exactly what is meant by "it"
You would have to separate the multiple cases that you included in this writing
Correct. I thought "reply" on this forum showed the current message from the person who was replied to, but it doesn't. Forum shows only the little mark above post.