Counts a quadrature encoder's steps from its A and B channels.
Creates a decoder seeded with the channel levels it reads now, both low unless given, so the first reading does not count a step that did not happen.
Optional
The signed count of steps so far.
Sets the count back to 0, keeping the channel state last read.
Feeds the channel levels read now, and returns 1 or -1 for a step in either direction, or 0 for no change or a jump past a step.
Counts a quadrature encoder's steps from its A and B channels.