I’ve posted similar questions in the lvgl forum but I would surely like to see this implemented in a future update of the Learn LVGL book, with examples. I’m working on implementing the recommendations I received elsewhere but I would like to see it here, too. The issue is reading the data from an incremental rotary encoder and the best method for doing so. I have the encoder being read in an interrupt routine, and it works, but I understand it’s not recommended for lvgl due to the possibility of catastrophically corrupting the lvgl program flow with the interrupt. The encoder movement is relatively slow being mounted on the shaft of an arbor press measuring tics and converted to inches for measurement. I’m not seeing a way to fetch the encoder data without losing any tics other than an interrupt routine. My particular encoder produces 2048 tics per 360 degrees of revolution. I have NOT read through the lvgl interrupt functions and there may be something in there that might help. Suggestions or insight?
Hi Tony.
Unfortunately, rotary encoders is a subject I’m not very familiar with.
I still don’t have any tutorials for rotary encoders in our blog.
I think you’ll need to use the rotary encoder as an LVGL input device: https://docs.lvgl.io/9.1/porting/indev.html
Regards,
Sara
I looked that over. The problem is that the input device status or the request for it’s data is said to be ‘called periodically’, which isn’t gonna work. I need to capture every tic from the encoder in order to measure distance accurately. A missed tic from the encoder means lost accuracy. I need to write a small sketch to measure the time between tics at the fastest rate or as fast as I can move the handle on the arbor press. Depending on that speed then maybe a call to read the encoder at two or three times that speed might capture every tic.