1 2# Introduction 3 4LVGL (Light and Versatile Graphics Library) is a free and open-source graphics library providing everything you need to create an embedded GUI with easy-to-use graphical elements, beautiful visual effects and a low memory footprint. 5 6 7## Key features 8- Powerful building blocks such as buttons, charts, lists, sliders, images, etc. 9- Advanced graphics with animations, anti-aliasing, opacity, smooth scrolling 10- Various input devices such as touchpad, mouse, keyboard, encoder, etc. 11- Multi-language support with UTF-8 encoding 12- Multi-display support, i.e. use multiple TFT, monochrome displays simultaneously 13- Fully customizable graphic elements with CSS-like styles 14- Hardware independent: use with any microcontroller or display 15- Scalable: able to operate with little memory (64 kB Flash, 16 kB RAM) 16- OS, external memory and GPU are supported but not required 17- Single frame buffer operation even with advanced graphic effects 18- Written in C for maximal compatibility (C++ compatible) 19- Simulator to start embedded GUI design on a PC without embedded hardware 20- Binding to MicroPython 21- Tutorials, examples, themes for rapid GUI design 22- Documentation is available online and as PDF 23- Free and open-source under MIT license 24 25## Requirements 26Basically, every modern controller which is able to drive a display is suitable to run LVGL. The minimal requirements are: 27<ul> 28<li> 16, 32 or 64 bit microcontroller or processor</li> 29<li>> 16 MHz clock speed is recommended</li> 30<li> Flash/ROM: > 64 kB for the very essential components (> 180 kB is recommended)</li> 31<li> RAM: 32 <ul> 33 <li> Static RAM usage: ~2 kB depending on the used features and object types</li> 34 <li> Stack: > 2kB (> 8 kB is recommended)</li> 35 <li> Dynamic data (heap): > 4 KB (> 48 kB is recommended if using several objects). 36 Set by <em>LV_MEM_SIZE</em> in <em>lv_conf.h</em>. </li> 37 <li> Display buffer: > <em>"Horizontal resolution"</em> pixels (> 10 × <em>"Horizontal resolution"</em> is recommended) </li> 38 <li> One frame buffer in the MCU or in an external display controller</li> 39 </ul> 40</li> 41<li> C99 or newer compiler</li> 42<li> Basic C (or C++) knowledge: 43 <a href="https://www.tutorialspoint.com/cprogramming/c_pointers.htm">pointers</a>, 44 <a href="https://www.tutorialspoint.com/cprogramming/c_structures.htm">structs</a>, 45 <a href="https://www.geeksforgeeks.org/callbacks-in-c/">callbacks</a>.</li> 46</ul> 47<em>Note that memory usage may vary depending on architecture, compiler and build options.</em> 48 49## License 50The LVGL project (including all repositories) is licensed under [MIT license](https://github.com/lvgl/lvgl/blob/master/LICENCE.txt). 51This means you can use it even in commercial projects. 52 53It's not mandatory, but we highly appreciate it if you write a few words about your project in the [My projects](https://forum.lvgl.io/c/my-projects/10) category of the forum or a private message to [lvgl.io](https://lvgl.io/#contact). 54 55Although you can get LVGL for free there is a massive amount of work behind it. It's created by a group of volunteers who made it available for you in their free time. 56 57To make the LVGL project sustainable, please consider [contributing](/CONTRIBUTING) to the project. 58You can choose from [many different ways of contributing](/CONTRIBUTING) such as simply writing a tweet about you using LVGL, fixing bugs, translating the documentation, or even becoming a maintainer. 59 60## Repository layout 61All repositories of the LVGL project are hosted on GitHub: https://github.com/lvgl 62 63You will find these repositories there: 64- [lvgl](https://github.com/lvgl/lvgl) The library itself with many [examples](https://github.com/lvgl/lvgl/blob/master/examples/) and [demos](https://github.com/lvgl/lvgl/blob/master/demos/). 65- [lv_drivers](https://github.com/lvgl/lv_drivers) Display and input device drivers 66- [blog](https://github.com/lvgl/blog) Source of the blog's site (https://blog.lvgl.io) 67- [sim](https://github.com/lvgl/sim) Source of the online simulator's site (https://sim.lvgl.io) 68- [lv_port_...](https://github.com/lvgl?q=lv_port&type=&language=) LVGL ports to development boards or environments 69- [lv_binding_..](https://github.com/lvgl?q=lv_binding&type=&language=l) Bindings to other languages 70 71## Release policy 72 73The core repositories follow the rules of [Semantic versioning](https://semver.org/): 74- Major versions for incompatible API changes. E.g. v5.0.0, v6.0.0 75- Minor version for new but backward-compatible functionalities. E.g. v6.1.0, v6.2.0 76- Patch version for backward-compatible bug fixes. E.g. v6.1.1, v6.1.2 77 78Tags like `vX.Y.Z` are created for every release. 79 80### Release cycle 81- Bug fixes: Released on demand even weekly 82- Minor releases: Every 3-4 months 83- Major releases: Approximately yearly 84 85### Branches 86The core repositories have at least the following branches: 87- `master` latest version, patches are merged directly here. 88- `release/vX.Y` stable versions of the minor releases 89- `fix/some-description` temporary branches for bug fixes 90- `feat/some-description` temporary branches for features 91 92 93### Changelog 94 95The changes are recorded in [CHANGELOG.md](/CHANGELOG). 96 97### Version support 98Before v8 the last minor release of each major series was supported for 1 year. 99Starting from v8, every minor release is supported for 1 year. 100 101| Version | Release date | Support end | Active | 102|---------|--------------|-------------|--------| 103| v5.3 | Feb 1, 2019 |Feb 1, 2020 | No | 104| v6.1 | Nov 26, 2019 |Nov 26, 2020 | No | 105| v7.11 | Mar 16, 2021 |Mar 16, 2022 | No | 106| v8.0 | 1 Jun, 2021 |1 Jun, 2022 | Yes | 107| v8.1 | 10 Nov, 2021 |10 Nov, 2022 | Yes | 108| v8.2 | 31 Jan, 2022 |31 Jan, 2023 | Yes | 109| v8.3 | In progress | | | 110 111## FAQ 112 113### Where can I ask questions? 114You can ask questions in the forum: [https://forum.lvgl.io/](https://forum.lvgl.io/). 115 116We use [GitHub issues](https://github.com/lvgl/lvgl/issues) for development related discussion. 117You should use them only if your question or issue is tightly related to the development of the library. 118 119Before posting a question, please ready this FAQ section as you might find answer to your issue here too. 120 121### Is my MCU/hardware supported? 122Every MCU which is capable of driving a display via parallel port, SPI, RGB interface or anything else and fulfills the [Requirements](#requirements) is supported by LVGL. 123 124This includes: 125- "Common" MCUs like STM32F, STM32H, NXP Kinetis, LPC, iMX, dsPIC33, PIC32, SWM341 etc. 126- Bluetooth, GSM, Wi-Fi modules like Nordic NRF and Espressif ESP32 127- Linux with frame buffer device such as /dev/fb0. This includes Single-board computers like the Raspberry Pi 128- Anything else with a strong enough MCU and a peripheral to drive a display 129 130### Is my display supported? 131LVGL needs just one simple driver function to copy an array of pixels into a given area of the display. 132If you can do this with your display then you can use it with LVGL. 133 134Some examples of the supported display types: 135- TFTs with 16 or 24 bit color depth 136- Monitors with an HDMI port 137- Small monochrome displays 138- Gray-scale displays 139- even LED matrices 140- or any other display where you can control the color/state of the pixels 141 142See the [Porting](/porting/display) section to learn more. 143 144### LVGL doesn't start, randomly crashes or nothing is drawn on the display. What can be the problem? 145- Try increasing `LV_MEM_SIZE`. 146- Be sure `lv_disp_drv_t`, `lv_indev_drv_t` and `lv_fs_drv_t` are global or `static`. 147- Be sure your display works without LVGL. E.g. paint it to red on start up. 148- Enable [Logging](porting/log) 149- Enable asserts in `lv_conf.h` (`LV_USE_ASSERT_...`) 150- If you use an RTOS 151 - increase the stack size of the task which calls `lv_timer_handler()` 152 - Be sure you used a mutex as [described here](/porting/os) 153 154### My display driver is not called. What have I missed? 155Be sure you are calling `lv_tick_inc(x)` in an interrupt and `lv_timer_handler()` in your main `while(1)`. 156 157Learn more in the [Tick](/porting/tick) and [Timer handler](/porting/timer-handler) sections. 158 159### Why is the display driver called only once? Only the upper part of the display is refreshed. 160Be sure you are calling `lv_disp_flush_ready(drv)` at the end of your "*display flush callback*". 161 162### Why do I see only garbage on the screen? 163Probably there a bug in your display driver. Try the following code without using LVGL. You should see a square with red-blue gradient. 164 165```c 166#define BUF_W 20 167#define BUF_H 10 168 169lv_color_t buf[BUF_W * BUF_H]; 170lv_color_t * buf_p = buf; 171uint16_t x, y; 172for(y = 0; y < BUF_H; y++) { 173 lv_color_t c = lv_color_mix(LV_COLOR_BLUE, LV_COLOR_RED, (y * 255) / BUF_H); 174 for(x = 0; x < BUF_W; x++){ 175 (*buf_p) = c; 176 buf_p++; 177 } 178} 179 180lv_area_t a; 181a.x1 = 10; 182a.y1 = 40; 183a.x2 = a.x1 + BUF_W - 1; 184a.y2 = a.y1 + BUF_H - 1; 185my_flush_cb(NULL, &a, buf); 186``` 187 188### Why do I see nonsense colors on the screen? 189Probably LVGL's color format is not compatible with your display's color format. Check `LV_COLOR_DEPTH` in *lv_conf.h*. 190 191If you are using 16-bit colors with SPI (or another byte-oriented interface) you probably need to set `LV_COLOR_16_SWAP 1` in *lv_conf.h*. 192It swaps the upper and lower bytes of the pixels. 193 194### How to speed up my UI? 195- Turn on compiler optimization and enable cache if your MCU has it 196- Increase the size of the display buffer 197- Use two display buffers and flush the buffer with DMA (or similar peripheral) in the background 198- Increase the clock speed of the SPI or parallel port if you use them to drive the display 199- If your display has an SPI port consider changing to a model with a parallel interface because it has much higher throughput 200- Keep the display buffer in internal RAM (not in external SRAM) because LVGL uses it a lot and it should have a fast access time 201 202### How to reduce flash/ROM usage? 203You can disable all the unused features (such as animations, file system, GPU etc.) and object types in *lv_conf.h*. 204 205If you are using GCC/CLANG you can add `-fdata-sections -ffunction-sections` compiler flags and `--gc-sections` linker flag to remove unused functions and variables from the final binary. If possible, add the `-flto` compiler flag to enable link-time-optimisation together with `-Os` for GCC or `-Oz` for CLANG. 206 207### How to reduce the RAM usage 208- Lower the size of the *Display buffer* 209- Reduce `LV_MEM_SIZE` in *lv_conf.h*. This memory is used when you create objects like buttons, labels, etc. 210- To work with lower `LV_MEM_SIZE` you can create objects only when required and delete them when they are not needed anymore 211 212### How to work with an operating system? 213 214To work with an operating system where tasks can interrupt each other (preemptively) you should protect LVGL related function calls with a mutex. 215See the [Operating system and interrupts](/porting/os) section to learn more. 216