Hi
I am using the encoder libary and need to limit it's range. Basically, I am using the encoder value to navigate a menu.
But this code just limits it to 0-12, it doesn't roll over as I expected (>12 starts at 0 and <0 returns to 12).
Does the encoder library store the value internally or something?
Currently, this just stops at zero or 12, no roll-over.
I am using the encoder libary and need to limit it's range. Basically, I am using the encoder value to navigate a menu.
Code:
do {
encoderbutton.update();
newencoderposition = encoderknob.read();
if (newencoderposition != encoderposition) {
if (newencoderposition >12) {
newencoderposition = 0;
}
if (newencoderposition <0) {
newencoderposition = 12;
}
Serial.print("Encoder = ");
Serial.println(newencoderposition);
encoderposition = newencoderposition;
menuitems();
if (encoderbutton.changed() ) { // Encoder button
int deboucedInput = encoderbutton.read();
if (deboucedInput == LOW ) {
selectitem();
}
}
}
} while (exitmenu == false);
exitmenu = false;
But this code just limits it to 0-12, it doesn't roll over as I expected (>12 starts at 0 and <0 returns to 12).
Does the encoder library store the value internally or something?
Currently, this just stops at zero or 12, no roll-over.