diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eadad6a..4c7f00e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,18 @@ # ChangeLog -## v0.1.5 - 2024-07-01 +## v0.1.5 - 2024-07-09 + +### Enhancements: + +* feat(gt911): support set I2C address by using RST and INT pins +* feat(lvgl_port): set the lvgl task to run on the same core as the Arduino task by default +* feat(board): increase the RGB pclk frequency to 26MHz for `ESP32_4848S040C_I_Y_3` ### Bugfixes: * fix(panel): init expander host with correct macro (#65) +* fix(panel): don't reset the LCD if the bus is RGB bus and the `ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO` is enabled +* fix(examples): fix lvgl port rotation issue when enabling avoid tearing by @NecroMancer05 ## v0.1.4 - 2024-06-17 diff --git a/ESP_Panel_Board_Custom.h b/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/ESP_Panel_Board_Custom.h +++ b/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/README.md b/README.md index 8a3cb742..50712065 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -[![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml) +[![GitHub Release](https://img.shields.io/github/v/release/esp-arduino-libs/ESP32_Display_Panel)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/releases) [![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml) # ESP Display Panel * [中文版本](./README_CN.md) -ESP32_Display_Panel is an Arduino library designed for ESP SoCs to drive display panels and facilitate rapid GUI development. Users can develop directly for a variety of [supported development boards](src/board/Board_Instructions.md) or create custom ones through simple adaptation. Additionally, ESP32_Display_Panel is compatible with various LCD and touch drivers, allowing users to develop using standalone drivers as needed. +ESP32_Display_Panel is an Arduino library designed for ESP SoCs to drive display panels and facilitate rapid GUI development. Users can develop directly for a variety of [supported development boards](docs/Board_Instructions.md) or create custom ones through simple adaptation. Additionally, ESP32_Display_Panel is compatible with various LCD and touch drivers, allowing users to develop using standalone drivers as needed. ESP32_Display_Panel encapsulates various components from the [Espressif Components Registry](https://components.espressif.com/), requiring development based on [arduino-esp32](https://github.com/espressif/arduino-esp32), and can be directly downloaded from the Arduino IDE. @@ -58,19 +58,19 @@ The functional block diagram of ESP32_Display_Panel is as follows, mainly compri ### Development Boards -Below is a list of [supported development boards](src/board/Board_Instructions.md): +Below is a list of [supported development boards](docs/Board_Instructions.md): | **Manufacturer** | **Board Model** | | --------------- | --------------- | -| [Espressif](src/board/Board_Instructions.md#espressif) | ESP32-C3-LCDkit, ESP32-S3-Box, ESP32-S3-Box-3, ESP32-S3-Box-3(beta), ESP32-S3-Box-Lite, ESP32-S3-EYE, ESP32-S3-Korvo-2, ESP32-S3-LCD-EV-Board, ESP32-S3-LCD-EV-Board-2, ESP32-S3-USB-OTG | -| [M5Stack](https://m5stack.com/) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | -| [Jingcai](src/board/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | +| [Espressif](docs/Board_Instructions.md#espressif) | ESP32-C3-LCDkit, ESP32-S3-Box, ESP32-S3-Box-3, ESP32-S3-Box-3(beta), ESP32-S3-Box-Lite, ESP32-S3-EYE, ESP32-S3-Korvo-2, ESP32-S3-LCD-EV-Board, ESP32-S3-LCD-EV-Board-2, ESP32-S3-USB-OTG | +| [M5Stack](docs/Board_Instructions.md#m5stack) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | +| [Jingcai](docs/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | -Developers and manufacturers are welcomed to contribute PRs to add more development boards. For detailed instructions, please refer to the [`Board Development Guide`](./src/board/Board_Contribution_Guide.md). +Developers and manufacturers are welcomed to contribute PRs to add more development boards. For detailed instructions, please refer to the [`Board Development Guide`](./docs/Board_Contribution_Guide.md). ### LCD Controllers -Below is a list of [supported LCD controllers](src/lcd/README.md): +Below is a list of [supported LCD controllers](docs/LCD_Controllers.md): | **Manufacturer** | **Model** | | --------------- | --------- | @@ -81,7 +81,7 @@ Below is a list of [supported LCD controllers](src/lcd/README.md): ### Touch Controllers -Below is a list of [supported touch controllers](src/touch/README.md): +Below is a list of [supported touch controllers](docs/Touch_Controllers.md): | **Manufacturer** | **Model** | | --------------- | --------- | @@ -112,10 +112,10 @@ Below are detailed instructions on how to configure ESP32_Display_Panel, mainly 3. For projects without configuration files, users can copy them from the root directory or examples of ESP32_Display_Panel to their own projects. 4. If multiple projects need to use the same configuration, users can place the configuration files in the [Arduino Library Directory](#where-is-the-directory-for-arduino-libraries), so that all projects can share the same configuration. -**Notes**: - -* The same directory can simultaneously contain both `ESP_Panel_Board_Supported.h` and `ESP_Panel_Board_Custom.h` configuration files, but they cannot be enabled at the same time, meaning `ESP_PANEL_USE_SUPPORTED_BOARD` and `ESP_PANEL_USE_CUSTOM_BOARD` can only have one set to `1`. -* If neither of the above two configuration files is enabled, users cannot use the `ESP_Panel` driver and can only use other standalone device drivers, such as `ESP_PanelBus`, `ESP_PanelLcd`, etc. +> [!WARNING] +> * The same directory can simultaneously contain both `ESP_Panel_Board_Supported.h` and `ESP_Panel_Board_Custom.h` configuration files, but they cannot be enabled at the same time, meaning `ESP_PANEL_USE_SUPPORTED_BOARD` and `ESP_PANEL_USE_CUSTOM_BOARD` can only have one set to `1`. +> * If neither of the above two configuration files is enabled, users cannot use the `ESP_Panel` driver and can only use other standalone device drivers, such as `ESP_PanelBus`, `ESP_PanelLcd`, etc. +> * Since the configurations within these files might change, such as adding, deleting, or renaming, to ensure the compatibility of the program, the library manages the versions of these files independently and checks whether the configuration files currently used by the user are compatible with the library during compilation. Detailed version information and checking rules can be found at the end of the file. #### Configuring Drivers @@ -309,7 +309,7 @@ To port the SquareLine project (v1.3.x), please refer to [here](#porting-squarel ### Configuring Supported Development Boards -For details on how to configure the supported development boards in the Arduino IDE, see [Board_Instructions.md](./src/board/Board_Instructions.md#recommended-configurations-in-the-arduino-ide). +For details on how to configure the supported development boards in the Arduino IDE, see [Board_Instructions - Recommended Configurations in the Arduino IDE](./docs/Board_Instructions.md#recommended-configurations-in-the-arduino-ide). ### Configuring LVGL diff --git a/README_CN.md b/README_CN.md index c9e43c10..a4db560c 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,10 +1,10 @@ -[![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml) +[![GitHub Release](https://img.shields.io/github/v/release/esp-arduino-libs/ESP32_Display_Panel)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/releases) [![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Display_Panel/actions/workflows/pre-commit.yml) # ESP Display Panel * [English Version](./README.md) -ESP32_Display_Panel 是专为 ESP SoCs 设计的 Arduino 库,用于驱动显示屏并实现快速 GUI 开发。用户不仅可以直接开发多款[内部支持的开发板](src/board/Board_Instructions.md),还可以通过简单的适配来开发自定义的开发板。此外,ESP32_Display_Panel 还适配了多款 LCD 和触摸的驱动,用户也可以根据需要使用独立的驱动进行开发。 +ESP32_Display_Panel 是专为 ESP SoCs 设计的 Arduino 库,用于驱动显示屏并实现快速 GUI 开发。用户不仅可以直接开发多款[内部支持的开发板](docs/Board_Instructions.md),还可以通过简单的适配来开发自定义的开发板。此外,ESP32_Display_Panel 还适配了多款 LCD 和触摸的驱动,用户也可以根据需要使用独立的驱动进行开发。 ESP32_Display_Panel 封装了多种[乐鑫组件库](https://components.espressif.com/)中相关的组件,需要基于 [arduino-esp32](https://github.com/espressif/arduino-esp32) 进行开发,并且可以直接从 Arduino IDE 中下载获取。 @@ -58,19 +58,19 @@ ESP32_Display_Panel 的功能框图如下所示,主要包含以下特性: ### 开发板 -下面是支持的[开发板列表](src/board/Board_Instructions.md): +下面是支持的[开发板列表](docs/Board_Instructions.md): | **厂商** | **开发板型号** | | -------- | -------------- | -| [Espressif](src/board/Board_Instructions.md#espressif) | ESP32-C3-LCDkit, ESP32-S3-Box, ESP32-S3-Box-3, ESP32-S3-Box-3(beta), ESP32-S3-Box-Lite, ESP32-S3-EYE, ESP32-S3-Korvo-2, ESP32-S3-LCD-EV-Board, ESP32-S3-LCD-EV-Board-2, ESP32-S3-USB-OTG | -| [M5Stack](https://m5stack.com/) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | -| [Jingcai](src/board/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | +| [Espressif](docs/Board_Instructions.md#espressif) | ESP32-C3-LCDkit, ESP32-S3-Box, ESP32-S3-Box-3, ESP32-S3-Box-3(beta), ESP32-S3-Box-Lite, ESP32-S3-EYE, ESP32-S3-Korvo-2, ESP32-S3-LCD-EV-Board, ESP32-S3-LCD-EV-Board-2, ESP32-S3-USB-OTG | +| [M5Stack](docs/Board_Instructions.md#m5stack) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | +| [Jingcai](docs/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | -欢迎开发者和厂商贡献 PR 来添加更多的开发板,详细说明请参考 [`开发板贡献指南`](./src/board/Board_Contribution_Guide_CN.md)。 +欢迎开发者和厂商贡献 PR 来添加更多的开发板,详细说明请参考 [`开发板贡献指南`](./docs/Board_Contribution_Guide_CN.md)。 ### LCD 控制器 -下面是支持的 [LCD 控制器列表](src/lcd/README.md): +下面是支持的 [LCD 控制器列表](docs/LCD_Controllers.md): | **厂商** | **型号** | | -------- | -------- | @@ -81,7 +81,7 @@ ESP32_Display_Panel 的功能框图如下所示,主要包含以下特性: ### 触摸控制器 -下面是支持的 [触摸控制器列表](src/touch/README.md): +下面是支持的 [触摸控制器列表](docs/Touch_Controllers.md): | **厂商** | **型号** | | -------- | -------- | @@ -112,10 +112,10 @@ ESP32_Display_Panel 的功能框图如下所示,主要包含以下特性: 3. 对于没有配置文件的工程,用户可以将其从 ESP32_Display_Panel 的根目录或者示例工程中复制到自己的工程中。 4. 如果有多个工程需要使用相同的配置,用户可以将配置文件放在 [Arduino 库目录](#arduino-库的目录在哪儿)中,这样所有的工程都可以共享相同的配置。 -**Notes**: - -* 同一个目录下可以同时包含 `ESP_Panel_Board_Supported.h` 和 `ESP_Panel_Board_Custom.h` 两种配置文件,但是它们不能同时被使能,即 `ESP_PANEL_USE_SUPPORTED_BOARD` 和 `ESP_PANEL_USE_CUSTOM_BOARD` 最多只能有一个为 `1`。 -* 如果以上两个配置文件都被没有被使能,那么用户就无法使用 `ESP_Panel` 驱动,只能使用其他独立的设备驱动,如 `ESP_PanelBus`, `ESP_PanelLcd` 等。 +> [!WARNING] +> * 同一个目录下可以同时包含 `ESP_Panel_Board_Supported.h` 和 `ESP_Panel_Board_Custom.h` 两种配置文件,但是它们不能同时被使能,即 `ESP_PANEL_USE_SUPPORTED_BOARD` 和 `ESP_PANEL_USE_CUSTOM_BOARD` 最多只能有一个为 `1`。 +> * 如果以上两个配置文件都被没有被使能,那么用户就无法使用 `ESP_Panel` 驱动,只能使用其他独立的设备驱动,如 `ESP_PanelBus`, `ESP_PanelLcd` 等。 +> * 由于这些文件内的配置可能会发生变化,比如新增、删除或重命名,为了保证程序的兼容性,库对它们分别进行了独立的版本管理,并在编译时检查用户当前使用的配置文件与库是否兼容。详细的版本信息以及检查规则可以在文件的末尾处找到。 #### 配置驱动 @@ -309,7 +309,7 @@ ESP32_Display_Panel 会根据 [ESP_Panel_Board_Custom.h](./ESP_Panel_Board_Custo ### 配置支持的开发板 -关于如何在 Arduino IDE 中配置支持的开发板,请参考 [Board_Instructions.md](./src/board/Board_Instructions.md#recommended-configurations-in-the-arduino-ide). +关于如何在 Arduino IDE 中配置支持的开发板,请参考 [Board_Instructions - Recommended Configurations in the Arduino IDE](./docs/Board_Instructions.md#recommended-configurations-in-the-arduino-ide). ### 配置 LVGL diff --git a/src/board/Board_Contribution_Guide.md b/docs/Board_Contribution_Guide.md similarity index 53% rename from src/board/Board_Contribution_Guide.md rename to docs/Board_Contribution_Guide.md index 096db0e3..98a2ea13 100644 --- a/src/board/Board_Contribution_Guide.md +++ b/docs/Board_Contribution_Guide.md @@ -26,7 +26,7 @@ Using the adaption of the [`M5Stack M5DIAL`](https://github.com/esp-arduino-libs | -README.md [M] | -ESP_PanelVersions.h [M] | -CHANGELOG.md [M] - | -ESP_Panel_Board_Custom.h + | -ESP_Panel_Board_Custom.h | -ESP_Panel_Board_Supported.h [M] | -library.properties [M] | -README_CN.md [M] @@ -38,24 +38,24 @@ Note: [A] stands for 'append' and [M] stands for 'modify' Using the adaption of `M5Stack M5DIAL` as an example, follow these steps to modify the relevant files: -1. **[M]** *[ESP_Panel_Board_Supported.h](../../ESP_Panel_Board_Supported.h)*: Add a macro for the new development board, such as `BOARD_M5STACK_M5DIAL`. Ensure the macro is in uppercase. Include the manufacturer's name and link, as well as the target development board's link. -2. **[A]** *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*: Use the *ESP_Panel_Board_Custom.h* file in the root directory as a template to create a new configuration header file for the development board. Follow the naming conventions of existing development boards. -3. **[M]** *[src/board/ESP_PanelBoard.h](../board/ESP_PanelBoard.h)*: Add the macro check for the new development board by referring to the existing boards in the file, and modify the file to use the correct header file for this development board. +1. **[M]** *[ESP_Panel_Board_Supported.h](../ESP_Panel_Board_Supported.h)*: Add a macro for the new development board, such as `BOARD_M5STACK_M5DIAL`. Ensure the macro is in uppercase. Include the manufacturer's name and link, as well as the target development board's link. +2. **[A]** *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*: Use the *ESP_Panel_Board_Custom.h* file in the root directory as a template to create a new configuration header file for the development board. Follow the naming conventions of existing development boards. +3. **[M]** *[src/board/ESP_PanelBoard.h](../src/board/ESP_PanelBoard.h)*: Add the macro check for the new development board by referring to the existing boards in the file, and modify the file to use the correct header file for this development board. **Note**: At this point, you can verify the above steps: - - Choose an example, such as *[examples/Panel/PanelTest](../../examples/Panel/PanelTest/)*. - - modify the macro `ESP_PANEL_USE_SUPPORTED_BOARD` to enable this header file. Define the development board macro, such as `BOARD_M5STACK_M5DIAL`, to enable the new header file *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*. + - Choose an example, such as *[examples/Panel/PanelTest](../examples/Panel/PanelTest/)*. + - modify the macro `ESP_PANEL_USE_SUPPORTED_BOARD` to enable this header file. Define the development board macro, such as `BOARD_M5STACK_M5DIAL`, to enable the new header file *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*. - Verify the example's ino file. If successful, proceed to the following steps. -4. **[M]** *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*: Modify the configuration header file for the new development board: +4. **[M]** *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*: Modify the configuration header file for the new development board: - Review the hardware schematics of the development board, focusing on the BUS type used for the LCD screen, the LCD driver name, the BUS type used for touch, the touch driver name, and the chip pin numbers used for each interface of the LCD and touch. - The best practice is to first get the screen working, then work on the touch functionality. - If the new development board's driver is compatible with an existing driver, there is no need to add a new driver. Simply note in the comments that this driver is compatible with an existing one and use the existing driver. - - If the driver used by the new development board is not compatible with existing drivers or has other special configurations, you can achieve this by modifying the macro functions at the end of the new development board's configuration header file, such as `ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION`, `ESP_PANEL_BEGIN_END_FUNCTION`, etc. Refer to *[src/board/espressif/ESP32_S3_BOX_3.h](../board/espressif/ESP32_S3_BOX_3.h)* or *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)* for specific implementations. - - Run examples other than *[examples/LCD](../../examples/LCD/)* and *[examples/Touch](../../examples/Touch/)*, and continuously adjust the configuration header file to ensure correct settings. + - If the driver used by the new development board is not compatible with existing drivers or has other special configurations, you can achieve this by modifying the macro functions at the end of the new development board's configuration header file, such as `ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION`, `ESP_PANEL_BEGIN_END_FUNCTION`, etc. Refer to *[src/board/espressif/ESP32_S3_BOX_3.h](../src/board/espressif/ESP32_S3_BOX_3.h)* or *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)* for specific implementations. + - Run examples other than *[examples/LCD](../examples/LCD/)* and *[examples/Touch](../examples/Touch/)*, and continuously adjust the configuration header file to ensure correct settings. -5. **[M]** *[ESP_Panel_Board_Supported](../../ESP_Panel_Board_Supported.h)*, *[library.properties](../../library.properties)*, *[board/Board_Instructions.md](../board/Board_Instructions.md)*, *[README_CN.md](../../README_CN.md)*, *[README.md](../../README.md)*: Update the supported development boards information in these files. -6. **[M]** *[src/board/Board_Instructions.md](../board/Board_Instructions.md)*: Update the recommended configuration for the new development board. -7. **[M]** *[src/ESP_PanelVersions.h](../ESP_PanelVersions.h)*: Ensure that the version under `Library Version` should be ahead of the latest tag version in terms of the tag version; when changes occur to *[ESP_Panel_Board_Custom.h](../../ESP_Panel_Board_Custom.h)*, *[ESP_Panel_Board_Supported.h](../../ESP_Panel_Board_Supported.h)*, and *[ESP_Panel_Conf.h](../../ESP_Panel_Conf.h)* in the root directory, ensure that the version number at the end of the corresponding file and at the beginging of *[src/ESP_PanelVersions.h](../ESP_PanelVersions.h)* should be ahead of the latest tag version in terms of the minor version. -8. **[M]** *[CHANGELOG.md](../../CHANGELOG.md)*: Update the changelog. \ No newline at end of file +5. **[M]** *[ESP_Panel_Board_Supported](../ESP_Panel_Board_Supported.h)*, *[library.properties](../library.properties)*, *[docs/Board_Instructions.md](../docs/Board_Instructions.md)*, *[README_CN.md](../README_CN.md)*, *[README.md](../README.md)*: Update the supported development boards information in these files. +6. **[M]** *[docs/Board_Instructions.md](../docs/Board_Instructions.md)*: Update the recommended configuration for the new development board. +7. **[M]** *[src/ESP_PanelVersions.h](../src/ESP_PanelVersions.h)*: Ensure that the version under `Library Version` should be ahead of the latest tag version in terms of the tag version; when changes occur to *[ESP_Panel_Board_Custom.h](../ESP_Panel_Board_Custom.h)*, *[ESP_Panel_Board_Supported.h](../ESP_Panel_Board_Supported.h)*, and *[ESP_Panel_Conf.h](../ESP_Panel_Conf.h)* in the root directory, ensure that the version number at the end of the corresponding file and at the beginging of *[src/ESP_PanelVersions.h](../src/ESP_PanelVersions.h)* should be ahead of the latest tag version in terms of the minor version. +8. **[M]** *[CHANGELOG.md](../CHANGELOG.md)*: Update the changelog. \ No newline at end of file diff --git a/src/board/Board_Contribution_Guide_CN.md b/docs/Board_Contribution_Guide_CN.md similarity index 52% rename from src/board/Board_Contribution_Guide_CN.md rename to docs/Board_Contribution_Guide_CN.md index 2d1a16dc..701322ac 100644 --- a/src/board/Board_Contribution_Guide_CN.md +++ b/docs/Board_Contribution_Guide_CN.md @@ -26,7 +26,7 @@ pip3 install pre-commit && pre-commit install | -README.md [M] | -ESP_PanelVersions.h [M] | -CHANGELOG.md [M] - | -ESP_Panel_Board_Custom.h + | -ESP_Panel_Board_Custom.h | -ESP_Panel_Board_Supported.h [M] | -library.properties [M] | -README_CN.md [M] @@ -38,24 +38,24 @@ pip3 install pre-commit && pre-commit install 以适配 `M5Stack M5DIAL` 为例,按照以下步骤修改相关文件: -1. **[M]** *[ESP_Panel_Board_Supported.h](../../ESP_Panel_Board_Supported.h)*:为新开发板添加一个宏,例如 `BOARD_M5STACK_M5DIAL`。命名时注意宏名大写。注意附上开发板制造商的名称和链接,以及目标开发板的链接。 -2. **[A]** *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*:使用根目录中的 *ESP_Panel_Board_Custom.h* 文件作为模板,为开发板创建一个新的配置头文件。文件命名请参考已有开发板。 -3. **[M]** *[src/board/ESP_PanelBoard.h](../board/ESP_PanelBoard.h)*:参照文件中其他开发板的写法,添加新开发板的宏名判断,并注意修改此开发板所使用的头文件。 +1. **[M]** *[ESP_Panel_Board_Supported.h](../ESP_Panel_Board_Supported.h)*:为新开发板添加一个宏,例如 `BOARD_M5STACK_M5DIAL`。命名时注意宏名大写。注意附上开发板制造商的名称和链接,以及目标开发板的链接。 +2. **[A]** *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*:使用根目录中的 *ESP_Panel_Board_Custom.h* 文件作为模板,为开发板创建一个新的配置头文件。文件命名请参考已有开发板。 +3. **[M]** *[src/board/ESP_PanelBoard.h](../src/board/ESP_PanelBoard.h)*:参照文件中其他开发板的写法,添加新开发板的宏名判断,并注意修改此开发板所使用的头文件。 **注意**:此时,可以验证上述步骤: - - 选择一个示例,例如 *[examples/Panel/PanelTest](../../examples/Panel/PanelTest/)*。 - - 修改宏 `ESP_PANEL_USE_SUPPORTED_BOARD` 以启用此头文件。定义开发板宏,例如 `BOARD_M5STACK_M5DIAL`,以启用新的头文件 *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*。 + - 选择一个示例,例如 *[examples/Panel/PanelTest](../examples/Panel/PanelTest/)*。 + - 修改宏 `ESP_PANEL_USE_SUPPORTED_BOARD` 以启用此头文件。定义开发板宏,例如 `BOARD_M5STACK_M5DIAL`,以启用新的头文件 *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*。 - 验证示例的 ino 文件。如果成功,继续后续步骤。 -4. **[M]** *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*:修改新开发板的配置头文件: +4. **[M]** *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*:修改新开发板的配置头文件: - 审查开发板的硬件原理图,重点关注LCD 屏幕所使用 BUS 类型、 LCD 驱动名、touch 所使用 BUS 类型、touch 驱动名,以及 LCD 和 touch 各接口所使用的芯片管脚号。 - 修改技巧是先亮屏再 touch。 - 如果新开发板的驱动程序与现有驱动程序兼容,则无需添加新驱动程序。只需在注释中注明该驱动程序与现有驱动程序兼容,并使用现有驱动程序。 - - 如果新开发板使用的驱动程序与现有驱动程序不兼容或有其他特殊配置,可以通过修改新开发板配置头文件末尾的宏函数来实现,例如 `ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION`、`ESP_PANEL_BEGIN_END_FUNCTION` 等。具体实现请参考 *[src/board/espressif/ESP32_S3_BOX_3.h](../board/espressif/ESP32_S3_BOX_3.h)* 或 *[src/board/m5stack/M5DIAL.h](../board/m5stack/M5DIAL.h)*。 - - 运行除 *[examples/LCD](../../examples/LCD/)* 和 *[examples/Touch](../../examples/Touch/)* 以外的示例,并不断调整配置头文件以确保设置正确。 + - 如果新开发板使用的驱动程序与现有驱动程序不兼容或有其他特殊配置,可以通过修改新开发板配置头文件末尾的宏函数来实现,例如 `ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION`、`ESP_PANEL_BEGIN_END_FUNCTION` 等。具体实现请参考 *[src/board/espressif/ESP32_S3_BOX_3.h](../src/board/espressif/ESP32_S3_BOX_3.h)* 或 *[src/board/m5stack/M5DIAL.h](../src/board/m5stack/M5DIAL.h)*。 + - 运行除 *[examples/LCD](../examples/LCD/)* 和 *[examples/Touch](../examples/Touch/)* 以外的示例,并不断调整配置头文件以确保设置正确。 -5. **[M]** *[ESP_Panel_Board_Supported](../../ESP_Panel_Board_Supported.h)*、*[library.properties](../../library.properties)*、*[board/Board_Instructions.md](../board/Board_Instructions.md)*、*[README_CN.md](../../README_CN.md)*、*[README.md](../../README.md)*:更新上述文件中“已支持开发板”说明。 -6. **[M]** *[src/board/Board_Instructions.md](../board/Board_Instructions.md)*:更新新开发板的推荐配置。 -7. **[M]** *[src/ESP_PanelVersions.h](../ESP_PanelVersions.h)*:确保 `Library Version` 下的版本应小版本领先于最新 tag 版本。当根目录下的 *[ESP_Panel_Board_Custom.h](../../ESP_Panel_Board_Custom.h)*、*[ESP_Panel_Board_Supported.h](../../ESP_Panel_Board_Supported.h)* 和 *[ESP_Panel_Conf.h](../../ESP_Panel_Conf.h)* 发生变化时,相应文件末尾和 *[src/ESP_PanelVersions.h](../ESP_PanelVersions.h)* 开头的版本号应中版本领先于最新 tag 版本。 -8. **[M]** *[CHANGELOG.md](../../CHANGELOG.md)*:更新变更日志。 \ No newline at end of file +5. **[M]** *[ESP_Panel_Board_Supported](../ESP_Panel_Board_Supported.h)*、*[library.properties](../library.properties)*、*[docs/Board_Instructions.md](../docs/Board_Instructions.md)*、*[README_CN.md](../README_CN.md)*、*[README.md](../README.md)*:更新上述文件中“已支持开发板”说明。 +6. **[M]** *[docs/Board_Instructions.md](../docs/Board_Instructions.md)*:更新新开发板的推荐配置。 +7. **[M]** *[src/ESP_PanelVersions.h](../src/ESP_PanelVersions.h)*:确保 `Library Version` 下的版本应小版本领先于最新 tag 版本。当根目录下的 *[ESP_Panel_Board_Custom.h](../ESP_Panel_Board_Custom.h)*、*[ESP_Panel_Board_Supported.h](../ESP_Panel_Board_Supported.h)* 和 *[ESP_Panel_Conf.h](../ESP_Panel_Conf.h)* 发生变化时,相应文件末尾和 *[src/ESP_PanelVersions.h](../src/ESP_PanelVersions.h)* 开头的版本号应中版本领先于最新 tag 版本。 +8. **[M]** *[CHANGELOG.md](../CHANGELOG.md)*:更新变更日志。 \ No newline at end of file diff --git a/src/board/Board_Instructions.md b/docs/Board_Instructions.md similarity index 100% rename from src/board/Board_Instructions.md rename to docs/Board_Instructions.md diff --git a/src/lcd/README.md b/docs/LCD_Controllers.md similarity index 100% rename from src/lcd/README.md rename to docs/LCD_Controllers.md diff --git a/src/touch/README.md b/docs/Touch_Controllers.md similarity index 93% rename from src/touch/README.md rename to docs/Touch_Controllers.md index b0827937..c17414b1 100644 --- a/src/touch/README.md +++ b/docs/Touch_Controllers.md @@ -2,10 +2,10 @@ | **Name** | **Version** | | -------------------------------------------------------------------------------------- | ----------- | -| [esp_lcd_touch](https://components.espressif.com/components/espressif/esp_lcd_touch) | 1.1.1 | +| [esp_lcd_touch](https://components.espressif.com/components/espressif/esp_lcd_touch) | 1.1.2 | | [CST816S](https://components.espressif.com/components/espressif/esp_lcd_touch_cst816s) | 1.0.3 | | [FT5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06) | 1.0.6 | -| [GT911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911) | 1.1.0 | +| [GT911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911) | 1.1.1 | | [GT1151](https://components.espressif.com/components/espressif/esp_lcd_touch_gt1151) | 1.0.5~1 | | ST1633 | 0.1.0 | | [ST7123](https://components.espressif.com/components/espressif/esp_lcd_touch_st7123) | 0.0.1 | diff --git a/examples/LVGL/v8/Porting/ESP_Panel_Board_Custom.h b/examples/LVGL/v8/Porting/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/examples/LVGL/v8/Porting/ESP_Panel_Board_Custom.h +++ b/examples/LVGL/v8/Porting/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/examples/LVGL/v8/Porting/lvgl_port_v8.cpp b/examples/LVGL/v8/Porting/lvgl_port_v8.cpp index 31429eb1..08cc35ab 100644 --- a/examples/LVGL/v8/Porting/lvgl_port_v8.cpp +++ b/examples/LVGL/v8/Porting/lvgl_port_v8.cpp @@ -485,7 +485,7 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd) ESP_LOGD(TAG, "Register display driver to LVGL"); lv_disp_drv_init(&disp_drv); disp_drv.flush_cb = flush_callback; -#if LVGL_PORT_ROTATION_90 || LVGL_PORT_ROTATION_270 +#if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270) disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; disp_drv.ver_res = LVGL_PORT_DISP_WIDTH; #else diff --git a/examples/LVGL/v8/Porting/lvgl_port_v8.h b/examples/LVGL/v8/Porting/lvgl_port_v8.h index f7cdb7ca..21b8edc3 100644 --- a/examples/LVGL/v8/Porting/lvgl_port_v8.h +++ b/examples/LVGL/v8/Porting/lvgl_port_v8.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include @@ -49,7 +50,9 @@ #define LVGL_PORT_TASK_MIN_DELAY_MS (2) // The minimum delay of the LVGL timer task, in milliseconds #define LVGL_PORT_TASK_STACK_SIZE (6 * 1024) // The stack size of the LVGL timer task, in bytes #define LVGL_PORT_TASK_PRIORITY (2) // The priority of the LVGL timer task -#define LVGL_PORT_TASK_CORE (-1) // The core of the LVGL timer task, `-1` means the don't specify the core +#define LVGL_PORT_TASK_CORE (ARDUINO_RUNNING_CORE) + // The core of the LVGL timer task, `-1` means the don't specify the core + // Default is the same as the Arduino task // This can be set to `1` only if the SoCs support dual-core, // otherwise it should be set to `-1` or `0` diff --git a/examples/LVGL/v8/Rotation/ESP_Panel_Board_Custom.h b/examples/LVGL/v8/Rotation/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/examples/LVGL/v8/Rotation/ESP_Panel_Board_Custom.h +++ b/examples/LVGL/v8/Rotation/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/examples/LVGL/v8/Rotation/lvgl_port_v8.cpp b/examples/LVGL/v8/Rotation/lvgl_port_v8.cpp index 31429eb1..280b9ccf 100644 --- a/examples/LVGL/v8/Rotation/lvgl_port_v8.cpp +++ b/examples/LVGL/v8/Rotation/lvgl_port_v8.cpp @@ -485,8 +485,8 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd) ESP_LOGD(TAG, "Register display driver to LVGL"); lv_disp_drv_init(&disp_drv); disp_drv.flush_cb = flush_callback; -#if LVGL_PORT_ROTATION_90 || LVGL_PORT_ROTATION_270 - disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; + if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270) + disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; disp_drv.ver_res = LVGL_PORT_DISP_WIDTH; #else disp_drv.hor_res = LVGL_PORT_DISP_WIDTH; diff --git a/examples/LVGL/v8/Rotation/lvgl_port_v8.h b/examples/LVGL/v8/Rotation/lvgl_port_v8.h index f7cdb7ca..21b8edc3 100644 --- a/examples/LVGL/v8/Rotation/lvgl_port_v8.h +++ b/examples/LVGL/v8/Rotation/lvgl_port_v8.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include @@ -49,7 +50,9 @@ #define LVGL_PORT_TASK_MIN_DELAY_MS (2) // The minimum delay of the LVGL timer task, in milliseconds #define LVGL_PORT_TASK_STACK_SIZE (6 * 1024) // The stack size of the LVGL timer task, in bytes #define LVGL_PORT_TASK_PRIORITY (2) // The priority of the LVGL timer task -#define LVGL_PORT_TASK_CORE (-1) // The core of the LVGL timer task, `-1` means the don't specify the core +#define LVGL_PORT_TASK_CORE (ARDUINO_RUNNING_CORE) + // The core of the LVGL timer task, `-1` means the don't specify the core + // Default is the same as the Arduino task // This can be set to `1` only if the SoCs support dual-core, // otherwise it should be set to `-1` or `0` diff --git a/examples/Panel/PanelTest/ESP_Panel_Board_Custom.h b/examples/Panel/PanelTest/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/examples/Panel/PanelTest/ESP_Panel_Board_Custom.h +++ b/examples/Panel/PanelTest/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/examples/PlatformIO/src/ESP_Panel_Board_Custom.h b/examples/PlatformIO/src/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/examples/PlatformIO/src/ESP_Panel_Board_Custom.h +++ b/examples/PlatformIO/src/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/examples/PlatformIO/src/lvgl_port_v8.cpp b/examples/PlatformIO/src/lvgl_port_v8.cpp index 31429eb1..280b9ccf 100644 --- a/examples/PlatformIO/src/lvgl_port_v8.cpp +++ b/examples/PlatformIO/src/lvgl_port_v8.cpp @@ -485,8 +485,8 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd) ESP_LOGD(TAG, "Register display driver to LVGL"); lv_disp_drv_init(&disp_drv); disp_drv.flush_cb = flush_callback; -#if LVGL_PORT_ROTATION_90 || LVGL_PORT_ROTATION_270 - disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; + if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270) + disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; disp_drv.ver_res = LVGL_PORT_DISP_WIDTH; #else disp_drv.hor_res = LVGL_PORT_DISP_WIDTH; diff --git a/examples/SquareLine/v8/Porting/ESP_Panel_Board_Custom.h b/examples/SquareLine/v8/Porting/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/examples/SquareLine/v8/Porting/ESP_Panel_Board_Custom.h +++ b/examples/SquareLine/v8/Porting/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/examples/SquareLine/v8/Porting/lvgl_port_v8.cpp b/examples/SquareLine/v8/Porting/lvgl_port_v8.cpp index 31429eb1..280b9ccf 100644 --- a/examples/SquareLine/v8/Porting/lvgl_port_v8.cpp +++ b/examples/SquareLine/v8/Porting/lvgl_port_v8.cpp @@ -485,8 +485,8 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd) ESP_LOGD(TAG, "Register display driver to LVGL"); lv_disp_drv_init(&disp_drv); disp_drv.flush_cb = flush_callback; -#if LVGL_PORT_ROTATION_90 || LVGL_PORT_ROTATION_270 - disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; + if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270) + disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; disp_drv.ver_res = LVGL_PORT_DISP_WIDTH; #else disp_drv.hor_res = LVGL_PORT_DISP_WIDTH; diff --git a/examples/SquareLine/v8/Porting/lvgl_port_v8.h b/examples/SquareLine/v8/Porting/lvgl_port_v8.h index f7cdb7ca..21b8edc3 100644 --- a/examples/SquareLine/v8/Porting/lvgl_port_v8.h +++ b/examples/SquareLine/v8/Porting/lvgl_port_v8.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include @@ -49,7 +50,9 @@ #define LVGL_PORT_TASK_MIN_DELAY_MS (2) // The minimum delay of the LVGL timer task, in milliseconds #define LVGL_PORT_TASK_STACK_SIZE (6 * 1024) // The stack size of the LVGL timer task, in bytes #define LVGL_PORT_TASK_PRIORITY (2) // The priority of the LVGL timer task -#define LVGL_PORT_TASK_CORE (-1) // The core of the LVGL timer task, `-1` means the don't specify the core +#define LVGL_PORT_TASK_CORE (ARDUINO_RUNNING_CORE) + // The core of the LVGL timer task, `-1` means the don't specify the core + // Default is the same as the Arduino task // This can be set to `1` only if the SoCs support dual-core, // otherwise it should be set to `-1` or `0` diff --git a/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Custom.h b/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Custom.h index dfa8f855..1eb79a70 100644 --- a/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Custom.h +++ b/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Custom.h @@ -197,9 +197,9 @@ #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 /* LCD Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_LCD_IO_RST (-1) -#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_LCD_IO_RST (-1) // IO num of RESET pin, set to -1 if not use +#define ESP_PANEL_LCD_RST_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_LCD */ @@ -239,8 +239,8 @@ /* Touch panel bus parameters */ #if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C - #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 - #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 to use the default address + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // For GT911, there are two addresses: 0x5D(default) and 0x14 #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K @@ -274,12 +274,14 @@ #define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 /* Touch Other Settings */ -/* IO num of RESET pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_RST (-1) -#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level -/* IO num of INT pin, set to -1 if not use */ -#define ESP_PANEL_TOUCH_IO_INT (-1) -#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level +/* Reset pin */ +#define ESP_PANEL_TOUCH_IO_RST (-1) // IO num of RESET pin, set to -1 if not use + // For GT911, the RST pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // Active level. 0: low level, 1: high level +/* Interrupt pin */ +#define ESP_PANEL_TOUCH_IO_INT (-1) // IO num of INT pin, set to -1 if not use + // For GT911, the INT pin is also used to configure the I2C address +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // Active level. 0: low level, 1: high level #endif /* ESP_PANEL_USE_TOUCH */ @@ -288,8 +290,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1 #if ESP_PANEL_USE_BACKLIGHT -/* IO num of backlight pin */ -#define ESP_PANEL_BACKLIGHT_IO (45) +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (45) // IO num of backlight pin #define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level /* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ @@ -362,7 +364,7 @@ */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 2 #endif /* ESP_PANEL_USE_CUSTOM_BOARD */ diff --git a/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.cpp b/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.cpp index 31429eb1..280b9ccf 100644 --- a/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.cpp +++ b/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.cpp @@ -485,8 +485,8 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd) ESP_LOGD(TAG, "Register display driver to LVGL"); lv_disp_drv_init(&disp_drv); disp_drv.flush_cb = flush_callback; -#if LVGL_PORT_ROTATION_90 || LVGL_PORT_ROTATION_270 - disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; + if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270) + disp_drv.hor_res = LVGL_PORT_DISP_HEIGHT; disp_drv.ver_res = LVGL_PORT_DISP_WIDTH; #else disp_drv.hor_res = LVGL_PORT_DISP_WIDTH; diff --git a/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.h b/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.h index f7cdb7ca..21b8edc3 100644 --- a/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.h +++ b/examples/SquareLine/v8/WiFiClock/lvgl_port_v8.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include @@ -49,7 +50,9 @@ #define LVGL_PORT_TASK_MIN_DELAY_MS (2) // The minimum delay of the LVGL timer task, in milliseconds #define LVGL_PORT_TASK_STACK_SIZE (6 * 1024) // The stack size of the LVGL timer task, in bytes #define LVGL_PORT_TASK_PRIORITY (2) // The priority of the LVGL timer task -#define LVGL_PORT_TASK_CORE (-1) // The core of the LVGL timer task, `-1` means the don't specify the core +#define LVGL_PORT_TASK_CORE (ARDUINO_RUNNING_CORE) + // The core of the LVGL timer task, `-1` means the don't specify the core + // Default is the same as the Arduino task // This can be set to `1` only if the SoCs support dual-core, // otherwise it should be set to `-1` or `0` diff --git a/examples/Touch/I2C/I2C.ino b/examples/Touch/I2C/I2C.ino index edd04b8d..c09e5992 100644 --- a/examples/Touch/I2C/I2C.ino +++ b/examples/Touch/I2C/I2C.ino @@ -52,7 +52,9 @@ * - TT21100 * - ST1633, ST7123 */ -#define EXAMPLE_TOUCH_NAME ST1633 +#define EXAMPLE_TOUCH_NAME GT911 +#define EXAMPLE_TOUCH_ADDRESS (0) // Typically set to `0` to use the default address + // For GT911, there are two addresses: 0x5D(default) and 0x14 #define EXAMPLE_TOUCH_WIDTH (480) #define EXAMPLE_TOUCH_HEIGHT (480) #define EXAMPLE_TOUCH_I2C_FREQ_HZ (400 * 1000) @@ -61,10 +63,12 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// Please update the following configuration according to your board spec //////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define EXAMPLE_TOUCH_PIN_NUM_I2C_SCL (45) -#define EXAMPLE_TOUCH_PIN_NUM_I2C_SDA (19) -#define EXAMPLE_TOUCH_PIN_NUM_RST (-1) -#define EXAMPLE_TOUCH_PIN_NUM_INT (-1) +#define EXAMPLE_TOUCH_PIN_NUM_I2C_SCL (10) +#define EXAMPLE_TOUCH_PIN_NUM_I2C_SDA (9) +#define EXAMPLE_TOUCH_PIN_NUM_RST (13) // Set to `-1` if not used + // For GT911, the RST pin is also used to configure the I2C address +#define EXAMPLE_TOUCH_PIN_NUM_INT (14) // Set to `-1` if not used + // For GT911, the INT pin is also used to configure the I2C address #define _EXAMPLE_TOUCH_CLASS(name, ...) ESP_PanelTouch_##name(__VA_ARGS__) #define EXAMPLE_TOUCH_CLASS(name, ...) _EXAMPLE_TOUCH_CLASS(name, ##__VA_ARGS__) @@ -86,11 +90,19 @@ void setup() Serial.println("I2C touch example start"); Serial.println("Create I2C bus"); +#if EXAMPLE_TOUCH_ADDRESS == 0 ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(EXAMPLE_TOUCH_PIN_NUM_I2C_SCL, EXAMPLE_TOUCH_PIN_NUM_I2C_SDA, ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(EXAMPLE_TOUCH_NAME)); // Taking GT911 as an example, the following is the code after macro expansion: // ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(EXAMPLE_TOUCH_PIN_NUM_I2C_SCL, EXAMPLE_TOUCH_PIN_NUM_I2C_SDA, // ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG()); +#else + ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(EXAMPLE_TOUCH_PIN_NUM_I2C_SCL, EXAMPLE_TOUCH_PIN_NUM_I2C_SDA, + ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG_WITH_ADDR(EXAMPLE_TOUCH_NAME, EXAMPLE_TOUCH_ADDRESS)); + // Taking GT911 as an example, the following is the code after macro expansion: + // ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(EXAMPLE_TOUCH_PIN_NUM_I2C_SCL, EXAMPLE_TOUCH_PIN_NUM_I2C_SDA, + // ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG_WITH_ADDR()); +#endif touch_bus->configI2cFreqHz(EXAMPLE_TOUCH_I2C_FREQ_HZ); touch_bus->begin(); diff --git a/src/ESP_Panel.cpp b/src/ESP_Panel.cpp index 692daa75..01d2bc8c 100644 --- a/src/ESP_Panel.cpp +++ b/src/ESP_Panel.cpp @@ -43,8 +43,10 @@ using namespace std; */ #define _CREATE_LCD(name, bus, cfg) make_shared(bus, cfg) #define CREATE_LCD(name, bus, cfg) _CREATE_LCD(name, bus, cfg) -#define _CREATE_LCD_TOUCH(name, bus, cfg) make_shared(bus, cfg) -#define CREATE_LCD_TOUCH(name, bus, cfg) _CREATE_LCD_TOUCH(name, bus, cfg) +#define _CREATE_TOUCH(name, bus, cfg) make_shared(bus, cfg) +#define CREATE_TOUCH(name, bus, cfg) _CREATE_TOUCH(name, bus, cfg) +#define _CREATE_TOUCH_WITH_ADDR(name, bus, cfg, addr) make_shared(bus, cfg, addr) +#define CREATE_TOUCH_WITH_ADDR(name, bus, cfg, addr) _CREATE_TOUCH_WITH_ADDR(name, bus, cfg, addr) #define _CREATE_EXPANDER(name, host_id, address) make_shared(host_id, address) #define CREATE_EXPANDER(name, host_id, address) _CREATE_EXPANDER(name, host_id, address) @@ -344,7 +346,12 @@ bool ESP_Panel::init(void) }; #endif // I2C touch panel IO - esp_lcd_panel_io_i2c_config_t touch_panel_io_config = ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(ESP_PANEL_TOUCH_NAME); + esp_lcd_panel_io_i2c_config_t touch_panel_io_config = +#if ESP_PANEL_TOUCH_I2C_ADDRESS == 0 + ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(ESP_PANEL_TOUCH_NAME); +#else + ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG_WITH_ADDR(ESP_PANEL_TOUCH_NAME, ESP_PANEL_TOUCH_I2C_ADDRESS); +#endif #elif ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -394,6 +401,7 @@ bool ESP_Panel::init(void) .process_coordinates = NULL, .interrupt_callback = NULL, .user_data = NULL, + .driver_data = NULL, }; #if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST @@ -406,7 +414,12 @@ bool ESP_Panel::init(void) ESP_PANEL_CHECK_NULL_RET(touch_bus_ptr, false, "Create touch bus failed"); ESP_LOGD(TAG, "Create touch device"); - touch_ptr = CREATE_LCD_TOUCH(ESP_PANEL_TOUCH_NAME, touch_bus_ptr.get(), lcd_touch_config); + touch_ptr = +#if ESP_PANEL_TOUCH_I2C_ADDRESS == 0 + CREATE_TOUCH(ESP_PANEL_TOUCH_NAME, touch_bus_ptr.get(), lcd_touch_config); +#else + CREATE_TOUCH_WITH_ADDR(ESP_PANEL_TOUCH_NAME, touch_bus_ptr.get(), lcd_touch_config, ESP_PANEL_TOUCH_I2C_ADDRESS); +#endif ESP_PANEL_CHECK_NULL_RET(touch_ptr, false, "Create touch device failed"); #endif /* ESP_PANEL_USE_TOUCH */ @@ -496,8 +509,11 @@ bool ESP_Panel::begin(void) #endif ESP_PANEL_CHECK_FALSE_RET(_lcd_bus_ptr->begin(), false, "Begin LCD bus failed"); ESP_PANEL_CHECK_FALSE_RET(_lcd_ptr->init(), false, "Initialize LCD failed"); - ESP_PANEL_CHECK_FALSE_RET(_lcd_ptr->reset(), false, "Reset LCD failed"); // Operate LCD device according to the optional configurations +#if (ESP_PANEL_LCD_BUS_TYPE != ESP_PANEL_BUS_TYPE_RGB) || !ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO + // We can't reset the LCD if the bus is RGB bus and the `ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO` is enabled + ESP_PANEL_CHECK_FALSE_RET(_lcd_ptr->reset(), false, "Reset LCD failed"); +#endif #ifdef ESP_PANEL_LCD_SWAP_XY ESP_PANEL_CHECK_FALSE_RET(_lcd_ptr->swapXY(ESP_PANEL_LCD_SWAP_XY), false, "Swap XY failed"); #endif diff --git a/src/ESP_PanelTypes.h b/src/ESP_PanelTypes.h index ec5c14f8..66cab144 100644 --- a/src/ESP_PanelTypes.h +++ b/src/ESP_PanelTypes.h @@ -22,31 +22,49 @@ #define ESP_PANEL_BUS_TYPE_I80 (5) #define ESP_PANEL_BUS_TYPE_MAX (6) -#define _ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(name) ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG() /** * @brief This macro is used to generate the I2C panel IO configuration according to the touch panel name. * + * @param[in] name Touch panel name + * * Taking GT911 as an example, the following is the actual code after macro expansion: * * ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(GT911) => ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG() */ +#define _ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(name) ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG() #define ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(name) _ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG(name) -#define _ESP_PANEL_TOUCH_SPI_PANEL_IO_CONFIG(name, cs_io) ESP_LCD_TOUCH_IO_SPI_ ## name ## _CONFIG(cs_io) +/** + * @brief This macro is used to generate the I2C panel IO configuration according to the touch panel name and address. + * + * @param[in] name Touch panel name + * @param[in] addr I2C address of the touch panel + * + * Taking GT911 as an example, the following is the actual code after macro expansion: + * + * ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG_WITH_ADDR(GT911, 0x14) => ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(0x14) + */ +#define _ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG_WITH_ADDR(name, addr) ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG_WITH_ADDR(addr) +#define ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG_WITH_ADDR(name, addr) _ESP_PANEL_TOUCH_I2C_PANEL_IO_CONFIG_WITH_ADDR(name, addr) + /** * @brief This macro is used to generate the SPI panel IO configuration according to the touch panel name. * + * @param[in] name Touch panel name + * @param[in] cs_io Chip select IO number + * * Taking XPT2046 as an example, the following is the actual code after macro expansion: * * ESP_PANEL_TOUCH_SPI_PANEL_IO_CONFIG(XPT2046, 5) => ESP_LCD_TOUCH_IO_SPI_XPT2046_CONFIG(5) */ +#define _ESP_PANEL_TOUCH_SPI_PANEL_IO_CONFIG(name, cs_io) ESP_LCD_TOUCH_IO_SPI_ ## name ## _CONFIG(cs_io) #define ESP_PANEL_TOUCH_SPI_PANEL_IO_CONFIG(name, cs_io) _ESP_PANEL_TOUCH_SPI_PANEL_IO_CONFIG(name, cs_io) /** * @brief Formater for single LCD vendor command with 8-bit parameter * - * @param delay_ms Delay in milliseconds after this command - * @param command LCD command + * @param[in] delay_ms Delay in milliseconds after this command + * @param[in] command LCD command * @param ... Array of 8-bit command parameters, should be like `{data0, data1, data2, ...}` * */ @@ -55,8 +73,8 @@ /** * @brief Formater for single LCD vendor command with no parameter * - * @param delay_ms Delay in milliseconds after this command - * @param command LCD command + * @param[in] delay_ms Delay in milliseconds after this command + * @param[in] command LCD command * */ #define ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command) {command, (uint8_t []){ 0x00 }, 0, delay_ms} diff --git a/src/ESP_PanelVersions.h b/src/ESP_PanelVersions.h index 94c3aa34..c31073b8 100644 --- a/src/ESP_PanelVersions.h +++ b/src/ESP_PanelVersions.h @@ -21,7 +21,7 @@ /* File `ESP_Panel_Board_Custom.h` */ #define ESP_PANEL_BOARD_CUSTOM_VERSION_MAJOR 0 #define ESP_PANEL_BOARD_CUSTOM_VERSION_MINOR 1 -#define ESP_PANEL_BOARD_CUSTOM_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_VERSION_PATCH 2 /* File `ESP_Panel_Board_Supported.h` */ #define ESP_PANEL_BOARD_SUPPORTED_VERSION_MAJOR 0 diff --git a/src/board/jingcai/ESP32_4848S040C_I_Y_3.h b/src/board/jingcai/ESP32_4848S040C_I_Y_3.h index 7178fd61..02bc2323 100644 --- a/src/board/jingcai/ESP32_4848S040C_I_Y_3.h +++ b/src/board/jingcai/ESP32_4848S040C_I_Y_3.h @@ -43,7 +43,7 @@ */ #if ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB - #define ESP_PANEL_LCD_RGB_CLK_HZ (11 * 1000 * 1000) + #define ESP_PANEL_LCD_RGB_CLK_HZ (26 * 1000 * 1000) #define ESP_PANEL_LCD_RGB_HPW (10) #define ESP_PANEL_LCD_RGB_HBP (10) #define ESP_PANEL_LCD_RGB_HFP (20) diff --git a/src/bus/I2C.cpp b/src/bus/I2C.cpp index 2eb2262a..c13f2c84 100644 --- a/src/bus/I2C.cpp +++ b/src/bus/I2C.cpp @@ -97,6 +97,11 @@ void ESP_PanelBus_I2C::configI2cFlags(bool dc_low_on_data, bool disable_control_ io_config.flags.disable_control_phase = disable_control_phase; } +uint32_t ESP_PanelBus_I2C::getI2cAddress(void) +{ + return io_config.dev_addr; +} + bool ESP_PanelBus_I2C::begin(void) { ESP_PANEL_ENABLE_TAG_DEBUG_LOG(); diff --git a/src/bus/I2C.h b/src/bus/I2C.h index 496a83c3..8721ed20 100644 --- a/src/bus/I2C.h +++ b/src/bus/I2C.h @@ -72,6 +72,8 @@ class ESP_PanelBus_I2C: public ESP_PanelBus { void configI2cParamBits(uint32_t num); void configI2cFlags(bool dc_low_on_data, bool disable_control_phase); + uint32_t getI2cAddress(void); + /** * @brief Startup the bus * diff --git a/src/touch/ESP_PanelTouch.cpp b/src/touch/ESP_PanelTouch.cpp index 1ea7fcc9..64e93065 100644 --- a/src/touch/ESP_PanelTouch.cpp +++ b/src/touch/ESP_PanelTouch.cpp @@ -211,6 +211,16 @@ int ESP_PanelTouch::readButtonState(uint8_t n, int timeout_ms) return getButtonState(n); } +void ESP_PanelTouch::configResetActiveLevel(uint8_t level) +{ + config.levels.reset = level; +} + +void ESP_PanelTouch::configInterruptActiveLevel(uint8_t level) +{ + config.levels.interrupt = level; +} + bool ESP_PanelTouch::isInterruptEnabled(void) { return (config.interrupt_callback == onTouchInterrupt); diff --git a/src/touch/ESP_PanelTouch.h b/src/touch/ESP_PanelTouch.h index eb78aac0..3ea8662b 100644 --- a/src/touch/ESP_PanelTouch.h +++ b/src/touch/ESP_PanelTouch.h @@ -32,6 +32,7 @@ .process_coordinates = NULL, \ .interrupt_callback = NULL, \ .user_data = NULL, \ + .driver_data = NULL, \ } /** @@ -230,6 +231,20 @@ class ESP_PanelTouch { */ int readButtonState(uint8_t index = 0, int timeout_ms = 0); + /** + * @brief Configure the active level of reset signal + * + * @param level 1: high level, 0: low level + */ + void configResetActiveLevel(uint8_t level); + + /** + * @brief Configure the active level of interrupt signal + * + * @param level 1: high level, 0: low level + */ + void configInterruptActiveLevel(uint8_t level); + /** * @brief Check if the interrupt function is enabled * diff --git a/src/touch/GT911.cpp b/src/touch/GT911.cpp index 10813c8b..cc3a06f8 100644 --- a/src/touch/GT911.cpp +++ b/src/touch/GT911.cpp @@ -9,8 +9,7 @@ static const char *TAG = "GT911_CPP"; -ESP_PanelTouch_GT911::ESP_PanelTouch_GT911(ESP_PanelBus *bus, uint16_t width, uint16_t height, - int rst_io, int int_io): +ESP_PanelTouch_GT911::ESP_PanelTouch_GT911(ESP_PanelBus *bus, uint16_t width, uint16_t height, int rst_io, int int_io): ESP_PanelTouch(bus, width, height, rst_io, int_io) { } @@ -38,8 +37,19 @@ ESP_PanelTouch_GT911::~ESP_PanelTouch_GT911() bool ESP_PanelTouch_GT911::begin(void) { + ESP_PANEL_ENABLE_TAG_DEBUG_LOG(); + ESP_PANEL_CHECK_NULL_RET(bus, false, "Invalid bus"); + ESP_PanelBus_I2C *i2c_bus = static_cast(bus); + esp_lcd_touch_io_gt911_config_t tp_gt911_config = { + .dev_addr = i2c_bus->getI2cAddress(), + }; + if (config.driver_data == NULL) { + ESP_LOGD(TAG, "Use default GT911 driver data(address: 0x%02x)", tp_gt911_config.dev_addr); + config.driver_data = (void *)&tp_gt911_config; + } + ESP_PANEL_CHECK_ERR_RET(esp_lcd_touch_new_i2c_gt911(bus->getHandle(), &config, &handle), false, "New driver failed"); return true; diff --git a/src/touch/GT911.h b/src/touch/GT911.h index 8cf1c240..73d55449 100644 --- a/src/touch/GT911.h +++ b/src/touch/GT911.h @@ -8,6 +8,7 @@ #include "base/esp_lcd_touch_gt911.h" #include "ESP_PanelTouch.h" +#include "bus/I2C.h" /** * @brief GT911 touch device object class @@ -19,19 +20,20 @@ class ESP_PanelTouch_GT911 : public ESP_PanelTouch { /** * @brief Construct a new touch device in a simple way, the `init()` function should be called after this function * - * @param bus Pointer to panel bus - * @param width The width of the touch screen - * @param height The height of the touch screen - * @param rst_io The reset pin of the touch screen, set to `-1` if not used - * @param int_io The interrupt pin of the touch screen, set to `-1` if not used + * @param bus Pointer to panel bus + * @param width The width of the touch screen + * @param height The height of the touch screen + * @param rst_io The reset pin of the touch screen, set to `-1` if not used + * @param int_io The interrupt pin of the touch screen, set to `-1` if not used */ ESP_PanelTouch_GT911(ESP_PanelBus *bus, uint16_t width, uint16_t height, int rst_io = -1, int int_io = -1); /** * @brief Construct a new touch device in a complex way, the `init()` function should be called after this function * - * @param bus Pointer to panel bus - * @param config Touch device configuration + * @param bus Pointer to panel bus + * @param config Touch device configuration + * @param address The address of the touch device, default set to `0` to use the default address */ ESP_PanelTouch_GT911(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config); diff --git a/src/touch/base/esp_lcd_touch.h b/src/touch/base/esp_lcd_touch.h index 048a6f97..96b354a7 100644 --- a/src/touch/base/esp_lcd_touch.h +++ b/src/touch/base/esp_lcd_touch.h @@ -27,7 +27,7 @@ extern "C" { #define ESP_LCD_TOUCH_VER_MAJOR (1) #define ESP_LCD_TOUCH_VER_MINOR (1) -#define ESP_LCD_TOUCH_VER_PATCH (1) +#define ESP_LCD_TOUCH_VER_PATCH (2) #define CONFIG_ESP_LCD_TOUCH_MAX_POINTS (ESP_PANEL_TOUCH_MAX_POINTS) #define CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS (ESP_PANEL_TOUCH_MAX_BUTTONS) @@ -69,10 +69,12 @@ typedef struct { /*!< User callback called after get coordinates from touch controller for apply user adjusting */ void (*process_coordinates)(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num); - /*!< User callback called after the touch interrupt occured */ + /*!< User callback called after the touch interrupt occurred */ esp_lcd_touch_interrupt_callback_t interrupt_callback; /*!< User data passed to callback */ void *user_data; + /*!< User data passed to driver */ + void *driver_data; } esp_lcd_touch_config_t; typedef struct { @@ -387,7 +389,7 @@ esp_err_t esp_lcd_touch_get_mirror_y(esp_lcd_touch_handle_t tp, bool *mirror); esp_err_t esp_lcd_touch_del(esp_lcd_touch_handle_t tp); /** - * @brief Register user callback called after the touch interrupt occured + * @brief Register user callback called after the touch interrupt occurred * * @param tp: Touch handler * @param callback: Interrupt callback @@ -398,7 +400,7 @@ esp_err_t esp_lcd_touch_del(esp_lcd_touch_handle_t tp); esp_err_t esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_handle_t tp, esp_lcd_touch_interrupt_callback_t callback); /** - * @brief Register user callback called after the touch interrupt occured with user data + * @brief Register user callback called after the touch interrupt occurred with user data * * @param tp: Touch handler * @param callback: Interrupt callback diff --git a/src/touch/base/esp_lcd_touch_gt911.c b/src/touch/base/esp_lcd_touch_gt911.c index c458cd7c..2b11c8ac 100644 --- a/src/touch/base/esp_lcd_touch_gt911.c +++ b/src/touch/base/esp_lcd_touch_gt911.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,7 +18,6 @@ #include "driver/i2c.h" #include "esp_lcd_panel_io.h" #include "esp_lcd_touch.h" - #include "esp_lcd_touch_gt911.h" static const char *TAG = "GT911"; @@ -70,6 +69,9 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const ESP_PANEL_ENABLE_TAG_DEBUG_LOG(); + ESP_LOGI(TAG, "LCD touch panel create success, version: %d.%d.%d", ESP_LCD_TOUCH_GT911_VER_MAJOR, + ESP_LCD_TOUCH_GT911_VER_MINOR, ESP_LCD_TOUCH_GT911_VER_PATCH); + /* Prepare main structure */ esp_lcd_touch_handle_t esp_lcd_touch_gt911 = heap_caps_calloc(1, sizeof(esp_lcd_touch_t), MALLOC_CAP_DEFAULT); ESP_GOTO_ON_FALSE(esp_lcd_touch_gt911, ESP_ERR_NO_MEM, err, TAG, "no mem for GT911 controller"); @@ -92,6 +94,57 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const /* Save config */ memcpy(&esp_lcd_touch_gt911->config, config, sizeof(esp_lcd_touch_config_t)); + esp_lcd_touch_io_gt911_config_t *gt911_config = (esp_lcd_touch_io_gt911_config_t *)esp_lcd_touch_gt911->config.driver_data; + + /* Prepare pin for touch controller reset */ + if (esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC) { + const gpio_config_t rst_gpio_config = { + .mode = GPIO_MODE_OUTPUT, + .pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.rst_gpio_num) + }; + ret = gpio_config(&rst_gpio_config); + ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed"); + } + + if (gt911_config && esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC && esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) { + /* Prepare pin for touch controller int */ + const gpio_config_t int_gpio_config = { + .mode = GPIO_MODE_OUTPUT, + .intr_type = GPIO_INTR_DISABLE, + .pull_down_en = 0, + .pull_up_en = 1, + .pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.int_gpio_num), + }; + ret = gpio_config(&int_gpio_config); + ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed"); + + ESP_RETURN_ON_ERROR(gpio_set_level(esp_lcd_touch_gt911->config.rst_gpio_num, esp_lcd_touch_gt911->config.levels.reset), TAG, "GPIO set level error!"); + ESP_RETURN_ON_ERROR(gpio_set_level(esp_lcd_touch_gt911->config.int_gpio_num, 0), TAG, "GPIO set level error!"); + vTaskDelay(pdMS_TO_TICKS(10)); + + /* Select I2C addr, set output high or low */ + uint32_t gpio_level; + if (ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP == gt911_config->dev_addr) { + gpio_level = 1; + } else if (ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS == gt911_config->dev_addr) { + gpio_level = 0; + } else { + gpio_level = 0; + ESP_LOGE(TAG, "Addr (0x%X) is invalid", gt911_config->dev_addr); + } + ESP_RETURN_ON_ERROR(gpio_set_level(esp_lcd_touch_gt911->config.int_gpio_num, gpio_level), TAG, "GPIO set level error!"); + vTaskDelay(pdMS_TO_TICKS(1)); + + ESP_RETURN_ON_ERROR(gpio_set_level(esp_lcd_touch_gt911->config.rst_gpio_num, !esp_lcd_touch_gt911->config.levels.reset), TAG, "GPIO set level error!"); + vTaskDelay(pdMS_TO_TICKS(10)); + + vTaskDelay(pdMS_TO_TICKS(50)); + } else { + ESP_LOGW(TAG, "Unable to initialize the I2C address"); + /* Reset controller */ + ret = touch_gt911_reset(esp_lcd_touch_gt911); + ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 reset failed"); + } /* Prepare pin for touch interrupt */ if (esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) { @@ -109,20 +162,6 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const } } - /* Prepare pin for touch controller reset */ - if (esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC) { - const gpio_config_t rst_gpio_config = { - .mode = GPIO_MODE_OUTPUT, - .pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.rst_gpio_num) - }; - ret = gpio_config(&rst_gpio_config); - ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed"); - } - - /* Reset controller */ - ret = touch_gt911_reset(esp_lcd_touch_gt911); - ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 reset failed"); - /* Read status and config info */ ret = touch_gt911_read_cfg(esp_lcd_touch_gt911); ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 init failed"); @@ -133,14 +172,10 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const if (esp_lcd_touch_gt911) { esp_lcd_touch_gt911_del(esp_lcd_touch_gt911); } - return ret; } *out_touch = esp_lcd_touch_gt911; - ESP_LOGI(TAG, "LCD touch panel create success, version: %d.%d.%d", ESP_LCD_TOUCH_GT911_VER_MAJOR, ESP_LCD_TOUCH_GT911_VER_MINOR, - ESP_LCD_TOUCH_GT911_VER_PATCH); - return ret; } diff --git a/src/touch/base/esp_lcd_touch_gt911.h b/src/touch/base/esp_lcd_touch_gt911.h index 2e9ef120..a1849cfd 100644 --- a/src/touch/base/esp_lcd_touch_gt911.h +++ b/src/touch/base/esp_lcd_touch_gt911.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,7 +19,7 @@ extern "C" { #define ESP_LCD_TOUCH_GT911_VER_MAJOR (1) #define ESP_LCD_TOUCH_GT911_VER_MINOR (1) -#define ESP_LCD_TOUCH_GT911_VER_PATCH (0) +#define ESP_LCD_TOUCH_GT911_VER_PATCH (1) /** * @brief Create a new GT911 touch driver @@ -45,6 +45,14 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const #define ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS (0x5D) #define ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP (0x14) +/** + * @brief GT911 Configuration Type + * + */ +typedef struct { + uint8_t dev_addr; /*!< I2C device address */ +} esp_lcd_touch_io_gt911_config_t; + /** * @brief Touch IO configuration structure * @@ -61,6 +69,24 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const } \ } +/** + * @brief Touch IO configuration structure with input address + * + * @param[in] addr I2C address of the touch panel + * + */ +#define ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG_WITH_ADDR(addr) \ + { \ + .dev_addr = addr, \ + .control_phase_bytes = 1, \ + .dc_bit_offset = 0, \ + .lcd_cmd_bits = 16, \ + .flags = \ + { \ + .disable_control_phase = 1, \ + } \ + } + #ifdef __cplusplus } #endif