Landscape not available with ILI9341 and ESP32?

Hi all,
I’m on quite a steep learning curve here during country lockdown. In the past I was only using arduino IDE, but now I learned ESP32, lvgl, python, github, and now micropython. So far so good.
But now I run in something stupid. After successfully building and downloading lv_micropython I can write code and design nice screens, but ONLY in portrait. I found a post about changing to landscape, but this doesn’t seem to work. When I try to use landscape mode I always get this:

AttributeError: type object ‘ili9341’ has no attribute ‘LANDSCAPE’

I tried it with ili9XXX, ili9341, directly MADCTL_MV, but so far no luck.
Can anyone point me in the right direction?

import lvgl as lv
import lvesp32
from ili9XXX import ili9341

disp = ili9341(
    mhz=40,
    factor=4,
    hybrid=True,
    rot=ili9341.LANDSCAPE,
    width=320,
    height=240
)

Hi @bvlet!

The best thing to do when you are not sure about the syntax, is examine the sources.
The LANDSCAPE constant is defined in ili9XXX.py so you can simply:

 from ili9XXX import ili9341, LANDSCAPE

When you say “no luck” do you mean that you get the same error when running the code? Other errors? Or do you mean that it runs without errors but does not do what you expect?

Sorry for my late reply, I was a bit busy last two days.
But I’m very thankful for your post! Because in the end the only thing I forgot to do was, to put “LANDSCAPE” in the import. After I did this, everything worked fine, and the syntax I used was correct after all.

I can’t believe I missed this point, I must have had some tunnel vision looking only at the initialization code. I kept getting the AttributeError in the REPL. I would’ve thought that

rot=ili9341.LANDSCAPE

would do the same, but apparently not…

Thank you very much, I can go on now :slight_smile: