I wrote a demo-code that uses timer2 for "backround-polling" of the encoder-pins.
This occupies timer2 which is used by other libraries too.
So I was asking myself if it would be possible to add the rotary-code to the timer-interrupt that counts up millis() without delaying millis() too much to no longer count milliseconds as precise as without the rotarty--encoder-code.
How much modification would this need?
Would I have to modify the arduino-core?
I don't know whether another ISR will be allowed and how it will call the standard ISR of timer 0. The interrupt vector table allows for only one ISR address.
Instead I'd use the PCINT for the encoder pin(s) which occur much less frequently than the regular timer interrupts. In addition RC filters can be used to reduce/suppress bouncing of mechanical and manually rotated encoders.
You can also use one of the "compare match" interrupts on timer 0.
They'll also occur a ~1kHz, and they're separate from the millis() (overflow) interrupt.
The only problem would be if you're using PWM on one of the timer0 pins, changing the PWM value could result in a short or long interrupt, each time you change it.