RotaryEncoder state machine based approach to correctly reading the rotation signals of standard "KY-040" rotary encoders