Skip to content

Commit

Permalink
LVGL: Add support of LVGL9 into LVGL port
Browse files Browse the repository at this point in the history
  • Loading branch information
espzav committed Jan 30, 2024
1 parent 6bc7078 commit 5431be8
Show file tree
Hide file tree
Showing 30 changed files with 3,471 additions and 1,597 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
idf_ver: ["release-v4.3", "release-v4.4", "latest"]
idf_ver: ["release-v4.4", "release-v5.0", "release-v5.1", "release-v5.2", "latest"]
idf_target: ["esp32", "esp32s2", "esp32c3", "esp32s3"]
exclude:
- idf_ver: "release-v4.3"
Expand All @@ -31,4 +31,5 @@ jobs:
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}"
pip install idf-component-manager --upgrade
idf.py build
1 change: 1 addition & 0 deletions bsp/esp32_c3_lcdkit/include/bsp/esp32_c3_lcdkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "driver/i2s_pdm.h"
#include "iot_button.h"
#include "lvgl.h"
#include "esp_lvgl_port.h"
#include "esp_codec_dev.h"

/**************************************************************************************************
Expand Down
32 changes: 32 additions & 0 deletions components/esp_lvgl_port/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Changelog

## 1.5.0

### Features

- Divided into files per feature
- Added support for LVGL9

## 1.4.0

### Features

- Added support for USB HID mouse/keyboard as an input device

## 1.3.0

### Features

- Added low power interface

## 1.2.0

### Features

- Added support for encoder (knob) as an input device

## 1.1.0

### Features

- Added support for navigation buttons as an input device
55 changes: 45 additions & 10 deletions components/esp_lvgl_port/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
file(GLOB_RECURSE IMAGE_SOURCES images/*.c)

idf_component_register(SRCS "esp_lvgl_port.c" ${IMAGE_SOURCES} INCLUDE_DIRS "include" REQUIRES "esp_lcd" PRIV_REQUIRES "esp_timer")
#Get LVGL version
idf_component_get_property(lvgl_ver lvgl__lvgl COMPONENT_VERSION)
if(lvgl_ver EQUAL "")
idf_component_get_property(lvgl_ver lvgl COMPONENT_VERSION)
endif()
message(STATUS "LVGL version: ${lvgl_ver}")

#Select folder by LVGL version
if(lvgl_ver VERSION_LESS "9.0.0")
message(VERBOSE "Compiling esp_lvgl_port for LVGL8")
set(PORT_FOLDER "lvgl8")
else()
message(VERBOSE "Compiling esp_lvgl_port for LVGL9")
set(PORT_FOLDER "lvgl9")
endif()

set(PORT_PATH "src/${PORT_FOLDER}")

idf_component_register(SRCS "${PORT_PATH}/esp_lvgl_port.c" "${PORT_PATH}/esp_lvgl_port_disp.c" INCLUDE_DIRS "include" REQUIRES "esp_lcd" PRIV_REQUIRES "esp_timer")

set(ADD_SRCS "")
set(ADD_LIBS "")

idf_build_get_property(build_components BUILD_COMPONENTS)
if("espressif__button" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::espressif__button)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_button.c")
list(APPEND ADD_LIBS idf::espressif__button)
endif()
if("button" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::button)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_button.c")
list(APPEND ADD_LIBS idf::button)
endif()
if("espressif__esp_lcd_touch" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::espressif__esp_lcd_touch)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_touch.c")
list(APPEND ADD_LIBS idf::espressif__esp_lcd_touch)
endif()
if("esp_lcd_touch" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_lcd_touch)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_touch.c")
list(APPEND ADD_LIBS idf::esp_lcd_touch)
endif()
if("espressif__knob" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::espressif__knob)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_knob.c")
list(APPEND ADD_LIBS idf::espressif__knob)
endif()
if("knob" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::knob)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_knob.c")
list(APPEND ADD_LIBS idf::knob)
endif()
if("espressif__usb_host_hid" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::espressif__usb_host_hid)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_usbhid.c" "images/${PORT_FOLDER}/img_cursor.c")
list(APPEND ADD_LIBS idf::espressif__usb_host_hid)
endif()
if("usb_host_hid" IN_LIST build_components)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::usb_host_hid)
list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_usbhid.c" "images/${PORT_FOLDER}/img_cursor.c")
list(APPEND ADD_LIBS idf::usb_host_hid)
endif()

if(ADD_SRCS)
target_sources(${COMPONENT_LIB} PRIVATE ${ADD_SRCS})
endif()
if(ADD_LIBS)
target_link_libraries(${COMPONENT_LIB} PRIVATE ${ADD_LIBS})
endif()
17 changes: 17 additions & 0 deletions components/esp_lvgl_port/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ This component helps with using LVGL with Espressif's LCD and touch drivers. It
* Add/remove navigation buttons input (using [`button`](https://github.com/espressif/esp-iot-solution/tree/master/components/button))
* Add/remove encoder input (using [`knob`](https://github.com/espressif/esp-iot-solution/tree/master/components/knob))

## LVGL Version

This component supports **LVGL8** and **LVGL9**. By default, it selects the latest LVGL version. If you want to use a specific version (e.g. latest LVGL8), you can easily put into `idf_component.yml` in your project like this:

```
lvgl/lvgl:
version: "^8"
public: true
```

### LVGL Version Compatibility

This component is fully compatible with LVGL version 9. All types and functions are used from LVGL9. Some LVGL9 types are not supported in LVGL8 and there are retyping in [`esp_lvgl_port_compatibility.h`](include/esp_lvgl_port_compatibility.h) header file. **Please, be aware, that some draw and object functions are not compatible between LVGL8 and LVGL9.**

## Usage

### Initialization
Expand Down Expand Up @@ -53,6 +67,7 @@ Add an LCD screen to the LVGL. It can be called multiple times for adding multip
},
.flags = {
.buff_dma = true,
.swap_bytes = false,
}
};
disp_handle = lvgl_port_add_disp(&disp_cfg);
Expand Down Expand Up @@ -219,6 +234,7 @@ Every LVGL calls must be protected with these lock/unlock commands:
```

### Rotating screen

LVGL port supports rotation of the display. You can select whether you'd like software rotation or hardware rotation.
Software rotation requires no additional logic in your `flush_cb` callback.

Expand All @@ -233,6 +249,7 @@ Rotation mode can be selected in the `lvgl_port_display_cfg_t` structure.
}
```
Display rotation can be changed at runtime.
``` c
lv_disp_set_rotation(disp_handle, LV_DISP_ROT_90);
```
Expand Down

0 comments on commit 5431be8

Please sign in to comment.