Hi, there.
I found small problem in your encoder stream read function routine which lead to encoder reading bug when changing direction. and that is don't executing until next step after changing direction which instead of one step now it execute two steps.
I resolve that by adding this in your read() function line 67:
if(d>0 && oldPos<=0){
d+=sensivity;
}else if (d<0 && oldPos>=0){
d-=sensivity;
}
so your entire read function become like this:
int read() override {
int d=enc.pos-oldPos;
if(d>0 && oldPos<=0){
d+=sensivity;
}else if (d<0 && oldPos>=0){
d-=sensivity;
}
if (d<=-sensivity) {
oldPos-=sensivity;
return options->navCodes[downCmd].ch;
}
if (d>=sensivity) {
oldPos+=sensivity;
return options->navCodes[upCmd].ch;
}
return -1;
}
Hi, there. I found small problem in your encoder stream read function routine which lead to encoder reading bug when changing direction. and that is don't executing until next step after changing direction which instead of one step now it execute two steps. I resolve that by adding this in your read() function line 67: if(d>0 && oldPos<=0){ d+=sensivity; }else if (d<0 && oldPos>=0){ d-=sensivity; }
so your entire read function become like this: