Rotary Encoder

Encoder libraries never need debounce as their is no ambiguity with bounce, it just toggles the
output position +/- one count, which is something that can happen anyway if there's mechanical vibration.

The output position from an encoder like this can be given hysteresis of 1 count before interpreting it,
something like this:

volatile int position ;

ISR ....
{
  ...
  position = ...
}


int get_position()
{
  static int smoothed_position;
  if (abs (position - smoothed_position) > 1) // moved more than 1 since last time
  {
    smothed_position = position ;
  }
  return smoothed_position ;
}

The result of get_position() will hide any bouncing or dithering between readings when
perched on the edge.