Adding LVGL to an existing ESP32 ESP-IDF Platform IO Project

Hey everyone,

I have an existing project built using Platform IO that I want to use LVGL in. I have an IL9341 display hooked up to a custom ESP32 based board. I’ve cloned the lv_port_esp32 repository, have converted it to a Platform IO project using the instructions provided at this link and have managed to get the demo programs working well - however I’ve hit a bit of a road block when trying to get my existing project to just build with LVGL.

I’ve tried to following:

  • Add lvgl and lvgl_esp32_drivers as git submodules - I get build errors referring to not finding “main” (my main.cpp file is located in src rather than main).
  • Add lvgl as a lib_deps and lvgl_esp32_drivers as a git submodule - I get errors saying lvgl_conf.h doesn’t exist and menuconfig doesn’t show any LVGL component to configure. As I understand it I shouldn’t need lvgl_conf.h because of the KConfig files included? (not 100% sure on that one).

I personally prefer to work inside the Platform IO domain in terms of managing dependencies etc. as it makes working across different developers a lot easier. I’ve been trawling the forums and previously closed issues as there’s a wealth of information but a lot of the examples that use Platform IO use the Arduino framework rather than the IDF.

Any help would be greatly appreciated!

UPDATE
So I managed to deal with some of the issues above. I ended up adding lvgl and lvgl_esp32_drivers to my platform.ini file like so:

lib_deps = lvgl@7.11.0
           lvgl_esp32_drivers=https://github.com/lvgl/lvgl_esp32_drivers

I changed my source directory folder to main and added src_dir = main to my platform.ini file. I also suspect that CMake doesn’t know to look in the libdeps folder for components and so I added it as an additional component directory in my root CMakeLists.txt file:

list(APPEND EXTRA_COMPONENT_DIRS .pio/libdeps/esp32dev)

I’m now getting errors when trying to build the EVE_commands file in lvgl_tft. I don’t think the file is the issue and it’s more my build config that’s causing the problem. Again, any insight into this would be really helpful.

1 Like

Greetings,

I don’t have a solution to your particular problem, but it sounds like you have the solution to mine…

I have a post in this forum entitled “How do I set up lv_platformio with lv_port_esp32?” (Sadly, this forum does not allow links for some reason).

I am trying to get some kind of demo going on my ESP32 and an ILI9844 display. You mention that you’ve managed to get the demo programs working well. Is there anywhere I can download your demo source code?

We have been hit by a number of spam posts in the past, so the forum is configured to block most links to other sites for new users. However, it shouldn’t be blocking self-domain links. I’ll check the settings.

Hey I just followed the steps I linked in the in my initial post (here). Don’t forget to run menuconfig to select the right display driver and your pinout.

I cannot run idf.py menuconfig:

$ idf.py menuconfig
bash: idf.py: command not found...

Do you know where PlatformIO puts the idf.py script?

It should be under project tasks in Platform IO
image

Fantastic! I got it working. Thanks!

So, I managed to add LVGL to an (admittedly small) existing PlatformIO project. You can see the result at https://github.com/spierepf/ESP32-SmartScale

Basically, I tried to make the project look like https://github.com/lvgl/lv_port_esp32

  • I renamed the src folder to main and played around with CMakeLists.txt and component.mk to get things to compile.
  • Then I created a components directory and added git submodules for lvgl and lvgl_esp32_drivers making sure to use the v7 release of lvgl
  • Finally I added snippets of code from lv_port_esp32 starting from
xTaskCreatePinnedToCore(guiTask, "gui", 4096*2, NULL, 0, NULL, 1);

until I got things to compile, focusing on the “hello world” example in create_demo_application

Then of course I had to run Menuconfig as you pointed out, and it all worked!

I hope this helps you, otherwise, post a reply and we’ll see what us noobs can do :slight_smile:

Hey spierepf,

The question I was mainly asking was getting a project running using Platform IO’s library management rather than git submodules. I ended up using git submodules in the end. Thanks though.