PlatformIO Community

Espidf lvgl how to use it

I try to fiddle something new

I installed pio lib install “lvgl/lvgl”
in my platformIO.ini I have

platform = espressif32
board = esp32dev
framework = espidf
lib_deps = lvgl/lvgl@^8.0.0

then the example file

#include "../../lvgl.h"

static lv_obj_t * label;

static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
    if(event == LV_EVENT_VALUE_CHANGED) {
        /*Refresh the text*/
        lv_label_set_text_fmt(label, "%d", lv_slider_get_value(slider));
        lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15);    /*Align below the slider*/

 * Create a slider and write its value on a label.
void lv_example_get_started_3(void)
    /* Create a slider in the center of the display */
    lv_obj_t * slider = lv_slider_create(lv_scr_act(), NULL);
    lv_obj_set_width(slider, 200);                        /*Set the width*/
    lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);    /*Align to the center of the parent (screen)*/
    lv_obj_add_event_cb(slider, slider_event_cb, NULL);         /*Assign an event function*/

    /* Create a label below the slider */
    label = lv_label_create(lv_scr_act(), NULL);
    lv_label_set_text(label, "0");
    lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15);    /*Align below the slider*/


Where is the main_app.c file
I don’t unterstand this concept

How to use this example

LVGL does have a dedicated PlatformIO example at and

Per thread [ESP32] ld: region `dram0_0_seg' overflowed by 156768 bytes there’s also an ESP32+LVGL project at

Thank you maxgerhardt. I fiddled with the windows emulator and lvgl looks promising.

Here I’m again
I try to to make this Project for learning GitHub - lvgl/lv_port_esp32: LVGL ported to ESP32 including various display and touchpad drivers
I do pio run -t menuconfig what is working but you have to use J and K because the arrow keys not working then I try to do Point 5
5. Configure your display and/or touch controllers in Components config->LVGL TFT Display Configuration and Components config->LVGL TOUCH Configuration.
I see all kind of modules but not the LVGL item I installed pio lib install “lvgl/lvgl”
with the platformIO.ini

platform = espressif32
board = esp-wrover-kit
framework = espidf
lib_deps = lvgl/lvgl@^8.0.0

What I have to do to get the LVGL item

Don’t add lvgl as a library when working with ESP-IDF, but as a component, see docs and example. This way the Kconfig file will be read if there is one. (You should also remove the .pio folder after removing it from lib_deps to clear old build artefacts).

I think the topic component is really poor described.
I figured out that with

git submodule add components/lvgl
git submodule update --init --recursive

I can add a lib as component
But when I do this I have the Problem
src/main.c:26:10: fatal error: lvgl.h: No such file or directory
What I have to do that PlatformIO recognizes, lvgl.h
or is my approach wrong ?
I reference to this

Ah, I just tried this and found a caveat that prevented it from working, at least for me.

the REQUIRES main had to be deleted, otherwise it would be giving me "failed to resolve component main" errors.

So, a standard project with Espressif32 Dev module + ESP-IDF + adding lvgl in the components/ folder makes the configuration appear in pio run -t menuconfig.

The src/main.c code

#include "lvgl.h"
void app_main() {

will initially show a include error at lvgl.h, but after one compilation, which is successfull, and a Ctrl+Shift+P → Rebuild IntelliSense it goes away.


1 Like

Also interesting: If I just clone GitHub - lvgl/lv_port_esp32: LVGL ported to ESP32 including various display and touchpad drivers using

git clone --recursive
cd lv_port_esp32
pio init -b esp32dev -O "framework=espidf"
echo [platformio] >> platformio.ini
echo src_dir = main >> platformio.ini
pio run -t menuconfig

on the commandline, I get


This working here :slight_smile: Seems to have something to do with the folder structure, too (main vs src/).

1 Like

Thank you a lot now it’s working

This worked for me as well! Thank you