Skip to content

Commit

Permalink
Merge branch 'feat/add_rgb_anti-tear_demo' into 'master'
Browse files Browse the repository at this point in the history
feat(lcd): Added RGB anti-tearing demo

See merge request ae_group/esp-iot-solution!960
  • Loading branch information
leeebo committed Apr 1, 2024
2 parents 7f7b82d + dec3591 commit 29b5a8d
Show file tree
Hide file tree
Showing 52 changed files with 2,482 additions and 569 deletions.
10 changes: 10 additions & 0 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ build_example_display_lcd_rgb_lcd_8bit:
variables:
EXAMPLE_DIR: examples/display/lcd/rgb_lcd_8bit

build_example_display_lcd_rgb_avoid_tearing:
extends:
- .build_examples_template
- .rules:build:example_display_lcd_rgb_avoid_tearing
parallel:
matrix:
- IMAGE: espressif/idf:release-v5.1
variables:
EXAMPLE_DIR: examples/display/lcd/rgb_avoid_tearing

build_example_extended_vfs_gpio_gpio_simple:
extends:
- .build_examples_template
Expand Down
27 changes: 27 additions & 0 deletions .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@
.patterns-example_display_lcd_rgb_lcd_8bit: &patterns-example_display_lcd_rgb_lcd_8bit
- "examples/display/lcd/rgb_lcd_8bit/**/*"

.patterns-example_display_lcd_rgb_avoid_tearing: &patterns-example_display_lcd_rgb_avoid_tearing
- "examples/display/lcd/rgb_avoid_tearing/**/*"

.patterns-example_extended_vfs_gpio_gpio_simple: &patterns-example_extended_vfs_gpio_gpio_simple
- "examples/extended_vfs/gpio/gpio_simple/**/*"

Expand Down Expand Up @@ -646,6 +649,12 @@
- <<: *if-trigger-job
- <<: *if-dev-push
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_gc9b71
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_sh8601
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_spd2010
- <<: *if-dev-push
changes: *patterns-example_display_lcd_qspi_with_ram

Expand All @@ -666,9 +675,27 @@
- <<: *if-trigger-job
- <<: *if-dev-push
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_st77903_rgb
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_panel_io_additions
- <<: *if-dev-push
changes: *patterns-example_display_lcd_rgb_lcd_8bit

.rules:build:example_display_lcd_rgb_avoid_tearing:
rules:
- <<: *if-protected
- <<: *if-label-build
- <<: *if-trigger-job
- <<: *if-dev-push
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_st7701
- <<: *if-dev-push
changes: *patterns-components_display_lcd_esp_lcd_panel_io_additions
- <<: *if-dev-push
changes: *patterns-example_display_lcd_rgb_avoid_tearing

.rules:build:example_extended_vfs_gpio_gpio_simple:
rules:
- <<: *if-protected
Expand Down
24 changes: 15 additions & 9 deletions components/display/lcd/esp_lcd_st7701/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# ChangeLog

## v0.0.1 - 2023-09-12
## v1.0.1 - 2024-03-25

### Enhancements:
### bugfix

* Implement the driver for the ST7701(S) LCD controller
* Support RGB interface
* Fix the `mirror` function

## v1.0.0 - 2023-11-03

### bugfix

* Fix the incompatible dependent version of ESP-IDF
* Fix missing dependency of `cmake_utilities` component
* Check conflicting commands between initialization sequence and driver

## v0.0.2 - 2023-10-26

### Enhancements:

* Support to mirror by command

## v1.0.0 - 2023-11-03
## v0.0.1 - 2023-09-12

### bugfix
### Enhancements:

* Fix the incompatible dependent version of ESP-IDF
* Fix missing dependency of `cmake_utilities` component
* Check conflicting commands between initialization sequence and driver
* Implement the driver for the ST7701(S) LCD controller
* Support RGB interface
22 changes: 20 additions & 2 deletions components/display/lcd/esp_lcd_st7701/esp_lcd_st7701.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "soc/soc_caps.h"

#if SOC_LCD_RGB_SUPPORTED
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
Expand All @@ -26,6 +29,9 @@
#define ST7701_CMD_BKxSEL_BYTE2 (0x00)
#define ST7701_CMD_BKxSEL_BYTE3 (0x00)
#define ST7701_CMD_CN2_BIT (1 << 4)
#define ST7701_CMD_BKxSEL_BK0 (0x00)
#define ST7701_CMD_BKxSEL_BK1 (0x01)
#define ST7701_CMD_BKxSEL_BK2 (0x03)

typedef struct {
esp_lcd_panel_io_handle_t io;
Expand Down Expand Up @@ -140,7 +146,7 @@ esp_err_t esp_lcd_new_panel_st7701(const esp_lcd_panel_io_handle_t io, const esp

// Create RGB panel
ESP_GOTO_ON_ERROR(esp_lcd_new_rgb_panel(vendor_config->rgb_config, ret_panel), err, TAG, "create RGB panel failed");
ESP_LOGD(TAG, "new RGB panel @%p", ret_panel);
ESP_LOGD(TAG, "new RGB panel @%p", *ret_panel);

// Save the original functions of RGB panel
st7701->init = (*ret_panel)->init;
Expand Down Expand Up @@ -346,9 +352,20 @@ static esp_err_t panel_st7701_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool
} else {
st7701->madctl_val &= ~LCD_CMD_ML_BIT;
}

// Enable the Command2 BK0
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7701_CMD_CND2BKxSEL, (uint8_t []) {
ST7701_CMD_BKxSEL_BYTE0, ST7701_CMD_BKxSEL_BYTE1, ST7701_CMD_BKxSEL_BYTE2, ST7701_CMD_BKxSEL_BYTE3,
ST7701_CMD_BKxSEL_BK0 | ST7701_CMD_CN2_BIT,
}, 5), TAG, "send command failed");
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7701_CMD_SDIR, (uint8_t[]) {
sdir_val,
}, 1), TAG, "send command failed");;

// Disable Command2
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7701_CMD_CND2BKxSEL, (uint8_t []) {
ST7701_CMD_BKxSEL_BYTE0, ST7701_CMD_BKxSEL_BYTE1, ST7701_CMD_BKxSEL_BYTE2, ST7701_CMD_BKxSEL_BYTE3, 0,
}, 5), TAG, "send command failed");
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) {
st7701->madctl_val,
}, 1), TAG, "send command failed");;
Expand Down Expand Up @@ -380,3 +397,4 @@ static esp_err_t panel_st7701_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
}
return ESP_OK;
}
#endif /* SOC_LCD_RGB_SUPPORTED */
4 changes: 3 additions & 1 deletion components/display/lcd/esp_lcd_st7701/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.0.0"
version: "1.0.1"
targets:
- esp32s3
description: ESP LCD ST7701
Expand All @@ -8,3 +8,5 @@ issues: https://github.com/espressif/esp-iot-solution/issues
dependencies:
idf: ">5.0.4,!=5.1.1"
cmake_utilities: "0.*"
examples:
- path: ../../../../examples/display/lcd/rgb_avoid_tearing
9 changes: 9 additions & 0 deletions components/display/lcd/esp_lcd_st77922/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# ChangeLog

## v0.0.3 - 2024-3-27

### Enhancements:

### bugfix

* Fix the logic when checking conflicting commands between initialization sequence and driver
* Fix the wrong command structure in the README.md

## v0.0.2 - 2024-2-19

### Enhancements:
Expand Down
16 changes: 8 additions & 8 deletions components/display/lcd/esp_lcd_st77922/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
* Uncomment these line if use custom initialization commands.
* The array should be declared as static const and positioned outside the function.
*/
// static const ST77922_lcd_init_cmd_t lcd_init_cmds[] = {
// static const st77922_lcd_init_cmd_t lcd_init_cmds[] = {
// // {cmd, { data }, data_size, delay_ms}
// {0x28, (uint8_t []){0x00}, 0, 0},
// {0x10, (uint8_t []){0x00}, 0, 0},
Expand All @@ -46,11 +46,11 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
// ...
// };

ESP_LOGI(TAG, "Install ST77922 panel driver");
ESP_LOGI(TAG, "Install st77922 panel driver");
esp_lcd_panel_handle_t panel_handle = NULL;
ST77922_vendor_config_t vendor_config = {
st77922_vendor_config_t vendor_config = {
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(ST77922_lcd_init_cmd_t),
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(st77922_lcd_init_cmd_t),
.flags = {
.use_qspi_interface = 0,
},
Expand Down Expand Up @@ -88,7 +88,7 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
* Uncomment these line if use custom initialization commands.
* The array should be declared as static const and positioned outside the function.
*/
// static const ST77922_lcd_init_cmd_t lcd_init_cmds[] = {
// static const st77922_lcd_init_cmd_t lcd_init_cmds[] = {
// // {cmd, { data }, data_size, delay_ms}
// {0x28, (uint8_t []){0x00}, 0, 0},
// {0x10, (uint8_t []){0x00}, 0, 0},
Expand All @@ -97,11 +97,11 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
// ...
// };
ESP_LOGI(TAG, "Install ST77922 panel driver");
ESP_LOGI(TAG, "Install st77922 panel driver");
esp_lcd_panel_handle_t panel_handle = NULL;
ST77922_vendor_config_t vendor_config = {
st77922_vendor_config_t vendor_config = {
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(ST77922_lcd_init_cmd_t),
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(st77922_lcd_init_cmd_t),
.flags = {
.use_qspi_interface = 1,
},
Expand Down
12 changes: 5 additions & 7 deletions components/display/lcd/esp_lcd_st77922/esp_lcd_st77922.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define LCD_OPCODE_READ_CMD (0x0BULL)
#define LCD_OPCODE_WRITE_COLOR (0x32ULL)

#define ST77922_CMD_SET (0xF1)
#define ST77922_CMD_SET (0xF0)
#define ST77922_PARAM_SET (0x00)

static const char *TAG = "st77922";
Expand Down Expand Up @@ -198,7 +198,7 @@ static const st77922_lcd_init_cmd_t vendor_specific_init_default[] = {
{0x2B, (uint8_t []){0x00, 0x00, 0x01, 0x2B}, 4, 0},
{0xD0, (uint8_t []){0x80}, 1, 0},
// ======================CMD2======================
{0xF1, (uint8_t []){0x00}, 1, 0},
{0xF1, (uint8_t []){0x00}, 0, 0},
{0x60, (uint8_t []){0x00, 0x00, 0x00}, 3, 0},
{0x65, (uint8_t []){0x00}, 1, 0},
{0x66, (uint8_t []){0x00, 0x3F}, 2, 0},
Expand Down Expand Up @@ -242,7 +242,7 @@ static const st77922_lcd_init_cmd_t vendor_specific_init_default[] = {
{0xB9, (uint8_t []){0x23, 0x23}, 2, 0},
{0xBF, (uint8_t []){0x0F, 0x13, 0x13, 0x09, 0x09, 0x09}, 6, 0}, // VGHP/VGLP
// ======================CMD3======================
{0xF2, (uint8_t []){0x00}, 1, 0},
{0xF2, (uint8_t []){0x00}, 0, 0},
{0x73, (uint8_t []){0x04, 0xBA, 0x1A, 0x58, 0x5B}, 5, 0}, // VOP= 5v
{0x77, (uint8_t []){0x6B, 0x5B, 0xFB, 0xC3, 0xC5}, 5, 0},
{0x7A, (uint8_t []){0x15, 0x27}, 2, 0},
Expand All @@ -251,7 +251,7 @@ static const st77922_lcd_init_cmd_t vendor_specific_init_default[] = {
{0xBF, (uint8_t []){0x36}, 1, 0},
{0xE3, (uint8_t []){0x43, 0x43}, 2, 0}, // VMF
// ======================CMD1======================
{0xF0, (uint8_t []){0x00}, 1, 0},
{0xF0, (uint8_t []){0x00}, 0, 0},
{0x21, (uint8_t []){0x00}, 1, 0},
{0x11, (uint8_t []){0x00}, 1, 120},
{0x35, (uint8_t []){0x00}, 1, 20},
Expand Down Expand Up @@ -311,9 +311,7 @@ static esp_err_t panel_st77922_init(esp_lcd_panel_t *panel)
vTaskDelay(pdMS_TO_TICKS(init_cmds[i].delay_ms));

// Check if the current cmd is the "command set" cmd
if ((init_cmds[i].cmd == ST77922_CMD_SET)) {
is_user_set = ((uint8_t *)init_cmds[i].data)[0] == ST77922_PARAM_SET ? true : false;
}
is_user_set = (init_cmds[i].cmd == ST77922_CMD_SET);
}
ESP_LOGD(TAG, "send init commands success");

Expand Down
2 changes: 1 addition & 1 deletion components/display/lcd/esp_lcd_st77922/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.0.2"
version: "0.0.3"
description: ESP LCD ST77922
url: https://github.com/espressif/esp-iot-solution/tree/master/components/display/lcd/esp_lcd_st77922
repository: https://github.com/espressif/esp-iot-solution.git
Expand Down
8 changes: 4 additions & 4 deletions docs/en/display/lcd/rgb_lcd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ Here is the explanation of the functions implemented for ``esp_lcd_panel_handle_
- Mirror the X and Y axes either through commands or using ``rgb_panel_mirror()`` based on user configuration.
* - swap_xy()
- rgb_panel_swap_xy()
- esp_lcd_panel_mirror()
- esp_lcd_panel_swap_xy()
- Swap X and Y axes through software using ``rgb_panel_swap_xy()`` without saving and overwriting.
* - set_gap()
- rgb_panel_set_gap()
- esp_lcd_panel_mirror()
- esp_lcd_panel_set_gap()
- Modify the starting and ending coordinates for drawing through software using ``rgb_panel_set_gap()`` without saving and overwriting.
* - invert_color()
- rgb_panel_invert_color()
- esp_lcd_panel_mirror()
- esp_lcd_panel_invert_color()
- Invert pixel color data bitwise through hardware using ``rgb_panel_invert_color()`` without saving and overwriting (0xF0F0 -> 0x0F0F).
* - disp_on_off()
- rgb_panel_disp_on_off()
- esp_lcd_panel_mirror()
- esp_lcd_panel_disp_on_off()
- Implement the on/off control of LCD display based on user configuration. If ``disp_gpio_num`` is not configured, control can be achieved using LCD commands ``LCD_CMD_DISON (29h)`` and ``LCD_CMD_DISOFF (28h)``. Additionally, if ``disp_gpio_num`` is configured, control can be achieved by calling the function ``rgb_panel_disp_on_off()``.

For the majority of RGB LCDs, the commands and parameters of their driver IC are compatible with the implementation details mentioned above. Therefore, the porting process can be completed using the following steps:
Expand Down
8 changes: 4 additions & 4 deletions docs/zh_CN/display/lcd/rgb_lcd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ RGB LCD 驱动流程可大致分为三个部分:初始化接口设备、移植
- 根据用户配置,既可以通过命令,也可以使用 ``rgb_panel_mirror()`` 通过软件实现镜像 X 轴和 Y 轴。
* - swap_xy()
- rgb_panel_swap_xy()
- esp_lcd_panel_mirror()
- esp_lcd_panel_swap_xy()
- 无需保存和覆盖,使用 ``rgb_panel_swap_xy()`` 通过软件实现交换 X 轴和 Y 轴。
* - set_gap()
- rgb_panel_set_gap()
- esp_lcd_panel_mirror()
- esp_lcd_panel_set_gap()
- 无需保存和覆盖,使用 ``rgb_panel_set_gap()`` 通过软件修改画图时的起始和终止坐标,从而实现画图的偏移。
* - invert_color()
- rgb_panel_invert_color()
- esp_lcd_panel_mirror()
- esp_lcd_panel_invert_color()
- 无需保存和覆盖,使用 ``rgb_panel_invert_color()`` 通过硬件实现像素的色彩数据按位取反(0xF0F0 -> 0x0F0F)。
* - disp_on_off()
- rgb_panel_disp_on_off()
- esp_lcd_panel_mirror()
- esp_lcd_panel_disp_on_off()
- 根据用户配置来实现 LCD 显示的开关。如果没有配置 ``disp_gpio_num``,则可以通过 LCD 命令 ``LCD_CMD_DISON(29h)`` 和 ``LCD_CMD_DISOFF(28h)`` 来进行控制。另外,如果配置了 ``disp_gpio_num``,则可以通过调用函数 ``rgb_panel_disp_on_off()`` 来实现控制。

对于大多数 RGB LCD,其驱动 IC 的命令及参数与上述实现说明中的兼容,因此可以通过以下步骤完成移植:
Expand Down
8 changes: 6 additions & 2 deletions examples/.build-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,18 @@ examples/check_pedestrian_flow:
enable:
- if: IDF_TARGET in ["esp32","esp32s2","esp32s3","esp32c3"]

examples/display/lcd/qspi_without_ram:
examples/display/lcd/qspi_with_ram:
enable:
- if: IDF_TARGET in ["esp32s3"] and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 2)
- if: IDF_TARGET in ["esp32","esp32c2","esp32c3","esp32c6","esp32h2","esp32s2", "esp32s3"] and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 1)

examples/display/lcd/rgb_lcd_8bit:
enable:
- if: IDF_TARGET in ["esp32s3"]

examples/display/lcd/rgb_avoid_tearing:
enable:
- if: IDF_TARGET in ["esp32s3"]

examples/extended_vfs/gpio/gpio_simple:
enable:
- if: IDF_TARGET in ["esp32","esp32s2","esp32s3","esp32c3"]
Expand Down
8 changes: 5 additions & 3 deletions examples/display/lcd/qspi_with_ram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ The connection between ESP Board and the LCD is as follows:
└──────────────────────┘ └────────────────────┘
```

The GPIO number used by this example can be changed in [example_qspi_with_ram.c](main/example_qspi_with_ram.c).
Especially, please pay attention to the level used to turn on the LCD backlight, some LCD module needs a low level to turn it on, while others take a high level. You can change the backlight level macro `EXAMPLE_LCD_BK_LIGHT_ON_LEVEL` in [example_qspi_with_ram.c](main/example_qspi_with_ram.c).
The LCD vendor specific initialization can be different between manufacturers and should consult the LCD supplier for initialization sequence code.
* The LCD parameters and GPIO number used by this example can be changed in [example_qspi_with_ram.c](main/example_qspi_with_ram.c). Especially, please pay attention to the **vendor specific initialization**, it can be different between manufacturers and should consult the LCD supplier for initialization sequence code.

### Configure the Project

Run `idf.py menuconfig` and navigate to `Example Configuration` menu.

### Build and Flash

Expand Down
12 changes: 2 additions & 10 deletions examples/display/lcd/qspi_with_ram/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
set(LV_DEMO_DIR ../managed_components/lvgl__lvgl/demos)
file(GLOB_RECURSE LV_DEMOS_SOURCES ${LV_DEMO_DIR}/*.c)

idf_component_register(
SRCS "example_qspi_with_ram.c" ${LV_DEMOS_SOURCES}
INCLUDE_DIRS "." ${LV_DEMO_DIR})

set_source_files_properties(
${LV_DEMOS_SOURCES}
PROPERTIES COMPILE_OPTIONS
-DLV_LVGL_H_INCLUDE_SIMPLE)
SRCS "example_qspi_with_ram.c"
INCLUDE_DIRS ".")
Loading

0 comments on commit 29b5a8d

Please sign in to comment.