Hello everyone!
This question is frequently asked, but none of the provided answers worked for me.
I’ve got ESP32 2432S028 board - link and want to get the touch response.
This is my main.py
script. I left in the comments some of the approaches I’ve tried for reference.
import sys
from machine import Pin, SPI
from ili9XXX import ili9341
import lvgl as lv
lv.init()
disp = ili9341(clk=14, cs=15, dc=2, rst=12, power=23, backlight=21, miso=12, mosi=13,rot=0x20,width=320, height=240,backlight_on=1)
spi2=SPI(2,baudrate=2500000,mosi=Pin(32),miso=Pin(39))
from xpt2046 import xpt2046
touch = xpt2046(spihost=2,clk=25,cs=33)
# touch = xpt2046()
# touch = xpt2046(cs=5)
# touch = xpt2046(cs=21)
# touch = xpt2046(cs=33)
# touch = xpt2046(spihost=1,cs=36)
# touch = xpt2046(spihost=2, cs=5)
# touch = xpt2046(spihost=2,cs=33)
# touch = xpt2046(spihost=2,clk=25,cs=33)
# touch = xpt2046(spihost=2,mosi=32,miso=39,clk=25,cs=33)
# touch = xpt2046(cal_x0=3799, cal_x1 = 353, cal_y0=220, cal_y1 = 3719,transpose = False)
print(f"Python version: {sys.version_info}")
def button_cb(e):
print(f"lv.EVENT: {e.get_code()}")
scr = lv.scr_act()
btn = lv.btn(scr)
label = lv.label(btn)
label.set_text("Button")
btn.align(lv.ALIGN.CENTER,0,0)
btn.add_event(button_cb, lv.EVENT.ALL, None)
lv.scr_load(scr)
Terminal output:
>>> ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4344
load:0x40078000,len:13816
load:0x40080400,len:3340
entry 0x40080618
Single buffer
ILI9341 initialization completed
Enable backlight
Python version: (3, 4, 0)
MicroPython v1.20.0-700-g841ece132-dirty on 2023-10-03; ESP32 module with ESP32
Type "help()" for more information.
>>>
>>>
MicroPython v1.20.0-700-g841ece132-dirty on 2023-10-03; ESP32 module with ESP32
Type "help()" for more information.
>>> lv.EVENT: 35
lv.EVENT: 45
lv.EVENT: 45
lv.EVENT: 42
lv.EVENT: 45
lv.EVENT: 45
lv.EVENT: 20
lv.EVENT: 45
lv.EVENT: 45
lv.EVENT: 21
lv.EVENT: 27
lv.EVENT: 28
lv.EVENT: 22
lv.EVENT: 23
lv.EVENT: 24
lv.EVENT: 25
lv.EVENT: 26
lv.EVENT: 21
lv.EVENT: 27
lv.EVENT: 28
lv.EVENT: 22
lv.EVENT: 23
lv.EVENT: 24
lv.EVENT: 25
lv.EVENT: 26
>>>
All of the above lv.EVENT
s were displayed during the boot; when I touch the screen, nothing happens.
Any ideas are greatly appreciated!