Add encoder rotation acceleration.

This commit is contained in:
2025-05-04 22:36:11 -07:00
parent 90f94c3077
commit a7d47bc820

View File

@ -106,6 +106,7 @@ class EncoderDir {
// Return the number of ticks change since last polled.
int _rotate_change() {
int position = encoder_.getPosition();
unsigned long ms = encoder_.getMillisBetweenRotations();
// Validation (TODO: add debounce check).
if (previous_pos_ == position) {
@ -116,6 +117,13 @@ class EncoderDir {
change = position - previous_pos_;
previous_pos_ = position;
// Encoder rotate acceleration.
if (ms < 16) {
change *= 3;
} else if (ms < 32) {
change *= 2;
}
return change;
}