LVGL Configuration and SquareLine Project Porting
Officially Supported by Espressif Arduino
VIEWE ESP32 Smart Display Dev Board: Officially Supported by Espressif ESP32 Arduino.
One-click core & driver installation, no pin configuration needed, ready to develop in Arduino IDE.
Configuring LVGL
The functionality and parameters of LVGL can be configured by editing the lv_conf.h file, where users can modify macro definitions to update the behavior or default parameters of the driver. Here are some features for configuring LVGL:
-
When using arduino-esp32 v3.x.x version, LVGL will search for the configuration file in the following order:
current project directory>Arduino library directory. If the configuration file is not found, a compilation error indicating the absence of the configuration file will be prompted. Therefore, users need to ensure that at least one directory contains thelv_conf.hfile. -
If multiple projects need to use the same configuration, users can place the configuration file in the Arduino library directory, so that all projects can share the same configuration.
Below are detailed steps for sharing the same LVGL configuration:
-
Navigate to the Arduino library directory.
-
Enter the
lvglfolder, copy thelv_conf_template.hfile, and place the copy at the same level as thelvglfolder. Then, rename the copied file tolv_conf.h. -
Finally, the layout of the Arduino library folder should look like this:
Arduino
|-libraries
|-lv_conf.h
|-lvgl
|-other_lib_1
|-other_lib_2
-
Open the
lv_conf.hfile, and change the first#if 0to#if 1to enable the contents of the file. -
Set other configurations according to requirements. Here are some examples of common configuration options for LVGL v8:
#define LV_COLOR_DEPTH 16 // Typically use 16-bit color depth (RGB565),
// but can also set it to `32` to support 24-bit color depth (RGB888)
#define LV_COLOR_16_SWAP 0 // If using SPI/QSPI LCD (e.g., ESP32-C3-LCDkit), set this to `1`
#define LV_COLOR_SCREEN_TRANSP 1
#define LV_MEM_CUSTOM 1
#define LV_MEMCPY_MEMSET_STD 1
#define LV_TICK_CUSTOM 1
#define LV_ATTRIBUTE_FAST_MEM IRAM_ATTR
// Get higher performance but use more SRAM
#define LV_FONT_MONTSERRAT_N 1 // Enable all internal fonts needed (`N` should be replaced with font size)
- For more information, please refer to the LVGL official documentation.
Porting SquareLine Project
SquareLine Studio (v1.3.x) allows for the rapid design of beautiful UIs through visual editing. If you want to use UI source files exported from SquareLine in the Arduino IDE, you can follow these steps for porting:
-
First, create a new project in SquareLine Studio. Go to
Create->Arduino, selectArduino with TFT-eSPIas the project template, then configure the LCD properties for the target development board in thePROJECT SETTINGSsection, such asResolutionandColor depth. Finally, click theCreatebutton to create the project. -
For existing projects, you can also click on
File->Project Settingsin the navigation bar to enter the project settings. Then, in theBOARD PROPERTIESsection, configureBoard GroupasArduinoandBoardasArduino with TFT-eSPI. Additionally, configure the LCD properties for the target development board in theDISPLAY PROPERTIESsection. Finally, click theSavebutton to save the project settings. -
Once the UI design is complete and the export path is configured, click on
Export->Create Template ProjectandExport UI Filesbuttons in the menu bar to export the project and UI source files. The layout of the project directory will be as follows:Project |-libraries |-lv_conf.h |-lvgl |-readme.txt |-TFT_eSPI |-ui |-README.md |-ui -
Copy the
lv_conf.h,lvgl, anduifolders from thelibrariesfolder in the project directory to the Arduino library directory. If you need to use a locally installedlvgl, skip copyinglvglandlv_conf.h, then refer to the steps in the LVGL Configuration section to configure LVGL. The layout of the Arduino library folder will be as follows:Arduino |-libraries |-ESP32_Display_Panel |-ESP_Panel_Conf.h (optional) |-lv_conf.h (optional) |-lvgl |-ui |-other_lib_1 |-other_lib_2
Can't find what you need?
If you need more support, please watch the video or contact us: