LVGL (9.3.0) MicroPython (1.25.0) + ILI9341 + ESP32-D0WD-V3 (revision v3.1)

Hi all,

i try to use the AZ-Touch MOD set which works with the esp32-weather-station and other sketches so at least i have not f***** the soldering . But anyhow i cant get the display to run .
SPI Initialization always fails or results in a crash . The esp32 used only specified as ESP32S Dev Kit C V4 .

Can somebody give ne a hint on what i missed ?

kind regards,
oliver

This sample code throws no SPI errors but mem-allocation errors

Traceback (most recent call last):
File “”, line 7, in
MemoryError: memory allocation failed, allocating 1075011816 bytes

from micropython import const
import lvgl as lv
from machine import Pin, SPI
import lcd_bus, ili9341
import task_handler

lv.init()

— Pins / constants (AZ-Touch MOD) —

_MOSI = const(23)
_MISO = const(19)
_SCK = const(18)
_LCD_CS = const(5)
_LCD_DC = const(4)
_LCD_RST= const(22)
_BL = const(15)
_WIDTH = const(240)
_HEIGHT = const(320)

— Backlight ON (explicit) —

Pin(_BL, Pin.OUT).value(1)

— SPI host = VSPI (host=2 => SCK=18, MOSI=23, MISO=19) —

spi_bus = SPI.Bus(
host=2,
mosi=_MOSI, miso=_MISO, sck=_SCK
)

— Display bus (start conservative freq) —

display_bus = lcd_bus.SPIBus(
spi_bus=spi_bus,
dc=_LCD_DC,
cs=_LCD_CS,
freq=26_000_000
)

— ILI9341 panel: MUST set color_space = RGB565 —

display = ili9341.ILI9341(
data_bus=display_bus,
display_width=_WIDTH,
display_height=_HEIGHT,
reset_pin=_LCD_RST,
reset_state=ili9341.STATE_LOW,
color_space=lv.COLOR_FORMAT.RGB565, # REQUIRED
# Try these defaults first; adjust below if colors are wrong:
color_byte_order=ili9341.BYTE_ORDER_RGB,
rgb565_byte_swap=False
)

display.set_power(1)
display.init(1) # if white/blank, try display.init(2)
display.set_rotation(0)

Build UI on the active screen (DO NOT screen_load the same screen)

scr = lv.screen_active()
lbl = lv.label(scr); lbl.set_text(“HELLO AZ-TOUCH MOD”); lbl.align(lv.ALIGN.CENTER, 0, -30)
slider = lv.slider(scr); slider.set_size(200, 20); slider.center()

Some builds need the task handler running to flush

th = task_handler.TaskHandler()
print(“Screen built”)

ok this was probs premature …repl with this snipplet made the *****(pardon my french) work

import lvgl as lv
from machine import Pin, SPI
import lcd_bus, ili9341
import task_handler

Pin map (AZ-Touch MOD, working Arduino layout)

SCK, MOSI, MISO = 18, 23, 19 # VSPI (host=2)
DC, CS, RST, BL = 4, 5, 22, 15 # control pins

def init_display(rotation=0, freq=40_000_000, init_table=2):
# 1) Backlight ON - BUT SET TO LOW !!
Pin(BL, Pin.OUT).value(0)

if not lv.is_initialized():
    lv.init()
spi_bus = SPI.Bus(host=2, mosi=MOSI, miso=MISO, sck=SCK)

dbus = lcd_bus.SPIBus(spi_bus=spi_bus, dc=DC, cs=CS, freq=freq)

disp = ili9341.ILI9341(
    data_bus=dbus,
    display_width=240,
    display_height=320,
    reset_pin=RST,
    reset_state=ili9341.STATE_LOW,
    color_space=lv.COLOR_FORMAT.RGB565
)
disp.set_power(1)
disp.init(init_table)     
disp.set_rotation(rotation)

_ = task_handler.TaskHandler()
return disp