Use lvgl in vscode/platformio

Hello,
I build a protect using

Vscode + platformio on a windows 10 pc

I copied all the lvgl source folders version 6.1.2
I configured lv_conf.h
All compiles fine

I now want to use lvgl without copying the whole source folder in my project. To do that, I edited platformio.ini file, and added lvgl@6.1.2 in the library dependencies section, did define LVGL_CONFIG_SIMPLE in platformio.Ini, and also added -I lib/ so the compiler will find lv_conf.h file

I get a number of errors at compile time … what did I foregot or made wrong?

What errors are you getting?

I have this in platformio.ini :

build_flags = ${common.build_flags} -std=gnu++14 -I lib
#This is to be sure the compiler will find lv_conf.h located in lib directory. there is no lgvl.h there.
-DLV_CONF_INCLUDE_SIMPLE

lib_deps =
lvgl@v6.1.2

and the error I get is :
lvgl_Glue.cpp:19:8: error: ‘lv_disp_buf_t’ does not name a type

lvgl_Glue.cpp:20:8: error: ‘lv_color_t’ does not name a type; did you mean ‘xy_char_t’?
static lv_color_t buf_1[LV_HOR_RES_MAX * LINES]; /A buffer for LINES rows/

Do I need to have #include"lvgl.h" anywhere??? I use to have them, but if we use the platformio library manager, where does this need to point to? Where is lvgl.h file?

I know this is a very beginner question, but I am stuck on this simple issue. The lib works perfectly when I copy all the source files in my project.

thanks for your help.

The PlatformIO library manager just keeps track of the library folder for you. You’re still expected to include lvgl.h. I don’t know if PlatformIO detects the include paths for libraries automatically or not.

Hi
I played around with all the included and options, but still cannot get my code to compile using the platformio library manager for lvgl.
Code works with all lvgl sources copied in my project

Will keep it like that but would be great if a person with good platformio knowledge could explain how to do this…

Cheers.

You can try comparing your settings to those of the official PlatformIO project and see if there’s any differences.

Hi,
Thanks for the tip.
I see in the include file demo.h the way they do it :
#ifdef LV_CONF_INCLUDE_SIMPLE
#include <lvgl.h>
#else
#include “…/…/…/lvgl/lvgl.h”
#endif

I will try to replicate all, including exact folder names…

Just faced the same requirement and since there is no conclusion in this thread, here it is for the record. It is based on information I found in this thread.

Using platformio managed lvgl is very simple.

  1. Move your lv_conf.h to the platformio src directory of your project (I place all my .h and .c there).

  2. Add this line to your platformio.ini (This one locks a specific version, check platform io for syntax for other version rules.).

lib_deps = lvgl/lvgl@7.9.1
  1. Have these two build flags in paltformio.ini
build_flags = 
     .....
     -D LV_CONF_INCLUDE_SIMPLE
     -I src