I'm attempting to use a quad encoder as user input. It is connected to the LPTIM1, so I was going to use the HAL functions with encoder mode. I want to be able to sense both the direction and amount of turn of the encoder in order to move selection elements on a screen.
I'm interested in doing this using interrupts (aka not polling), which there doesn't seem to be a lot of examples about.
By default HAL_LPTIM_Encoder_Start_IT enables the "switch to up direction" and "switch to down direction" interrupts, which I'm assuming only happen initially on the direction change. Does anyone know if these interrupts will happen if the encoder is idle (i.e. user turns clockwise, stops turning, user turns clockwise again)? I'm assuming I will need to add one of the compare interrupts in order to be able to determine how much the encoder is changing in a particular direction. I don't have hardware available to test with (yet).
On direction change interrupts, setup the compare register appropriately (up or down X from current count)
Enable compare interrupt
On compare interrupt, update compare register by X again and send "rotate" event to the rest of the application.
Repeat as necessary or until opposite direction change interrupt
Anyone have experience using LPTIM with interrupts? Does this plan make sense?