Merge branch 'docs/translate_index_and_i2c_lcd' into 'master'

Docs/Provide translation for index.rst and i2c_lcd.rst

Closes DOC-7873

See merge request espressif/esp-idf!31025
This commit is contained in:
Shen Meng Jing 2024-05-28 13:18:29 +08:00
commit b325a56114
4 changed files with 161 additions and 11 deletions

View File

@ -1,6 +1,8 @@
I2C Interfaced LCD
------------------
:link_to_translation:`zh_CN:[中文]`
#. Create I2C bus. Please refer to :doc:`I2C API doc </api-reference/peripherals/i2c>` for more details.
.. code-block:: c
@ -20,7 +22,7 @@ I2C Interfaced LCD
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::dev_addr` sets the I2C device address of the LCD controller chip. The LCD driver uses this address to communicate with the LCD controller chip.
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::scl_speed_hz` sets the I2C clock frequency in Hz. The value should not exceed the range recommended in the LCD spec.
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::lcd_cmd_bits` and :cpp:member:`esp_lcd_panel_io_i2c_config_t::lcd_param_bits` set the bit width of the command and parameter that recognized by the LCD controller chip. This is chip specific, you should refer to your LCD spec in advance.
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::lcd_cmd_bits` and :cpp:member:`esp_lcd_panel_io_i2c_config_t::lcd_param_bits` set the bit width of the command and parameter recognized by the LCD controller chip. This is chip specific, you should refer to your LCD spec in advance.
.. code-block:: c

View File

@ -1,10 +1,12 @@
LCD
===
:link_to_translation:`zh_CN:[中文]`
Introduction
------------
ESP chips can generate various kinds of timings needed by common LCDs on the market, like SPI LCD, I2C LCD, Parallel LCD (Intel 8080), RGB/SRGB LCD, MIPI DSI LCD and etc. The ``esp_lcd`` component offers an abstracted driver framework to support them in a unified way.
ESP chips can generate various kinds of timings needed by common LCDs on the market, like SPI LCD, I2C LCD, Parallel LCD (Intel 8080), RGB/SRGB LCD, MIPI DSI LCD, etc. The ``esp_lcd`` component offers an abstracted driver framework to support them in an unified way.
An LCD typically consists of two main planes:
@ -17,7 +19,8 @@ Functional Overview
In the context of ``esp_lcd``, both the data plane and the control plane are represented by the :cpp:type:`esp_lcd_panel_handle_t` type.
On some LCDs, these two planes may be combined into a single plane. In this configuration, pixel data is transmitted through the control plane, achieving functionality similar to that of the data plane. This merging is common in SPI LCDs and I2C LCDs.
Additionally, there are LCDs that do not require a separate control plane. For instance, certain RGB LCDs automatically execute necessary initialization procedures after power-up. Host devices only need to continuously refresh pixel data through the data plane. However, it's essential to note that not all RGB LCDs eliminate the control plane entirely. Some LCD devices can simultaneously support multiple interfaces, requiring the host to send specific commands via the control plane (such as those based on the SPI interface) to enable the RGB mode.
Additionally, there are LCDs that do not require a separate control plane. For instance, certain RGB LCDs automatically execute necessary initialization procedures after power-up. Host devices only need to continuously refresh pixel data through the data plane. However, it's essential to note that not all RGB LCDs eliminate the control plane entirely. Some LCD devices can simultaneously support multiple interfaces, requiring the Host to send specific commands via the control plane (such as those based on the SPI interface) to enable the RGB mode.
This document will discuss how to create the control plane and data plane, as mentioned earlier, based on different types of LCDs.
@ -32,13 +35,13 @@ This document will discuss how to create the control plane and data plane, as me
.. note::
ESP-IDF provides only a limited number of LCD device controller drivers out of the box (e.g., ST7789), more drivers are available in the `Espressif Component Registry <https://components.espressif.com/components?q=esp_lcd>`__.
ESP-IDF provides only a limited number of LCD device controller drivers out of the box (e.g., ST7789). More drivers are available in the `Espressif Component Registry <https://components.espressif.com/components?q=esp_lcd>`__.
LCD Control Panel Operations
----------------------------
* :cpp:func:`esp_lcd_panel_reset` can reset the LCD control panel.
* :cpp:func:`esp_lcd_panel_init` performs a basic initialization of the control panel. To perform more manufacture specific initialization, please refer to :ref:`steps_add_manufacture_init`.
* :cpp:func:`esp_lcd_panel_init` performs a basic initialization of the control panel. To perform more manufacturer specific initialization, please refer to :ref:`steps_add_manufacture_init`.
* By combining using :cpp:func:`esp_lcd_panel_swap_xy` and :cpp:func:`esp_lcd_panel_mirror`, you can achieve the functionality of rotating or mirroring the LCD screen.
* :cpp:func:`esp_lcd_panel_disp_on_off` can turn on or off the LCD screen by cutting down the output path from the frame buffer to the LCD screen. Please note, this is not controlling the LCD backlight. Backlight control is not covered by the ``esp_lcd`` driver.
* :cpp:func:`esp_lcd_panel_disp_sleep` can reduce the power consumption of the LCD screen by entering the sleep mode. The internal frame buffer is still retained.
@ -48,14 +51,14 @@ LCD Data Panel Operations
* :cpp:func:`esp_lcd_panel_reset` can reset the LCD data panel.
* :cpp:func:`esp_lcd_panel_init` performs a basic initialization of the data panel.
* :cpp:func:`esp_lcd_panel_draw_bitmap` is the function which does the magic to flush the user draw buffer to the LCD screen, where the target draw window is configurable. Please note, this function expects the draw buffer is a 1-D array and there's no stride in between each lines.
* :cpp:func:`esp_lcd_panel_draw_bitmap` is the function which does the magic to flush the user draw buffer to the LCD screen, where the target draw window is configurable. Please note, this function expects that the draw buffer is a 1-D array and there's no stride in between each lines.
.. _steps_add_manufacture_init:
Steps to Add Manufacture Specific Initialization
Steps to Add Manufacturer Specific Initialization
-------------------------------------------------
The LCD controller drivers (e.g., st7789) in ESP-IDF only provide basic initialization in the :cpp:func:`esp_lcd_panel_init`, leaving the vast majority of settings to the default values. Some LCD modules needs to set a bunch of manufacture specific configurations before it can display normally. These configurations usually include gamma, power voltage and so on. If you want to add manufacture specific initialization, please follow the steps below:
The LCD controller drivers (e.g., st7789) in ESP-IDF only provide basic initialization in the :cpp:func:`esp_lcd_panel_init`, leaving the vast majority of settings to the default values. Some LCD modules need to set a bunch of manufacturer specific configurations before it can display normally. These configurations usually include gamma, power voltage and so on. If you want to add manufacturer specific initialization, please follow the steps below:
.. code:: c
@ -63,7 +66,7 @@ The LCD controller drivers (e.g., st7789) in ESP-IDF only provide basic initiali
esp_lcd_panel_init(panel_handle);
// set extra configurations e.g., gamma control
// with the underlying IO handle
// please consult your manufacture for special commands and corresponding values
// please consult your manufacturer for special commands and corresponding values
esp_lcd_panel_io_tx_param(io_handle, GAMMA_CMD, (uint8_t[]) {
GAMMA_ARRAY
}, N);

View File

@ -1 +1,52 @@
.. include:: ../../../../en/api-reference/peripherals/lcd/i2c_lcd.rst
I2C 接口的 LCD
---------------
:link_to_translation:`en:[English]`
#. 创建 I2C 总线。详细信息,请参阅 :doc:`I2C API 文档 </api-reference/peripherals/i2c>`
.. code-block:: c
i2c_master_bus_handle_t i2c_bus = NULL;
i2c_master_bus_config_t bus_config = {
.clk_source = I2C_CLK_SRC_DEFAULT,
.glitch_ignore_cnt = 7,
.i2c_port = I2C_BUS_PORT,
.sda_io_num = EXAMPLE_PIN_NUM_SDA,
.scl_io_num = EXAMPLE_PIN_NUM_SCL,
.flags.enable_internal_pullup = true,
};
ESP_ERROR_CHECK(i2c_new_master_bus(&bus_config, &i2c_bus));
#. 从 I2C 总线分配一个 LCD IO 设备句柄。在此步骤中,需要提供以下信息:
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::dev_addr` 设置 LCD 控制器芯片的 I2C 设备地址。LCD 驱动程序使用此地址与 LCD 控制器芯片通信。
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::scl_speed_hz` 设置 I2C 时钟频率 (Hz)。该值不应超过 LCD 规格书中推荐的范围。
- :cpp:member:`esp_lcd_panel_io_i2c_config_t::lcd_cmd_bits`:cpp:member:`esp_lcd_panel_io_i2c_config_t::lcd_param_bits` 分别设置 LCD 控制器芯片可识别的命令及参数的位宽。不同芯片对位宽要求不同,请提前参阅 LCD 规格书。
.. code-block:: c
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_io_i2c_config_t io_config = {
.dev_addr = EXAMPLE_I2C_HW_ADDR,
.scl_speed_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
.control_phase_bytes = 1, // 参阅 LCD 规格
.dc_bit_offset = 6, // 参阅 LCD 规格
.lcd_cmd_bits = EXAMPLE_LCD_CMD_BITS,
.lcd_param_bits = EXAMPLE_LCD_CMD_BITS,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus, &io_config, &io_handle));
#. 安装 LCD 控制器驱动程序。LCD 控制器驱动程序负责向 LCD 控制器芯片发送命令和参数。在此步骤中,需要指定上一步骤中分配到的 I2C IO 设备句柄以及一些面板特定配置:
- :cpp:member:`esp_lcd_panel_dev_config_t::reset_gpio_num` 设置 LCD 的硬件复位 GPIO 编号。如果 LCD 没有硬件复位管脚,则将此设置为 ``-1``
- :cpp:member:`esp_lcd_panel_dev_config_t::bits_per_pixel` 设置像素颜色数据的位宽。LCD 驱动程序使用此值计算要发送到 LCD 控制器芯片的字节数。
.. code-block:: c
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_panel_dev_config_t panel_config = {
.bits_per_pixel = 1,
.reset_gpio_num = EXAMPLE_PIN_NUM_RST,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle));

View File

@ -1 +1,95 @@
.. include:: ../../../../en/api-reference/peripherals/lcd/index.rst
LCD
===
:link_to_translation:`en:[English]`
简介
----
ESP 系列芯片可以发出市场上常见的 LCD如 SPI LCD、I2C LCD、并行 LCD (Intel 8080)、RGB/SRGB LCD、MIPI DSI LCD 等)所需的各种时序。``esp_lcd`` 组件为上述各类 LCD 提供了一个统一的抽象驱动框架。
LCD 通常由两个主要平面组成:
* **控制平面**:通过该平面,可以读取、写入 LCD 设备控制器的内部寄存器。主机通常使用该平面来初始化 LCD 电源或进行伽玛校正等。
* **数据平面**:数据平面负责向 LCD 设备传输像素数据。
功能概述
--------
``esp_lcd`` 的上下文中,数据平面和控制平面都由 :cpp:type:`esp_lcd_panel_handle_t` 数据类型表示。
在某些 LCD 中,上述两个平面可能会合并为一个平面。此时,像素数据通过控制平面传输,实现类似数据平面的功能。这在 SPI LCD 和 I2C LCD 中很常见。
此外,还有一些 LCD 不需要单独的控制平面。例如,某些 RGB LCD 在上电后会自动执行必要的初始化过程,主机只需通过数据平面不断刷新像素数据即可。但要注意,并非所有 RGB LCD 都完全不需要控制平面。部分 LCD 设备同时支持多种接口,需要主机通过控制平面(例如基于 SPI 接口)发送特定命令以启用 RGB 模式。
本文将讨论如何为不同类型的 LCD 创建控制平面和数据平面。
.. toctree::
:maxdepth: 1
:SOC_GPSPI_SUPPORTED: spi_lcd
:SOC_I2C_SUPPORTED: i2c_lcd
:SOC_LCD_I80_SUPPORTED: i80_lcd
:SOC_LCD_RGB_SUPPORTED: rgb_lcd
:SOC_MIPI_DSI_SUPPORTED: dsi_lcd
.. note::
ESP-IDF 仓库中自带的 LCD 设备控制器驱动程序数量有限例如ST7789 驱动程序是开箱即用的)。更多驱动程序可通过 `乐鑫组件注册表 <https://components.espressif.com/components?q=esp_lcd>`__ 获取。
LCD 控制面板操作
----------------
* :cpp:func:`esp_lcd_panel_reset` 可以重置 LCD 控制面板。
* :cpp:func:`esp_lcd_panel_init` 执行基本的控制面板初始化。有关特定制造商的初始化设置,请参阅 :ref:`steps_add_manufacture_init`
* 通过组合使用 :cpp:func:`esp_lcd_panel_swap_xy`:cpp:func:`esp_lcd_panel_mirror`,可以实现 LCD 屏幕旋转和 LCD 屏幕镜像功能。
* :cpp:func:`esp_lcd_panel_disp_on_off` 可以通过切断从帧 buffer 到 LCD 屏幕的输出路径来打开或关闭 LCD 屏幕。请注意,这与控制 LCD 背光不同,``esp_lcd`` 驱动程序无法控制 LCD 背光。
* :cpp:func:`esp_lcd_panel_disp_sleep` 可以通过进入睡眠模式减少 LCD 屏幕的功耗,而内部的帧 buffer 仍然保留。
LCD 数据面板操作
----------------
* :cpp:func:`esp_lcd_panel_reset` 可以重置 LCD 数据面板。
* :cpp:func:`esp_lcd_panel_init` 执行基本的数据面板初始化。
* :cpp:func:`esp_lcd_panel_draw_bitmap` 可以将绘制 buffer 刷新到 LCD 屏幕上,其中目标绘制窗口是可配置的。请注意,使用该函数需要确保绘制 buffer 是一维数组,且每行像素数据之间没有跨距。
.. _steps_add_manufacture_init:
添加特定制造商的初始化设置
--------------------------
在 ESP-IDF 中LCD 控制器驱动程序(例如 st7789在函数 :cpp:func:`esp_lcd_panel_init` 中只提供了基本的控制面板初始化设置,大部分设置使用默认值。部分 LCD 模组需要进行一系列特定制造商的配置(通常包含伽玛配置、电压配置等)才能正常显示。若想添加特定制造商的初始化设置,请参照以下步骤:
.. code:: c
esp_lcd_panel_reset(panel_handle);
esp_lcd_panel_init(panel_handle);
// 进行额外的配置,例如伽玛控制
// 使用底层 IO 句柄
// 请咨询制造商来获取特殊命令和相应的值
esp_lcd_panel_io_tx_param(io_handle, GAMMA_CMD, (uint8_t[]) {
GAMMA_ARRAY
}, N);
// 打开显示屏
esp_lcd_panel_disp_on_off(panel_handle, true);
应用示例
--------
.. list::
* 软件 JPEG 解码与显示 - :example:`peripherals/lcd/tjpgd`
:SOC_GPSPI_SUPPORTED: * 带有 SPI 触摸的通用 SPI LCD 示例 - :example:`peripherals/lcd/spi_lcd_touch`
:SOC_LCD_I80_SUPPORTED: * 基于 i80 控制器的 LCD 和 LVGL 动画 UI - :example:`peripherals/lcd/i80_controller`
:SOC_LCD_RGB_SUPPORTED: * 带有散点图 UI 的 RGB 面板示例 - :example:`peripherals/lcd/rgb_panel`
:SOC_I2C_SUPPORTED: * 带有 I2C 接口的 OLED 显示滚动文本 - :example:`peripherals/lcd/i2c_oled`
:SOC_MIPI_DSI_SUPPORTED: * MIPI DSI 显示示例 - :example:`peripherals/lcd/mipi_dsi`
API 参考
--------
.. include-build-file:: inc/lcd_types.inc
.. include-build-file:: inc/esp_lcd_types.inc
.. include-build-file:: inc/esp_lcd_panel_io.inc
.. include-build-file:: inc/esp_lcd_panel_ops.inc
.. include-build-file:: inc/esp_lcd_panel_vendor.inc