ESP32 + ili9341 corrupt display

Hi folk,
After playing around with the lvgl driver form micro python i make it work.
The only problem is the display seem corrupt.
When i use the exemple display of the button centered is not but only on the heigh.
Plus the screen seem to print unwanted black line event after the information is send to the display.

I feel like i should tweak the driver between ili9341 and the LVGL library, but i have no idee on how to do this…

Is someone have any idea on how to fix this.

Hi @Sangito

Please provide more information.

  • What hardware are you using - which board, the exact type of the display etc.
  • Exactly how you wired the display
  • Are you using lv_micropython? Latest? specific version?
  • How did you build lv_micropython (“make” parameters)
  • Some photos that show the problems you are seeing.
  • Any other information you think could be useful.

il use a lolin D32 pro:
For the diplay i use the Lolin TFT-2.4:

i use the lastest version of LV_micropyhton:

commit 01f31ac2371102370e8f33f39153ae5c68fffa1f (HEAD -> master, origin/master, origin/HEAD)
Author: Amir Gonnen <>
Date:   Tue Mar 15 23:25:33 2022 +0200
    Update LVGL
    Also, use usys.print_exception instead of sys.exc_info

I build with the parameter of the tutorial:


Picture of the screen:

the code i use:

import machine
import time
import lvgl as lv

Import ILI9341 driver and initialized it

import ili9XXX
from ili9XXX import ili9341
disp = ili9341(miso=19, mosi=23, clk=18, dc=27, cs=14, rst=33,
power=14, backlight=15, mhz=20,
width=240, height=320, rot=ili9XXX.REVERSE_LANDSCAPE)
print(“Setup LCD”)
scr = lv.obj()
btn = lv.btn(scr)
btn.align_to(lv.scr_act(), lv.ALIGN.CENTER,0,0)
label = lv.label(btn)
label.set_text(“Hello World!”)

Import XPT2046 driver and initalize it

from xpt2046 import xpt2046
touch = xpt2046(cs=12,mhz=5)

led = machine.Pin(5, machine.Pin.OUT)
print(“Pin ready”)
while True:

If it can help i use the display without any probleme with a vanilla micropython 1.18 and and homebrew ili9341 driver, so no electronic wiring problem or display broke problem.

Looks like an orientation issue.
Did you try setting width=320, height=240?
Did you try changing the rot argument to other options? (PORTRAIT, LANDSCAPE, etc.)

Yes and the result it’s so worst i’m not event able to reconize a form.
and i play with the orientation, it work but the display still corrup in another orientation.

I’ve just tried your configuration (with ILI9341 and a different board).
It works fine for me when switching the width/height:

disp = ili9341(dc=32, cs=33, power=-1, backlight=-1, width=320, height=240, rot=REVERSE_LANDSCAPE)

Ok, using the parameter ower=-1 fix some issue.
But something is off screen, but it’s look like related to the config of a screen.
When i aligne the button on the bottom right i lost my buton and it add some scrolling bare…

They all looks good on my screen (with width=320, height=240, rot=REVERSE_LANDSCAPE)
No scrollbar appears, I couldn’t reproduce your problem.

(to make it display correctly I needed to call scr.invalidate() after changing the alignment interactively on the REPL)

  • Please provide a complete script we could run or our side to reproduce your problem
  • Please provide photos of the problems you are seeing on your side.

ok here the way i must do to aligne.
Since the alignment seem to work with the forme but on the center of the form i must size the forme and then offset the alignment with this offset.
but only for the bottom and the right of the screen.
This way the aligne work.

import machine
import esp32
import time
import sdcard
import os
import lvgl as lv

led = machine.Pin(5, machine.Pin.OUT)
print(“Pin ready”)

Import ILI9341 driver and initialized it

import ili9XXX
disp = ili9XXX.ili9341(miso=19, mosi=23, clk=18, dc=27, cs=14, rst=33,
power=-1, backlight=-1, mhz=20,
width=320, height=240, rot=ili9XXX.REVERSE_LANDSCAPE)

Import XPT2046 driver and initalize it

from xpt2046 import xpt2046
touch = xpt2046(cs=12,mhz=5)

main script

def event_handler(evt):
code = evt.get_code()

if code == lv.EVENT.CLICKED:
        print("Clicked event seen")
elif code == lv.EVENT.VALUE_CHANGED:
    print("Value changed seen")

create a simple button

btn1 = lv.btn(lv.scr_act())

attach the callback

btn1.add_event_cb(event_handler,lv.EVENT.ALL, None)


create a toggle button

btn2 = lv.btn(lv.scr_act())

attach the callback

btn2.add_event_cb(event_handler,lv.EVENT.ALL, None)