igorantolic / ai-esp32-rotary-encoder

Easy implement rotary encoder to your application using microcontroler like ESP32
GNU General Public License v2.0
284 stars 70 forks source link

Initial value bug #49

Closed Onefabis closed 1 year ago

Onefabis commented 1 year ago

Hi! Nice lib, it helped me with my project. But I've found one bug when I launch my esp32: if I set boundaries like 0-100 and setEncoderValue = 0 it will ignore the first rotation and only after that it will start to change the value. In case I'll set 0-100 and setEncoderValue = 20, for instance, it will very fast switch to 19 and back to 20 in case of CW rotation. So my suggestion is to change the 137 line from this->old_AB = 0; to: this->old_AB = -1; It woks fine even with range -1 to 100 with default -1 value. And with -100 to 100 range with 0 as the default.

korianv commented 1 year ago

Cannot set this->old_AB = -1; because uint8_t old_AB; (header, line 56), unless the type changes to int8_t.

igorantolic commented 1 year ago

Try new setting rotaryEncoder.correctionOffset=2; //try with zero or ROTARY_ENCODER_STEPS/2 See Multi.select.ino example in just released version