No response from touch xpt2046.c

IRQ pin goes low but no reaction from xpt2046.c .
Have print stamens throughout xpt2046.c… nothing.
What is the chain of events for a button touch…
Manually updating using lv.task_handler().
Also tested with lv.task_handler() in a while loop… nothing?

The Micropython modxpt2046.c is based on xpt2046 driver from lv_drivers.
It’s the same driver, with Micropython API.

I suggest you experiment with the original C driver and see if the problem is there as well, or if this problem is specific to the Micropython driver.

If I remember correctly, this driver does not really use IRQ as an interrupt, it just sample the touch panel when xpt2046_read is called.
xpt2046_read is supposed to be registered as a callback in lvgl indev.

Where does this call come from?

The xpt2046 Micropython class, exposed by modxpt2046.c, has these member functions:

  • init
  • deinit
  • activate
  • read

You are expected to

  • Call init, activate, deinit when needed.
  • Create an lv.indev_drv_t object, initialize it, update it’s members.
  • Register read as the read_cb member of an indev driver.
  • Call the indev_drv_t register function.

As described in the docs regarding Input device interface.

Once you registered the driver, xpt2046_read is called by lvgl when it queries its input devices.

image
Does this look correct?

Using… lv.task_handler()?

Yes, it looks correct.

Indirectly, yes.
The entire lvgl functionality is driven by calls to task_handler().
This includes rendering the display and querying the input devices.

In xpt2046 I have a print statement at this location…

If I execute… lv.task_handler() should I see this print out?

Yes, if lvgl was initialized and some screen created.
Did you call lv.init()? Did you create a screen and some object?
Do you also call lv_tick_inc?

YES

YES

YES

if I understand correctly… this is only needed for animations.

I just want a Serial Set of Events
touch… what button was pressed… run a function… update display.

This is a issue continued from BLE issue with xpt2046.py touch driver

I need an interrupt to start a chain of events vs a loop looking for changes and is causing collisions with other functions.

lv_tick_inc must be called for things to get processed properly. It’s used for lots of other things besides animations.

If you don’t care about animations you can call it extremely infrequently (e.g. every 100 ms), but it needs to be called so the library has a way of keeping track of time.

Alternatively, if ESP32 already has a tick feature available, it’s normally possible in C to set up LVGL to make use of that and not require lv_tick_inc. I don’t know how to do this with MicroPython though.