Modulo Esp32-2432S08 (ili9341+xpt2046) problem touch

Hello everyone, I have encountered the following issue. I have compiled the firmware for the ESP32-2432S08 module , and I have managed to get the display working, but I am unable to make the touchscreen function. Here is my code:

import lvgl as lv
import espidf as esp

from ili9XXX import ili9341
from xpt2046 import xpt2046

lv.init()


disp = ili9341(spihost=esp.HSPI_HOST, miso=12, mosi=13, clk=14, cs=15, mhz=10, width=240, height=320, dc=2, rst=-1, power=-1, factor=8, backlight=21, backlight_on=1)

touch = xpt2046(miso=39, mosi=32, cs=25, spihost=esp.HSPI_HOST, mhz=5, max_cmds=16)

scr = lv.obj()
btn = lv.button(scr)
btn.align(lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text('Hello World!')
lv.screen_load(scr)
    

It produces the following error.:

Traceback (most recent call last):
File “main.py”, line 13, in
File “xpt2046.py”, line 29, in init
AttributeError: ‘lv_display_t’ object has no attribute ‘get_hor_res’

I hope you can help me. Thank you.

Hello!
That’s a bug in that file. There were renamings in LVGL (v8 → v9), and some of these renamings are not applied to MicroPython binding.
I will fix it, and check other files, too.
Thanks for reporting it!

Bug fixed (PR: update lv_bindings by PGNetHun · Pull Request #79 · lvgl/lv_micropython · GitHub )

Please pull again lv_micropython, rebuild, and check whether it works.

Thank you for your solution, that problem was fixed. But I have another problem with the touch xpt2046, I can’t get it to work

import lvgl as lv
import espidf as esp

lv.init()

# Import ILI9341 driver and initialized it

from ili9XXX import ili9341
disp = ili9341(miso=12,
               mosi=13,
               clk=14,
               cs=15,
               dc=2,
               rst=-1,
               power=-1,
               backlight=21,
               backlight_on=1,
               spihost=esp.HSPI_HOST,
               spimode=0,
               width=240,
               height=320,
               mhz=40,
               factor=4,
               hybrid=True,
               half_duplex=True,)

# Import XPT2046 driver and initalize it

from xpt2046 import xpt2046
touch = xpt2046(miso=39,
                mosi=32,
                clk=25,
                cs=33,
                spihost=esp.HSPI_HOST,
                mhz=2,
                max_cmds=16,
                cal_x0 = 3783,
                cal_y0 = 3948,
                cal_x1 = 242,
                cal_y1 = 423,
                transpose = True,
                half_duplex=True,
                samples = 3)

def button_cb(e):
    print(f"lv.EVENT: {e.get_code()}")


scr = lv.obj()
btn = lv.button(scr)
btn.align(lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text('Hello World!')
lv.screen_load(scr)
    

I’m getting the following error. I’ve tried all the possible combinations but I can’t find the solution. I see the button on the screen but I don’t have touch

E (1340) spi: spi_bus_initialize(756): SPI bus already initialized.
Traceback (most recent call last):
File “main.py”, line 35, in
File “xpt2046.py”, line 58, in init
File “xpt2046.py”, line 113, in spi_init
RuntimeError: Failed initializing SPI bus

I hope you can guide me. Thank you

Change the host for the touch driver to VSPI. You are trying to initialize 2 different busses to the same host and that’s not gonna work.