How to read touch using interrupt?

Hello,

I found the functions

/* Update the input device’s running mode to LV_INDEV_MODE_EVENT */
lv_indev_set_mode(indev, LV_INDEV_MODE_EVENT);

And

/* Call this anywhere you want to read the input device */
lv_indev_read(indev);

I tried to execute the function lv_indev_read(indev) inside the interrupt routine but it didn’t work.

https://docs.lvgl.io/9.3/details/main-modules/indev.html

The touch is the CST820, and the data reading needs to be synchronized with the interrupt to be valid data. Otherwise, ghost touches occur.

Maybe you missunderstand , what this do. Calling this inoke callback to read manualy and all read is in this callback func for both modes. Simply leave in periodic mode and in callback use

if(isinterrupt) {

}
...

Hello, I managed to do it, but it wasn’t this way (just reading the state of the interrupt pin).

Code:

Thanks.

You set the indev mode to “EVENT” and handle calling the indev_read\ function yourself. Be careful because you don’t want to call that function from inside of the ISR callback because of memory allocation occurring. You will need to send some kind of a flag or signal to the main task that is handling LVGL related stuff and have it perform the read of the indev. This means that in the interrupt callback you will need to collect whatever information is needed form the touch IC and store it so in the indev callback function for read you can return that data.

Hello, it was not possible to read the data in the interruption (I2C), there is a problem with the LVGL. But it was possible to increment a variable and monitor it in the Arduino IDE sketch Loop, and only then call the manual reading.

Since the interval between interrupts is approximately 37ms, I believe that no data should be lost.