All this to ask if a rotary encoder can work well without interrupts in my scenario.
[...8<...]
Also, I'm leaning toward debouncing the encoder with Schmidt triggers. My guess is this is better for having the mcu keep up than a software debounce, but maybe bad because if it doesn't keep up, glitches can't be caught the way a proper software debounce might.
The attached code contains the user input handling in my power supply: encoders' rotation, push buttons (long and short presses) and UART - which I edited out, as not relevant here.
It's for a STMF042, and uses the dreaded HAL, but should be fairly readable and portable.
The core is the
Debounce() function, which I call more or less every 1ms, triggered by the SysTick.
Since only one button and one encoder is served in each call, the actual sampling interval is 2ms.
The
Debounce() function is fast enough to be called in the SysTick handler, but it could be also called in the main loop.
No need for edge interrupts, and input events are delivered in a queue (
inputRing) the application can read with
ReadInput() (no spaghetti here).
Excess events are simply discarded.
As for the Schmitt triggers: the encoders are HW debounced with RCs (10kohm/47nF IIRC)+74HC14.
Events are not lost even when turning the encoders at highest speed possible (for my fingers, at least...I did not try attaching a drill to the shaft).
As the encoders are the 30-detents 15-pulses type, only a very simple direction detection routine is needed (and, indeed, possible).