No callback using xpt2046.c

Using
esp-idf v4.1
lv_micropython dev
micropython v1.14

CALLBACK FOR SCREEN NOT WORKING

ILI9341.c and xpt2046.c initialize.
When touching screen I received x and y from
printf(“data: x = %d, y = %d\n”, data->point.x, data->point.y);
that was placed in xpt2046.c file.
But def touch_event() is not called

import utime
from machine import Pin, SPI
import lvgl as lv
# import lvesp32
import ILI9341 as ili
from xpt2046 import xpt2046

lv.init()
vspi = SPI(2, miso=Pin(19), mosi=Pin(23), sck=Pin(18))

disp = ili.display(spihost=2, miso=19, mosi=23, clk=18, cs=15, \
dc=13, rst=0, backlight=27, mhz=20) 
disp.init()

disp_buf1 = lv.disp_buf_t()
buf1_1 = bytearray(320*10)
disp_buf1.init(buf1_1, None, len(buf1_1) //4)
disp_drv = lv.disp_drv_t()
disp_drv.init()
disp_drv.buffer = disp_buf1
disp_drv.flush_cb = disp.flush
disp_drv.hor_res = 240
disp_drv.ver_res = 320
disp_drv.register()

touch = xpt2046(spihost=2, cs=5, irq=4, mhz=5, \
x_inv=False, y_inv=True, x_min=240, y_min=320)
touch.init()

indev_drv = lv.indev_drv_t()
indev_drv.init()
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = touch.read	
indev_drv.register()

# -----------------------------------------------------------------------------
tp_irq = Pin(4, Pin.IN)
def touched(pin):		
	# works... print stament from xpt2046.c (data: x = 132, y = 74)
	for _ in range(5):
		lv.tick_inc(2)
		lv.task_handler()
		utime.sleep_ms(10)

def touch_event(obj, event):
	# not called
	if event == lv.EVENT.RELEASED:
		p = lv.point_t()
		lv.indev_get_point(lv.indev_get_next(None), p)
		l.set_text("x=%d, y=%d" % (p.x, p.y))
		l.align(scr, lv.ALIGN.CENTER, 0, 0)
		print("x=%d, y=%d" % (p.x, p.y))

# -----------------------------------------------------------------------------
scr = lv.scr_act()

t_scrn = lv.obj(scr, None)
t_scrn.set_size(scr.get_width(), scr.get_height()) # touch anywhere on screen
t_scrn.set_event_cb(touch_event)
l = lv.label(scr, None)
l.set_text("p o s i t i o n")
l.align(scr, lv.ALIGN.CENTER, 0, 0)

tp_irq.irq(trigger=Pin.IRQ_FALLING, handler=touched)
lv.task_handler()

I also tried from samples…

indev_drv = lv.indev_drv_t()
lv.indev_drv.init(indev_drv)    # AttributeError: 'module' object has no attribute 'indev_drv'
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = touch.read  
lv.indev_drv.register(indev_drv)  # AttributeError: 'module' object has no attribute 'indev_drv'

I get run errors.

Does it work for you with the Python driver?
You may need to uncomment import lvesp32

According to this post, they want to use the C drivers because of that SPI sharing issue from a while back.

Still, would be interesting to know if the same code on the same HW works or not with the Python driver. That could hint if the problem is related to the C driver or to something else.

YES

I removed the comment on lvesp32 for .c driver,
still no response from touch.

The reason I comment out lvesp32 is to stop the background scheduling !!
Bluetooth scan will freezes after some time with lvesp32 enabled.
I manually updated screen when needed with lv.task_handler() and
no longer have Bluetooth lockup issues.

Q. can the ili9341.c and xpt2046.c be converted to .mpy ?

Do you mean if they can be re-written in Python?
Probably, but we already have Python drivers so it makes more sense to support them instead of creating new Python drivers that do the same thing.

Personally I’m not using the C drivers so they are no so well maintained. I’m relying on the Python drivers.