# LVGL Manual

## [Introduction to LVGL](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/packages-manual/lvgl-docs/introduction?id=lvgl-%e4%bb%8b%e7%bb%8d) <a href="#lvgl-jie-shao" id="lvgl-jie-shao"></a>

[LVGL](https://www.lvgl.io/) is a highly customizable, modern aesthetically pleasing, easy-to-use, open source free embedded graphics library (MIT protocol), founded by Gábor Kiss-Vámosi from Hungary. Currently, the LVGL source code is hosted on [the Github](https://github.com/lvgl/lvgl) platform for maintenance. Under the promotion of community member [Man Jianting](https://github.com/mysterywolf) , the RT-Thread community and the LVGL community have completed the source code docking. The LVGL official Github source code repository has become a software package for RT-Thread. RT-Thread community partners only need to use the Env tool or RT-Studio to pull the latest source code of LVGL and automatically add it to the RT-Thread project.

### [BSP adapted to LVGL](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/packages-manual/lvgl-docs/introduction?id=%e5%b7%b2%e7%bb%8f%e9%80%82%e9%85%8d-lvgl-%e7%9a%84-bsp) <a href="#yi-jing-shi-pei-lvgl-de-bsp" id="yi-jing-shi-pei-lvgl-de-bsp"></a>

[List of BSPs that have been adapted to LVGL](https://docs.lvgl.io/master/get-started/os/rt-thread.html#how-to-run-lvgl-on-rt-thread) | [Explanation video](https://www.bilibili.com/video/BV1YM4y1F7fX)

Both RT-Thread simulators are compatible with LVGL. You can run the LVGL graphics library on the RT-Thread operating system without a development board. In the adapted BSP, users can complete the LVGL configuration and generate a project with one click. After compiling and downloading, the LVGL routines are automatically demonstrated. Please refer to the documentation or (and) the explanation video for how to configure.

### [How to port LVGL to a BSP](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/packages-manual/lvgl-docs/introduction?id=%e5%a6%82%e4%bd%95%e5%b0%86-lvgl-%e7%a7%bb%e6%a4%8d%e5%88%b0%e6%9f%90%e4%b8%aa-bsp) <a href="#ru-he-jiang-lvgl-yi-zhi-dao-mou-ge-bsp" id="ru-he-jiang-lvgl-yi-zhi-dao-mou-ge-bsp"></a>

For the transplant template, please refer to [Zhengdian Atom STM32L475 Pandora](https://github.com/RT-Thread/rt-thread/tree/master/bsp/stm32/stm32l475-atk-pandora/applications/lvgl) | [STM32F469 Discovery](https://github.com/RT-Thread/rt-thread/tree/master/bsp/stm32/stm32f469-st-disco/applications/lvgl) | [Nuvoton series](https://github.com/RT-Thread/rt-thread/blob/master/bsp/nuvoton/docs/LVGL_Notes.md)

There are three LVGL configuration files:

| Profile Name           | Location                                                                                                                                    | Function                                                                                             | Do users need to modify this file?                                              |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| lv\_conf\_internal.h   | [LVGL side](https://github.com/lvgl/lvgl/blob/master/src/lv_conf_internal.h)                                                                | Sets features not configured by the user to default                                                  | unnecessary                                                                     |
| lv\_rt\_thread\_conf.h | [LVGL side](https://github.com/lvgl/lvgl/blob/master/env_support/rt-thread/lv_rt_thread_conf.h)                                             | Take over the configuration related to the operating system (such as time base signal, memory, etc.) | unnecessary                                                                     |
| lv\_conf.h             | RT-Thread side: [Reference](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_conf.h) | User-defined configuration                                                                           | The user needs to create it in the applications/lvgl folder of the specific BSP |

From the table above, we can see that although there are three configuration files, only the last one actually requires user intervention. That is, the user needs to create an lvgl folder in the applications folder of the BSP. This folder is used to store lvgl-related files. The content is as follows:

| File name                          | effect                                                                                                                                                                                                                                                                                                                                                                                                             |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| lv\_conf.h                         | User-defined configuration of LVGL function (the file name cannot be changed randomly)                                                                                                                                                                                                                                                                                                                             |
| lv\_port\_disp.c                   | LVGL display interface file,  `void lv_port_disp_init(void)`initialize the content related to the interface with the LVGL display framework in the function (this function must exist). [Official manual reference](https://docs.lvgl.io/master/porting/display.html)  \| [transplant reference](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_disp.c) |
| lv\_port\_indev.c                  | LVGL input device docking file,  `void lv_port_indev_init(void)`initialize the content related to docking with the LVGL input device framework in the function (this function must exist). [Official manual reference](https://docs.lvgl.io/master/porting/indev.html)  \| [Porting reference](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.c)  |
| User interface initialization file | [Call](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/stm32f469-st-disco/applications/lvgl/demo/lv_demo.c) the function you want to initialize in `void lv_user_gui_init(void)` the function (the function must exist), and LVGL will automatically call the function during initialization.                                                                                                         |

> Since RT-Thread version 4.1.1 (including 4.1.1), users no longer need to create `lv_port_disp.h`and `lv_port_indev.h`files.

Users do not need to worry about LVGL initialization. LVGL will be automatically initialized by RT-Thread when the device is powered on. It will also automatically call `lv_port_disp_init`and `lv_port_indev_init`to initialize the user's display screen, input device driver and interface drawing function. These initialization tasks have been automatically initialized in the [lv\_rt\_thread\_port.c](https://github.com/lvgl/lvgl/blob/master/env_support/rt-thread/lv_rt_thread_port.c)`lv_user_gui_init` file on the LVGL side .

As for whether to connect the RT-Thread display device framework and the touch framework, users can freely deal with it. If you do not want to connect the RT-Thread display and touch framework, you can directly connect the driver to the connection function on the LVGL side [.](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_disp.c)

### [Ask a Question](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/packages-manual/lvgl-docs/introduction?id=%e6%8f%90%e9%97%ae) <a href="#ti-wen" id="ti-wen"></a>

* If you encounter any issues related to porting, please go to the RT-Thread community forum to ask questions: <https://club.rt-thread.org/index.html>
* If you encounter any problems with LVGL, please go to the LVGL community forum to ask questions (please use English): <https://forum.lvgl.io/>
