madhephaestus/ESP32Encoder

Encoder get difference from last read

windorey opened this issue · 1 comments

Hello, in my project I need to know the difference of the encoder since the last time read, for example if I turn it 3 times anticlockwise after the last read and then read it again, the result will be -3, if it's not rotated at all, it will be 0.

What would be the fastest and most efficient possible way of doing this?

I would do this in user code, just make a wrapping function/method around reading from the encoder object, and storing the last value in a variable. A separate call to calculate the Delta from previous makes the most sense.