improved rotary encoding logic

thanks to py-gaugette