From 0b685f83c3e3f755d2e931aa402962118e94c06c Mon Sep 17 00:00:00 2001 From: VIEWE-CN Date: Wed, 7 May 2025 15:01:05 +0800 Subject: [PATCH] feat(board & touch):add new supported viewe board and cst820 touch --- .../esp_panel_board_config_supported.h | 24 ++ .../esp_panel_board_kconfig_supported.h | 48 +++ .../supported/viewe/BOARD_VIEWE_SMARTRING.h | 313 ++++++++++++++ .../viewe/BOARD_VIEWE_UEDX24240013_MD50E.h | 359 ++++++++++++++++ .../viewe/BOARD_VIEWE_UEDX46460015_MD50ET.h | 313 ++++++++++++++ .../viewe/BOARD_VIEWE_UEDX48480021_MD80E.h | 369 +++++++++++++++++ .../viewe/BOARD_VIEWE_UEDX48480021_MD80ET.h | 382 ++++++++++++++++++ .../viewe/BOARD_VIEWE_UEDX48480021_MD80E_V2.h | 382 ++++++++++++++++++ .../viewe/BOARD_VIEWE_UEDX48480028_MD80ET.h | 378 +++++++++++++++++ .../viewe/BOARD_VIEWE_UEDX80480050E_AC_A.h | 296 ++++++++++++++ src/board/supported/viewe/Kconfig.viewe | 38 ++ src/drivers/touch/esp_panel_touch_cst820.cpp | 52 +++ src/drivers/touch/esp_panel_touch_cst820.hpp | 87 ++++ src/drivers/touch/port/esp_lcd_touch_cst820.c | 214 ++++++++++ src/drivers/touch/port/esp_lcd_touch_cst820.h | 62 +++ 15 files changed, 3317 insertions(+) create mode 100644 src/board/supported/viewe/BOARD_VIEWE_SMARTRING.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX24240013_MD50E.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX46460015_MD50ET.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80ET.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E_V2.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX48480028_MD80ET.h create mode 100644 src/board/supported/viewe/BOARD_VIEWE_UEDX80480050E_AC_A.h create mode 100644 src/drivers/touch/esp_panel_touch_cst820.cpp create mode 100644 src/drivers/touch/esp_panel_touch_cst820.hpp create mode 100644 src/drivers/touch/port/esp_lcd_touch_cst820.c create mode 100644 src/drivers/touch/port/esp_lcd_touch_cst820.h diff --git a/src/board/supported/esp_panel_board_config_supported.h b/src/board/supported/esp_panel_board_config_supported.h index 502d28a0..c76d88be 100644 --- a/src/board/supported/esp_panel_board_config_supported.h +++ b/src/board/supported/esp_panel_board_config_supported.h @@ -100,6 +100,13 @@ + defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_7) \ + defined(BOARD_WAVESHARE_ESP32_P4_NANO) \ /* Viewe */ \ + + defined(BOARD_VIEWE_SMARTRING) \ + + defined(BOARD_VIEWE_UEDX24240013_MD50E) \ + + defined(BOARD_VIEWE_UEDX46460015_MD50ET) \ + + defined(BOARD_VIEWE_UEDX48480021_MD80E) \ + + defined(BOARD_VIEWE_UEDX48480021_MD80E_V2) \ + + defined(BOARD_VIEWE_UEDX48480021_MD80ET) \ + + defined(BOARD_VIEWE_UEDX48480028_MD80ET) \ + defined(BOARD_VIEWE_UEDX24320024E_WB_A) \ + defined(BOARD_VIEWE_UEDX24320028E_WB_A) \ + defined(BOARD_VIEWE_UEDX24320035E_WB_A) \ @@ -109,6 +116,7 @@ + defined(BOARD_VIEWE_UEDX80480043E_WB_A) \ + defined(BOARD_VIEWE_UEDX80480050E_WB_A) \ + defined(BOARD_VIEWE_UEDX80480050E_WB_A_2) \ + + defined(BOARD_VIEWE_UEDX80480050E_AC_A) \ + defined(BOARD_VIEWE_UEDX80480070E_WB_A) \ > 1 #error "Multiple boards enabled! Please check file `esp_panel_board_supported_conf.h` and make sure only one board is enabled." @@ -175,6 +183,20 @@ #elif defined(BOARD_WAVESHARE_ESP32_P4_NANO) #include "waveshare/BOARD_WAVESHARE_ESP32_P4_NANO.h" /* Viewe */ + #elif defined(BOARD_VIEWE_SMARTRING) + #include "viewe/BOARD_VIEWE_SMARTRING.h" + #elif defined(BOARD_VIEWE_UEDX24240013_MD50E) + #include "viewe/BOARD_VIEWE_UEDX24240013_MD50E.h" + #elif defined(BOARD_VIEWE_UEDX46460015_MD50ET) + #include "viewe/BOARD_VIEWE_UEDX46460015_MD50ET.h" + #elif defined(BOARD_VIEWE_UEDX48480021_MD80E) + #include "viewe/BOARD_VIEWE_UEDX48480021_MD80E.h" + #elif defined(BOARD_VIEWE_UEDX48480021_MD80E_V2) + #include "viewe/BOARD_VIEWE_UEDX48480021_MD80E_V2.h" + #elif defined(BOARD_VIEWE_UEDX48480021_MD80ET) + #include "viewe/BOARD_VIEWE_UEDX48480021_MD80ET.h" + #elif defined(BOARD_VIEWE_UEDX48480028_MD80ET) + #include "viewe/BOARD_VIEWE_UEDX48480028_MD80ET.h" #elif defined(BOARD_VIEWE_UEDX24320024E_WB_A) #include "viewe/BOARD_VIEWE_UEDX24320024E_WB_A.h" #elif defined(BOARD_VIEWE_UEDX24320028E_WB_A) @@ -193,6 +215,8 @@ #include "viewe/BOARD_VIEWE_UEDX80480050E_WB_A.h" #elif defined(BOARD_VIEWE_UEDX80480050E_WB_A_2) #include "viewe/BOARD_VIEWE_UEDX80480050E_WB_A_2.h" + #elif defined(BOARD_VIEWE_UEDX80480050E_AC_A) + #include "viewe/BOARD_VIEWE_UEDX80480050E_AC_A.h" #elif defined(BOARD_VIEWE_UEDX80480070E_WB_A) #include "viewe/BOARD_VIEWE_UEDX80480070E_WB_A.h" #else diff --git a/src/board/supported/esp_panel_board_kconfig_supported.h b/src/board/supported/esp_panel_board_kconfig_supported.h index 9d9a1789..8cf05bae 100644 --- a/src/board/supported/esp_panel_board_kconfig_supported.h +++ b/src/board/supported/esp_panel_board_kconfig_supported.h @@ -155,6 +155,48 @@ #endif // VIEWE +#ifndef BOARD_VIEWE_SMARTRING + #ifdef CONFIG_BOARD_VIEWE_SMARTRING + #define BOARD_VIEWE_SMARTRING CONFIG_BOARD_VIEWE_SMARTRING + #endif +#endif + +#ifndef BOARD_VIEWE_UEDX24240013_MD50E + #ifdef CONFIG_BOARD_VIEWE_UEDX24240013_MD50E + #define BOARD_VIEWE_UEDX24240013_MD50E CONFIG_BOARD_VIEWE_UEDX24240013_MD50E + #endif +#endif + +#ifndef BOARD_VIEWE_UEDX46460015_MD50ET + #ifdef CONFIG_BOARD_VIEWE_UEDX46460015_MD50ET + #define BOARD_VIEWE_UEDX46460015_MD50ET CONFIG_BOARD_VIEWE_UEDX46460015_MD50ET + #endif +#endif + +#ifndef BOARD_VIEWE_UEDX48480021_MD80E + #ifdef CONFIG_BOARD_VIEWE_UEDX48480021_MD80E + #define BOARD_VIEWE_UEDX48480021_MD80E CONFIG_BOARD_VIEWE_UEDX48480021_MD80E + #endif +#endif + +#ifndef BOARD_VIEWE_UEDX48480021_MD80E_V2 + #ifdef CONFIG_BOARD_VIEWE_UEDX48480021_MD80E_V2 + #define BOARD_VIEWE_UEDX48480021_MD80E_V2 CONFIG_BOARD_VIEWE_UEDX48480021_MD80E_V2 + #endif +#endif + +#ifndef BOARD_VIEWE_UEDX48480021_MD80ET + #ifdef CONFIG_BOARD_VIEWE_UEDX48480021_MD80ET + #define BOARD_VIEWE_UEDX48480021_MD80ET CONFIG_BOARD_VIEWE_UEDX48480021_MD80ET + #endif +#endif + +#ifndef BOARD_VIEWE_UEDX48480028_MD80ET + #ifdef CONFIG_BOARD_VIEWE_UEDX48480028_MD80ET + #define BOARD_VIEWE_UEDX48480028_MD80ET CONFIG_BOARD_VIEWE_UEDX48480028_MD80ET + #endif +#endif + #ifndef BOARD_VIEWE_UEDX24320024E_WB_A #ifdef CONFIG_BOARD_VIEWE_UEDX24320024E_WB_A #define BOARD_VIEWE_UEDX24320024E_WB_A CONFIG_BOARD_VIEWE_UEDX24320024E_WB_A @@ -209,6 +251,12 @@ #endif #endif +#ifndef BOARD_VIEWE_UEDX80480050E_AC_A + #ifdef CONFIG_BOARD_VIEWE_UEDX80480050E_AC_A + #define BOARD_VIEWE_UEDX80480050E_AC_A CONFIG_BOARD_VIEWE_UEDX80480050E_AC_A + #endif +#endif + #ifndef BOARD_VIEWE_UEDX80480070E_WB_A #ifdef CONFIG_BOARD_VIEWE_UEDX80480070E_WB_A #define BOARD_VIEWE_UEDX80480070E_WB_A CONFIG_BOARD_VIEWE_UEDX80480070E_WB_A diff --git a/src/board/supported/viewe/BOARD_VIEWE_SMARTRING.h b/src/board/supported/viewe/BOARD_VIEWE_SMARTRING.h new file mode 100644 index 00000000..8dd3c7e6 --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_SMARTRING.h @@ -0,0 +1,313 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_VIEWE_SMARTRING.h + * @brief Configuration file for Viewe SMARTRING + * @author Viewe@VIEWESMART + * @link https://github.com/VIEWESMART/VIEWE-SMARTRING + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:SMARTRING" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (472) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (466) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER SH8601 + +/** + * @brief LCD bus type selection + * + * Supported bus types: + * - `ESP_PANEL_BUS_TYPE_SPI` + * - `ESP_PANEL_BUS_TYPE_QSPI` + * - `ESP_PANEL_BUS_TYPE_RGB` (ESP32-S3 only) + * - `ESP_PANEL_BUS_TYPE_MIPI_DSI` (ESP32-P4 only) + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_QSPI) + +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) || \ + (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI + +/** + * @brief QSPI bus + */ +/* For general */ +#define ESP_PANEL_BOARD_LCD_QSPI_HOST_ID (1) // Typically set to 1 +#if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST +/* For host */ +#define ESP_PANEL_BOARD_LCD_QSPI_IO_SCK (13) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA0 (12) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA1 (8) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA2 (14) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA3 (9) +#endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST +/* For panel */ +#define ESP_PANEL_BOARD_LCD_QSPI_IO_CS (7) // -1 if not used +#define ESP_PANEL_BOARD_LCD_QSPI_MODE (0) // 0-3, typically set to 0 +#define ESP_PANEL_BOARD_LCD_QSPI_CLK_HZ (40 * 1000 * 1000) + // Should be an integer divisor of 80M, typically set to 40M +#define ESP_PANEL_BOARD_LCD_QSPI_CMD_BITS (32) // Typically set to 32 +#define ESP_PANEL_BOARD_LCD_QSPI_PARAM_BITS (8) // Typically set to 8 + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +/** + * @brief LCD vendor initialization commands + * + * Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for + * initialization sequence code. Please uncomment and change the following macro definitions. Otherwise, the LCD driver + * will use the default initialization sequence code. + * + * The initialization sequence can be specified in two formats: + * 1. Raw format: + * {command, (uint8_t []){data0, data1, ...}, data_size, delay_ms} + * 2. Helper macros: + * - ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, {data0, data1, ...}) + * - ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command) + */ +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ +{ \ + {0xFE, (uint8_t []){0x00}, 0, 0}, \ + {0xC4, (uint8_t []){0x80}, 1, 0}, \ + {0x3A, (uint8_t []){0x55}, 1, 0}, \ + {0x35, (uint8_t []){0x00}, 0, 10}, \ + {0x53, (uint8_t []){0x20}, 1, 10}, \ + {0x51, (uint8_t []){0xFF}, 1, 10}, \ + {0x63, (uint8_t []){0xFF}, 1, 10}, \ + {0x2A, (uint8_t []){0x00,0x06,0x01,0xDD}, 4, 0}, \ + {0x2B, (uint8_t []){0x00,0x00,0x01,0xD1}, 4, 0}, \ + {0x11, (uint8_t []){0x00}, 0, 60}, \ + {0x29, (uint8_t []){0x00}, 0, 0}, \ +} +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (11) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (1) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CST820 + +/** + * @brief Touch bus type selection + * - `ESP_PANEL_BUS_TYPE_SPI` + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (1) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (45) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (41) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (46) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (42) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (0) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (17) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (1) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Pre-begin function for board initialization + * + * @param[in] p Pointer to the board object + * @return true on success, false on failure + */ +#define ESP_PANEL_BOARD_PRE_BEGIN_FUNCTION(p) \ + { \ + constexpr gpio_num_t BL = static_cast(40); \ + gpio_set_direction(BL, GPIO_MODE_OUTPUT); \ + gpio_set_level(BL, 1); \ + return true; \ + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX24240013_MD50E.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX24240013_MD50E.h new file mode 100644 index 00000000..660988dd --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX24240013_MD50E.h @@ -0,0 +1,359 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_VIEWE_UEDX24320013_MD50E.h + * @brief Configuration file for Viewe UEDX24320013-MD50E + * @author Viewe@VIEWESMART + * @link https://github.com/VIEWESMART/UEDX24240013-MD50ESP32_1.3inch-Knob + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX24240013-MD50E" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (240) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (240) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER GC9A01 + +/** + * @brief LCD bus type selection + * + * Supported bus types: + * - `ESP_PANEL_BUS_TYPE_SPI` + * - `ESP_PANEL_BUS_TYPE_QSPI` + * - `ESP_PANEL_BUS_TYPE_RGB` (ESP32-S3 only) + * - `ESP_PANEL_BUS_TYPE_MIPI_DSI` (ESP32-P4 only) + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_SPI) + +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) || \ + (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI + + /** + * @brief SPI bus + */ + /* For general */ + #define ESP_PANEL_BOARD_LCD_SPI_HOST_ID (1) // Typically set to 1 +#if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_LCD_SPI_IO_SCK (1) + #define ESP_PANEL_BOARD_LCD_SPI_IO_MOSI (0) + #define ESP_PANEL_BOARD_LCD_SPI_IO_MISO (-1) // -1 if not used +#endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST + /* For panel */ + #define ESP_PANEL_BOARD_LCD_SPI_IO_CS (10) // -1 if not used + #define ESP_PANEL_BOARD_LCD_SPI_IO_DC (4) + #define ESP_PANEL_BOARD_LCD_SPI_MODE (0) // 0-3. Typically set to 0 + #define ESP_PANEL_BOARD_LCD_SPI_CLK_HZ (40 * 1000 * 1000) + // Should be an integer divisor of 80M, typically set to 40M + #define ESP_PANEL_BOARD_LCD_SPI_CMD_BITS (8) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_SPI_PARAM_BITS (8) // Typically set to 8 + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +/** + * @brief LCD vendor initialization commands + * + * Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for + * initialization sequence code. Please uncomment and change the following macro definitions. Otherwise, the LCD driver + * will use the default initialization sequence code. + * + * The initialization sequence can be specified in two formats: + * 1. Raw format: + * {command, (uint8_t []){data0, data1, ...}, data_size, delay_ms} + * 2. Helper macros: + * - ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, {data0, data1, ...}) + * - ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command) + */ +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ +{ \ + {0xfe, (uint8_t []){0x00}, 0, 0}, \ + {0xef, (uint8_t []){0x00}, 0, 0}, \ + {0xeb, (uint8_t []){0x14}, 1, 0}, \ + {0x84, (uint8_t []){0x60}, 1, 0}, \ + {0x85, (uint8_t []){0xFF}, 1, 0}, \ + {0x86, (uint8_t []){0xFF}, 1, 0}, \ + {0x87, (uint8_t []){0xFF}, 1, 0}, \ + {0x8e, (uint8_t []){0xFF}, 1, 0}, \ + {0x8f, (uint8_t []){0xFF}, 1, 0}, \ + {0x88, (uint8_t []){0x0A}, 1, 0}, \ + {0x89, (uint8_t []){0x21}, 1, 0}, \ + {0x8a, (uint8_t []){0x00}, 1, 0}, \ + {0x8b, (uint8_t []){0x80}, 1, 0}, \ + {0x8c, (uint8_t []){0x01}, 1, 0}, \ + {0x8d, (uint8_t []){0x03}, 1, 0}, \ + {0xb5, (uint8_t []){0x08, 0x09, 0x14, 0x08}, 4, 0}, \ + {0xb6, (uint8_t []){0x00, 0x00}, 2, 0}, \ + {0x36, (uint8_t []){0x48}, 1, 0}, \ + {0x3a, (uint8_t []){0x05}, 1, 0}, \ + {0x90, (uint8_t []){0x08, 0x08, 0x08, 0x08}, 4, 0}, \ + {0xbd, (uint8_t []){0x06}, 1, 0}, \ + {0xba, (uint8_t []){0x01}, 1, 0}, \ + {0xbc, (uint8_t []){0x00}, 1, 0}, \ + {0xff, (uint8_t []){0x60, 0x01, 0x04}, 3, 0}, \ + {0xc3, (uint8_t []){0x13}, 1, 0}, \ + {0xc4, (uint8_t []){0x13}, 1, 0}, \ + {0xc9, (uint8_t []){0x25}, 1, 0}, \ + {0xbe, (uint8_t []){0x11}, 1, 0}, \ + {0xe1, (uint8_t []){0x10, 0x0e}, 2, 0}, \ + {0xdf, (uint8_t []){0x21, 0x0c, 0x02}, 3, 0}, \ + {0xf0, (uint8_t []){0x45, 0x09, 0x08, 0x08, 0x26, 0x2a}, 6, 0}, \ + {0xf1, (uint8_t []){0x43, 0x70, 0x72, 0x36, 0x37, 0x6f}, 6, 0}, \ + {0xf2, (uint8_t []){0x45, 0x09, 0x08, 0x08, 0x26, 0x2a}, 6, 0}, \ + {0xf3, (uint8_t []){0x43, 0x70, 0x72, 0x36, 0x37, 0x6f}, 6, 0}, \ + {0xed, (uint8_t []){0x1b, 0x0b}, 2, 0}, \ + {0xae, (uint8_t []){0x77}, 1, 0}, \ + {0xcd, (uint8_t []){0x63}, 1, 0}, \ + {0x70, (uint8_t []){0x07, 0x07, 0x04, 0x0e, 0x0f, 0x09, 0x07, 0x08, 0x03}, 9, 0}, \ + {0xe8, (uint8_t []){0x34}, 1, 0}, \ + {0x62, (uint8_t []){0x18, 0x0d, 0x71, 0xed, 0x70, 0x70, 0x18, 0x0f, 0x71, 0xef, 0x70, 0x70}, 12, 0}, \ + {0x63, (uint8_t []){0x18, 0x11, 0x71, 0xf1, 0x70, 0x70, 0x18, 0x13, 0x71, 0xf3, 0x70, 0x70}, 12, 0}, \ + {0x64, (uint8_t []){0x28, 0x29, 0xf1, 0x01, 0xf1, 0x00, 0x07}, 7, 0}, \ + {0x66, (uint8_t []){0x3c, 0x00, 0xcd, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00}, 10, 0}, \ + {0x67, (uint8_t []){0x00, 0x3c, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98}, 10, 0}, \ + {0x74, (uint8_t []){0x10, 0x85, 0x80, 0x00, 0x00, 0x4e, 0x00}, 7, 0}, \ + {0x98, (uint8_t []){0x3e, 0x07}, 2, 0}, \ + {0x99, (uint8_t []){0x3e, 0x07}, 2, 0}, \ + {0x35, (uint8_t []){0x00}, 1, 0}, \ + {0x44, (uint8_t []){0x00, 0x4a}, 2, 0}, \ + {0x21, (uint8_t []){0x00}, 0, 0}, \ + {0x2a, (uint8_t []){0x00, 0x00, 0x00, 0xef}, 4, 0}, \ + {0x2b, (uint8_t []){0x00, 0x00, 0x00, 0xef}, 4, 0}, \ + {0x2c, (uint8_t []){0x00}, 0, 0}, \ + {0x11, (uint8_t []){0x00}, 0, 120}, \ + {0x29, (uint8_t []){0x00}, 0, 20}, \ +} +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (1) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (1) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (1) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (0) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CHSC6540 + +/** + * @brief Touch bus type selection + * - `ESP_PANEL_BUS_TYPE_SPI` + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (3) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (1) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (8) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (1) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Pre-begin function for board initialization + * + * @param[in] p Pointer to the board object + * @return true on success, false on failure + */ +// #define ESP_PANEL_BOARD_PRE_BEGIN_FUNCTION(p) \ +// { \ +// constexpr gpio_num_t IM0 = static_cast(47); \ +// constexpr gpio_num_t IM1 = static_cast(48); \ +// gpio_set_direction(IM0, GPIO_MODE_OUTPUT); \ +// gpio_set_direction(IM1, GPIO_MODE_OUTPUT); \ +// gpio_set_level(IM0, 0); \ +// gpio_set_level(IM1, 1); \ +// return true; \ +// } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX46460015_MD50ET.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX46460015_MD50ET.h new file mode 100644 index 00000000..d846d5fd --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX46460015_MD50ET.h @@ -0,0 +1,313 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_VIEWE_UEDX46460015_MD50ET.h + * @brief Configuration file for Viewe UEDX46460015-MD50ET + * @author Viewe@VIEWESMART + * @link https://github.com/VIEWESMART/UEDX46460015-MD50ESP32-1.5inch-Touch-Knob-Display + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX46460015-MD50ET" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (472) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (466) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER SH8601 + +/** + * @brief LCD bus type selection + * + * Supported bus types: + * - `ESP_PANEL_BUS_TYPE_SPI` + * - `ESP_PANEL_BUS_TYPE_QSPI` + * - `ESP_PANEL_BUS_TYPE_RGB` (ESP32-S3 only) + * - `ESP_PANEL_BUS_TYPE_MIPI_DSI` (ESP32-P4 only) + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_QSPI) + +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) || \ + (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI + +/** + * @brief QSPI bus + */ +/* For general */ +#define ESP_PANEL_BOARD_LCD_QSPI_HOST_ID (1) // Typically set to 1 +#if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST +/* For host */ +#define ESP_PANEL_BOARD_LCD_QSPI_IO_SCK (10) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA0 (13) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA1 (11) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA2 (14) +#define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA3 (9) +#endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST +/* For panel */ +#define ESP_PANEL_BOARD_LCD_QSPI_IO_CS (12) // -1 if not used +#define ESP_PANEL_BOARD_LCD_QSPI_MODE (0) // 0-3, typically set to 0 +#define ESP_PANEL_BOARD_LCD_QSPI_CLK_HZ (40 * 1000 * 1000) + // Should be an integer divisor of 80M, typically set to 40M +#define ESP_PANEL_BOARD_LCD_QSPI_CMD_BITS (32) // Typically set to 32 +#define ESP_PANEL_BOARD_LCD_QSPI_PARAM_BITS (8) // Typically set to 8 + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +/** + * @brief LCD vendor initialization commands + * + * Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for + * initialization sequence code. Please uncomment and change the following macro definitions. Otherwise, the LCD driver + * will use the default initialization sequence code. + * + * The initialization sequence can be specified in two formats: + * 1. Raw format: + * {command, (uint8_t []){data0, data1, ...}, data_size, delay_ms} + * 2. Helper macros: + * - ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, {data0, data1, ...}) + * - ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command) + */ +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ +{ \ + {0xFE, (uint8_t []){0x00}, 0, 0}, \ + {0xC4, (uint8_t []){0x80}, 1, 0}, \ + {0x3A, (uint8_t []){0x55}, 1, 0}, \ + {0x35, (uint8_t []){0x00}, 0, 10}, \ + {0x53, (uint8_t []){0x20}, 1, 10}, \ + {0x51, (uint8_t []){0xFF}, 1, 10}, \ + {0x63, (uint8_t []){0xFF}, 1, 10}, \ + {0x2A, (uint8_t []){0x00,0x06,0x01,0xDD}, 4, 0}, \ + {0x2B, (uint8_t []){0x00,0x00,0x01,0xD1}, 4, 0}, \ + {0x11, (uint8_t []){0x00}, 0, 60}, \ + {0x29, (uint8_t []){0x00}, 0, 0}, \ +} +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (8) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (1) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CST820 + +/** + * @brief Touch bus type selection + * - `ESP_PANEL_BUS_TYPE_SPI` + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (1) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (3) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (1) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (0) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (17) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (1) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Pre-begin function for board initialization + * + * @param[in] p Pointer to the board object + * @return true on success, false on failure + */ +#define ESP_PANEL_BOARD_PRE_BEGIN_FUNCTION(p) \ + { \ + constexpr gpio_num_t BL = static_cast(17); \ + gpio_set_direction(BL, GPIO_MODE_OUTPUT); \ + gpio_set_level(BL, 1); \ + return true; \ + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E.h new file mode 100644 index 00000000..bff0f4f7 --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E.h @@ -0,0 +1,369 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_VIEWE_UEDX48480021_MD80E.h + * @brief Configuration file for Viewe UEDX48480021-MD80E + * @author Viewe@VIEWESMART + * @link https://github.com/VIEWESMART/UEDX48480021-MD80ESP32_2.1inch-Knob + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX48480021-MD80E" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (480) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (480) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER GC9503 + +/** + * @brief LCD bus type selection + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_RGB) + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB + + /** + * @brief RGB bus + */ + /** + * Set to 0 if using simple "RGB" interface which does not contain "3-wire SPI" interface. + */ + #define ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL (1) // 0/1. Typically set to 1 + +#if ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For control panel (3wire-SPI) */ + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_CS (18) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SCK (13) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SDA (12) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CS_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SCL_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SDA_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_MODE (0) // 0-3, typically set to 0 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CMD_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_PARAM_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_USE_DC_BIT (1) // 0/1. Typically set to 1 +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For refresh panel (RGB) */ + #define ESP_PANEL_BOARD_LCD_RGB_CLK_HZ (16 * 1000 * 1000) + // To increase the upper limit of the PCLK, see: https://docs.espressif.com/projects/esp-faq/en/latest/software-framework/peripherals/lcd.html#how-can-i-increase-the-upper-limit-of-pclk-settings-on-esp32-s3-while-ensuring-normal-rgb-screen-display + #define ESP_PANEL_BOARD_LCD_RGB_HPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_HBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_HFP (40) + #define ESP_PANEL_BOARD_LCD_RGB_VPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_VBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_VFP (50) + #define ESP_PANEL_BOARD_LCD_RGB_PCLK_ACTIVE_NEG (0) // 0: rising edge, 1: falling edge. Typically set to 0 + // The following sheet shows the valid combinations of + // data width and pixel bits: + // ┏---------------------------------┳- -------------------------------┓ + #define ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH (16) // | 16 | 8 | + #define ESP_PANEL_BOARD_LCD_RGB_PIXEL_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) // | ESP_PANEL_LCD_COLOR_BITS_RGB565 | ESP_PANEL_LCD_COLOR_BITS_RGB888 | + // ┗---------------------------------┻---------------------------------┛ + // To understand color format of RGB LCD, see: https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/rgb_lcd.html#color-formats + #define ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_BOARD_WIDTH * 10) + // Bounce buffer size in bytes. It is used to avoid screen drift + // for ESP32-S3. Typically set to `ESP_PANEL_BOARD_WIDTH * 10` + // The size should satisfy `size * N = LCD_width * LCD_height`, + // where N is an even number. + // For more details, see: https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/FAQ.md#how-to-fix-screen-drift-issue-when-driving-rgb-lcd-with-esp32-s3 + #define ESP_PANEL_BOARD_LCD_RGB_IO_HSYNC (46) + #define ESP_PANEL_BOARD_LCD_RGB_IO_VSYNC (3) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DE (17) // -1 if not used + #define ESP_PANEL_BOARD_LCD_RGB_IO_PCLK (9) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DISP (-1) // -1 if not used. Typically set to -1 + + // The following sheet shows the mapping of ESP GPIOs to + // LCD data pins with different data width and color format: + // ┏------┳- ------------┳--------------------------┓ + // | ESP: | 8-bit RGB888 | 16-bit RGB565 | + // |------|--------------|--------------------------| + // | LCD: | RGB888 | RGB565 | RGB666 | RGB888 | + // ┗------|--------------|--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA0 (10) // | D0 | B0 | B0-1 | B0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA1 (11) // | D1 | B1 | B2 | B4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA2 (12) // | D2 | B2 | B3 | B5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA3 (13) // | D3 | B3 | B4 | B6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA4 (14) // | D4 | B4 | B5 | B7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA5 (21) // | D5 | G0 | G0 | G0-2 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA6 (47) // | D6 | G1 | G1 | G3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA7 (48) // | D7 | G2 | G2 | G4 | +#if ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH > 8 // ┗--------------┫--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA8 (45) // | G3 | G3 | G5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA9 (38) // | G4 | G4 | G6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA10 (39) // | G5 | G5 | G7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA11 (40) // | R0 | R0-1 | R0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA12 (41) // | R1 | R2 | R4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA13 (42) // | R2 | R3 | R5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA14 (2) // | R3 | R4 | R6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA15 (1) // | R4 | R5 | R7 | + // ┗--------┻--------┻--------┛ +#endif // ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ +{ \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xF0, {0x55, 0xAA, 0x52, 0x08, 0x00}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xF6, {0x5A, 0x87}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x3F}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xCD, {0x25}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xCD, {0x00}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC9, {0x10}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xF8, {0x8A}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xAC, {0x45}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xA7, {0x47}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xA0, {0xDD}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x87, {0x04, 0x03, 0x66}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x86, {0x99, 0xa3, 0xa3, 0x51}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFA, {0x08, 0x08, 0x08, 0x04}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x9A, {0x8a}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x9B, {0x62}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x82, {0x48, 0x48}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xB1, {0x10}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x7A, {0x13, 0x1A}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x7B, {0x13, 0x1A}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x6D, {0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x02, 0x0b, 0x01, 0x00, 0x1f, 0x1e, 0x09, 0x0f, 0x1e, 0x1e, 0x1e, 0x1e, 0x10, 0x0a, 0x1e, 0x1f, 0x00, 0x08, 0x0b, 0x02, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x64, {0x18, 0x07, 0x01, 0xE7, 0x03, 0x03, 0x18, 0x06, 0x01, 0xE6, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x65, {0x58, 0x26, 0x18, 0x2c, 0x03, 0x03, 0x58, 0x26, 0x18, 0x2c, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x66, {0x58, 0x26, 0x18, 0x2c, 0x03, 0x03, 0x58, 0x26, 0x18, 0x2c, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x67, {0x18, 0x05, 0x01, 0xE5, 0x03, 0x03, 0x18, 0x04, 0x01, 0xE4, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x60, {0x18, 0x09, 0x7A, 0x7A, 0x51, 0xF1, 0x7A, 0x7A}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0x63, {0x51, 0xF1, 0x7A, 0x7A, 0x18, 0x08, 0x7A, 0x7A}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xD1, {0x00, 0x00, 0x00, 0x0E, 0x00, 0x31, 0x00, 0x4E, 0x00, 0x67, 0x00, 0x92, 0x00, 0xB5, 0x00, 0xED, 0x01, 0x1C, 0x01, 0x66, 0x01, 0xA4, 0x02, 0x04, 0x02, 0x53, 0x02, 0x56, 0x02, 0x9F, 0x02, 0xF3, 0x03, 0x29, 0x03, 0x73, 0x03, 0xA1, 0x03, 0xB9, 0x03, 0xC8, 0x03, 0xDB, 0x03, 0xE7, 0x03, 0xF4, 0x03, 0xFB, 0x03, 0XFF}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xD2, {0x00, 0x00, 0x00, 0x0E, 0x00, 0x31, 0x00, 0x4E, 0x00, 0x67, 0x00, 0x92, 0x00, 0xB5, 0x00, 0xED, 0x01, 0x1C, 0x01, 0x66, 0x01, 0xA4, 0x02, 0x04, 0x02, 0x53, 0x02, 0x56, 0x02, 0x9F, 0x02, 0xF3, 0x03, 0x29, 0x03, 0x73, 0x03, 0xA1, 0x03, 0xB9, 0x03, 0xC8, 0x03, 0xDB, 0x03, 0xE7, 0x03, 0xF4, 0x03, 0xFB, 0x03, 0XFF}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xD3, {0x00, 0x00, 0x00, 0x0E, 0x00, 0x31, 0x00, 0x4E, 0x00, 0x67, 0x00, 0x92, 0x00, 0xB5, 0x00, 0xED, 0x01, 0x1C, 0x01, 0x66, 0x01, 0xA4, 0x02, 0x04, 0x02, 0x53, 0x02, 0x56, 0x02, 0x9F, 0x02, 0xF3, 0x03, 0x29, 0x03, 0x73, 0x03, 0xA1, 0x03, 0xB9, 0x03, 0xC8, 0x03, 0xDB, 0x03, 0xE7, 0x03, 0xF4, 0x03, 0xFB, 0x03, 0XFF}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xD4, {0x00, 0x00, 0x00, 0x0E, 0x00, 0x31, 0x00, 0x4E, 0x00, 0x67, 0x00, 0x92, 0x00, 0xB5, 0x00, 0xED, 0x01, 0x1C, 0x01, 0x66, 0x01, 0xA4, 0x02, 0x04, 0x02, 0x53, 0x02, 0x56, 0x02, 0x9F, 0x02, 0xF3, 0x03, 0x29, 0x03, 0x73, 0x03, 0xA1, 0x03, 0xB9, 0x03, 0xC8, 0x03, 0xDB, 0x03, 0xE7, 0x03, 0xF4, 0x03, 0xFB, 0x03, 0XFF}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xD5, {0x00, 0x00, 0x00, 0x0E, 0x00, 0x31, 0x00, 0x4E, 0x00, 0x67, 0x00, 0x92, 0x00, 0xB5, 0x00, 0xED, 0x01, 0x1C, 0x01, 0x66, 0x01, 0xA4, 0x02, 0x04, 0x02, 0x53, 0x02, 0x56, 0x02, 0x9F, 0x02, 0xF3, 0x03, 0x29, 0x03, 0x73, 0x03, 0xA1, 0x03, 0xB9, 0x03, 0xC8, 0x03, 0xDB, 0x03, 0xE7, 0x03, 0xF4, 0x03, 0xFB, 0x03, 0XFF}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xD6, {0x00, 0x00, 0x00, 0x0E, 0x00, 0x31, 0x00, 0x4E, 0x00, 0x67, 0x00, 0x92, 0x00, 0xB5, 0x00, 0xED, 0x01, 0x1C, 0x01, 0x66, 0x01, 0xA4, 0x02, 0x04, 0x02, 0x53, 0x02, 0x56, 0x02, 0x9F, 0x02, 0xF3, 0x03, 0x29, 0x03, 0x73, 0x03, 0xA1, 0x03, 0xB9, 0x03, 0xC8, 0x03, 0xDB, 0x03, 0xE7, 0x03, 0xF4, 0x03, 0xFB, 0x03, 0XFF}), \ + ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x11), \ + ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29), \ +} + +/** + * @brief LCD specific flags configuration + * + * These flags are specific to the "3-wire SPI + RGB" bus. + */ +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB) && ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL +/** + * @brief Enable IO multiplex + * + * Set to 1 if the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs. Then, the control panel + * and its pins (except CS signal) will be released after LCD call `init()`. All `*_by_cmd` flags will be invalid. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX (1) // typically set to 0 +/** + * @brief Mirror by command + * + * Set to 1 if the `mirror()` function will be implemented by LCD command. Otherwise, the function will be implemented by + * software. Only valid when `ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX` is 0. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_MIRROR_BY_CMD (!ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX) +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB888) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (8) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (0) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER FT5x06 + +/** + * @brief Touch bus type selection + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (41) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (40) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (7) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (0) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (0) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80ET.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80ET.h new file mode 100644 index 00000000..9b1e6dcf --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80ET.h @@ -0,0 +1,382 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_VIEWE_UEDX48480021_MD80ET.h + * @brief Configuration file for Viewe UEDX48480021-MD80ET + * @author Viewe@VIEWESMART + * @link https://github.com/VIEWESMART/UEDX48480021-MD80ESP32-2.1inch-Touch-Knob-Display + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX48480021-MD80ET" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (480) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (480) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER GC9503 + +/** + * @brief LCD bus type selection + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_RGB) + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB + + /** + * @brief RGB bus + */ + /** + * Set to 0 if using simple "RGB" interface which does not contain "3-wire SPI" interface. + */ + #define ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL (1) // 0/1. Typically set to 1 + + #if ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For control panel (3wire-SPI) */ + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_CS (18) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SCK (13) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SDA (12) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CS_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SCL_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SDA_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_MODE (0) // 0-3, typically set to 0 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CMD_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_PARAM_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_USE_DC_BIT (1) // 0/1. Typically set to 1 +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For refresh panel (RGB) */ + #define ESP_PANEL_BOARD_LCD_RGB_CLK_HZ (16 * 1000 * 1000) + // To increase the upper limit of the PCLK, see: https://docs.espressif.com/projects/esp-faq/en/latest/software-framework/peripherals/lcd.html#how-can-i-increase-the-upper-limit-of-pclk-settings-on-esp32-s3-while-ensuring-normal-rgb-screen-display + #define ESP_PANEL_BOARD_LCD_RGB_HPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_HBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_HFP (40) + #define ESP_PANEL_BOARD_LCD_RGB_VPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_VBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_VFP (50) + #define ESP_PANEL_BOARD_LCD_RGB_PCLK_ACTIVE_NEG (0) // 0: rising edge, 1: falling edge. Typically set to 0 + // The following sheet shows the valid combinations of + // data width and pixel bits: + // ┏---------------------------------┳- -------------------------------┓ + #define ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH (16) // | 16 | 8 | + #define ESP_PANEL_BOARD_LCD_RGB_PIXEL_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) // | ESP_PANEL_LCD_COLOR_BITS_RGB565 | ESP_PANEL_LCD_COLOR_BITS_RGB888 | + // ┗---------------------------------┻---------------------------------┛ + // To understand color format of RGB LCD, see: https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/rgb_lcd.html#color-formats + #define ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_BOARD_WIDTH * 10) + // Bounce buffer size in bytes. It is used to avoid screen drift + // for ESP32-S3. Typically set to `ESP_PANEL_BOARD_WIDTH * 10` + // The size should satisfy `size * N = LCD_width * LCD_height`, + // where N is an even number. + // For more details, see: https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/FAQ.md#how-to-fix-screen-drift-issue-when-driving-rgb-lcd-with-esp32-s3 + #define ESP_PANEL_BOARD_LCD_RGB_IO_HSYNC (46) + #define ESP_PANEL_BOARD_LCD_RGB_IO_VSYNC (3) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DE (17) // -1 if not used + #define ESP_PANEL_BOARD_LCD_RGB_IO_PCLK (9) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DISP (-1) // -1 if not used. Typically set to -1 + + // The following sheet shows the mapping of ESP GPIOs to + // LCD data pins with different data width and color format: + // ┏------┳- ------------┳--------------------------┓ + // | ESP: | 8-bit RGB888 | 16-bit RGB565 | + // |------|--------------|--------------------------| + // | LCD: | RGB888 | RGB565 | RGB666 | RGB888 | + // ┗------|--------------|--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA0 (10) // | D0 | B0 | B0-1 | B0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA1 (11) // | D1 | B1 | B2 | B4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA2 (12) // | D2 | B2 | B3 | B5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA3 (13) // | D3 | B3 | B4 | B6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA4 (14) // | D4 | B4 | B5 | B7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA5 (21) // | D5 | G0 | G0 | G0-2 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA6 (47) // | D6 | G1 | G1 | G3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA7 (48) // | D7 | G2 | G2 | G4 | +#if ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH > 8 // ┗--------------┫--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA8 (45) // | G3 | G3 | G5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA9 (38) // | G4 | G4 | G6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA10 (39) // | G5 | G5 | G7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA11 (40) // | R0 | R0-1 | R0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA12 (41) // | R1 | R2 | R4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA13 (42) // | R2 | R3 | R5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA14 (2) // | R3 | R4 | R6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA15 (1) // | R4 | R5 | R7 | + // ┗--------┻--------┻--------┛ +#endif // ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ + { \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0}, \ + {0xEF, (uint8_t[]){0x08}, 1, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0}, \ + {0xC0, (uint8_t[]){0x3B, 0x00}, 2, 0}, \ + {0xC1, (uint8_t[]){0x0B, 0x02}, 2, 0}, \ + {0xC2, (uint8_t[]){0x07, 0x02}, 2, 0}, \ + {0xC7, (uint8_t[]){0x00}, 1, 0}, \ + {0xCC, (uint8_t[]){0x10}, 1, 0}, \ + {0xCD, (uint8_t[]){0x08}, 1, 0}, \ + {0xB0, (uint8_t[]){0x00, 0x11, 0x16, 0x0E, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31, 0x18}, 16, 0}, \ + {0xB1, (uint8_t[]){0x00, 0x11, 0x16, 0x0E, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2A, 0x31, 0x18}, 16, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x11}, 5, 0}, \ + {0xB0, (uint8_t[]){0x6D}, 1, 0}, \ + {0xB1, (uint8_t[]){0x37}, 1, 0}, \ + {0xB2, (uint8_t[]){0x8B}, 1, 0}, \ + {0xB3, (uint8_t[]){0x80}, 1, 0}, \ + {0xB5, (uint8_t[]){0x43}, 1, 0}, \ + {0xB7, (uint8_t[]){0x85}, 1, 0}, \ + {0xB8, (uint8_t[]){0x20}, 1, 0}, \ + {0xC0, (uint8_t[]){0x09}, 1, 0}, \ + {0xC1, (uint8_t[]){0x78}, 1, 0}, \ + {0xC2, (uint8_t[]){0x78}, 1, 0}, \ + {0xD0, (uint8_t[]){0x88}, 1, 0}, \ + {0xE0, (uint8_t[]){0x00, 0x00, 0x02}, 3, 0}, \ + {0xE1, (uint8_t[]){0x03, 0xA0, 0x00, 0x00, 0x04, 0xA0, 0x00, 0x00, 0x00, 0x20, 0x20}, 11, 0}, \ + {0xE2, (uint8_t[]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 13, 0}, \ + {0xE3, (uint8_t[]){0x00, 0x00, 0x11, 0x00}, 4, 0}, \ + {0xE4, (uint8_t[]){0x22, 0x00}, 2, 0}, \ + {0xE5, (uint8_t[]){0x05, 0xEC, 0xF6, 0xCA, 0x07, 0xEE, 0xF6, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 16, 0}, \ + {0xE6, (uint8_t[]){0x00, 0x00, 0x11, 0x00}, 4, 0}, \ + {0xE7, (uint8_t[]){0x22, 0x00}, 2, 0}, \ + {0xE8, (uint8_t[]){0x06, 0xED, 0xF6, 0xCA, 0x08, 0xEF, 0xF6, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 16, 0}, \ + {0xE9, (uint8_t[]){0x36, 0x00}, 2, 0}, \ + {0xEB, (uint8_t[]){0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00}, 1, 0}, \ + {0xED, (uint8_t[]){0xFF, 0xFF, 0xFF, 0xBA, 0x0A, 0xFF, 0x45, 0xFF, 0xFF, 0x54, 0xFF, 0xA0, 0xAB, 0xFF, 0xFF, 0xFF}, 16, 0}, \ + {0xEF, (uint8_t[]){0x08, 0x08, 0x08, 0x45, 0x3F, 0x54}, 6, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0}, \ + {0xE8, (uint8_t[]){0x00, 0x0E}, 2, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0}, \ + {0x11, (uint8_t[]){0x00}, 1, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0}, \ + {0xE8, (uint8_t[]){0x00, 0x0C}, 2, 0}, \ + {0xE8, (uint8_t[]){0x00, 0x00}, 2, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0}, \ + {0x36, (uint8_t[]){0x00}, 1, 0}, \ + {0x3A, (uint8_t[]){0x66}, 1, 0}, \ + {0x29, (uint8_t[]){0x00}, 1, 0},\ + } + +/** + * @brief LCD specific flags configuration + * + * These flags are specific to the "3-wire SPI + RGB" bus. + */ +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB) && ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL +/** + * @brief Enable IO multiplex + * + * Set to 1 if the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs. Then, the control panel + * and its pins (except CS signal) will be released after LCD call `init()`. All `*_by_cmd` flags will be invalid. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX (1) // typically set to 0 +/** + * @brief Mirror by command + * + * Set to 1 if the `mirror()` function will be implemented by LCD command. Otherwise, the function will be implemented by + * software. Only valid when `ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX` is 0. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_MIRROR_BY_CMD (!ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX) +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB888) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (8) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (1) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CST820 + +/** + * @brief Touch bus type selection + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (15) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (16) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (7) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (0) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (0) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E_V2.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E_V2.h new file mode 100644 index 00000000..2cb05e80 --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480021_MD80E_V2.h @@ -0,0 +1,382 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_VIEWE_UEDX48480021_MD80E_V2.h + * @brief Configuration file for Viewe UEDX48480021-MD80E-V2 + * @author Viewe@VIEWESMART + * @link https://github.com/VIEWESMART/UEDX48480021-MD80ESP32_2.1inch-Knob + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX48480021-MD80E-V2" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (480) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (480) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER GC9503 + +/** + * @brief LCD bus type selection + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_RGB) + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB + + /** + * @brief RGB bus + */ + /** + * Set to 0 if using simple "RGB" interface which does not contain "3-wire SPI" interface. + */ + #define ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL (1) // 0/1. Typically set to 1 + + #if ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For control panel (3wire-SPI) */ + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_CS (18) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SCK (13) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SDA (12) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CS_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SCL_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SDA_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_MODE (0) // 0-3, typically set to 0 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CMD_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_PARAM_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_USE_DC_BIT (1) // 0/1. Typically set to 1 +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For refresh panel (RGB) */ + #define ESP_PANEL_BOARD_LCD_RGB_CLK_HZ (16 * 1000 * 1000) + // To increase the upper limit of the PCLK, see: https://docs.espressif.com/projects/esp-faq/en/latest/software-framework/peripherals/lcd.html#how-can-i-increase-the-upper-limit-of-pclk-settings-on-esp32-s3-while-ensuring-normal-rgb-screen-display + #define ESP_PANEL_BOARD_LCD_RGB_HPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_HBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_HFP (40) + #define ESP_PANEL_BOARD_LCD_RGB_VPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_VBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_VFP (50) + #define ESP_PANEL_BOARD_LCD_RGB_PCLK_ACTIVE_NEG (0) // 0: rising edge, 1: falling edge. Typically set to 0 + // The following sheet shows the valid combinations of + // data width and pixel bits: + // ┏---------------------------------┳- -------------------------------┓ + #define ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH (16) // | 16 | 8 | + #define ESP_PANEL_BOARD_LCD_RGB_PIXEL_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) // | ESP_PANEL_LCD_COLOR_BITS_RGB565 | ESP_PANEL_LCD_COLOR_BITS_RGB888 | + // ┗---------------------------------┻---------------------------------┛ + // To understand color format of RGB LCD, see: https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/rgb_lcd.html#color-formats + #define ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_BOARD_WIDTH * 10) + // Bounce buffer size in bytes. It is used to avoid screen drift + // for ESP32-S3. Typically set to `ESP_PANEL_BOARD_WIDTH * 10` + // The size should satisfy `size * N = LCD_width * LCD_height`, + // where N is an even number. + // For more details, see: https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/FAQ.md#how-to-fix-screen-drift-issue-when-driving-rgb-lcd-with-esp32-s3 + #define ESP_PANEL_BOARD_LCD_RGB_IO_HSYNC (46) + #define ESP_PANEL_BOARD_LCD_RGB_IO_VSYNC (3) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DE (17) // -1 if not used + #define ESP_PANEL_BOARD_LCD_RGB_IO_PCLK (9) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DISP (-1) // -1 if not used. Typically set to -1 + + // The following sheet shows the mapping of ESP GPIOs to + // LCD data pins with different data width and color format: + // ┏------┳- ------------┳--------------------------┓ + // | ESP: | 8-bit RGB888 | 16-bit RGB565 | + // |------|--------------|--------------------------| + // | LCD: | RGB888 | RGB565 | RGB666 | RGB888 | + // ┗------|--------------|--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA0 (10) // | D0 | B0 | B0-1 | B0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA1 (11) // | D1 | B1 | B2 | B4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA2 (12) // | D2 | B2 | B3 | B5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA3 (13) // | D3 | B3 | B4 | B6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA4 (14) // | D4 | B4 | B5 | B7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA5 (21) // | D5 | G0 | G0 | G0-2 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA6 (47) // | D6 | G1 | G1 | G3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA7 (48) // | D7 | G2 | G2 | G4 | +#if ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH > 8 // ┗--------------┫--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA8 (45) // | G3 | G3 | G5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA9 (38) // | G4 | G4 | G6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA10 (39) // | G5 | G5 | G7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA11 (40) // | R0 | R0-1 | R0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA12 (41) // | R1 | R2 | R4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA13 (42) // | R2 | R3 | R5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA14 (2) // | R3 | R4 | R6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA15 (1) // | R4 | R5 | R7 | + // ┗--------┻--------┻--------┛ +#endif // ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ + { \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0}, \ + {0xEF, (uint8_t[]){0x08}, 1, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0}, \ + {0xC0, (uint8_t[]){0x3B, 0x00}, 2, 0}, \ + {0xC1, (uint8_t[]){0x0B, 0x02}, 2, 0}, \ + {0xC2, (uint8_t[]){0x07, 0x02}, 2, 0}, \ + {0xC7, (uint8_t[]){0x00}, 1, 0}, \ + {0xCC, (uint8_t[]){0x10}, 1, 0}, \ + {0xCD, (uint8_t[]){0x08}, 1, 0}, \ + {0xB0, (uint8_t[]){0x00, 0x11, 0x16, 0x0E, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31, 0x18}, 16, 0}, \ + {0xB1, (uint8_t[]){0x00, 0x11, 0x16, 0x0E, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2A, 0x31, 0x18}, 16, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x11}, 5, 0}, \ + {0xB0, (uint8_t[]){0x6D}, 1, 0}, \ + {0xB1, (uint8_t[]){0x37}, 1, 0}, \ + {0xB2, (uint8_t[]){0x8B}, 1, 0}, \ + {0xB3, (uint8_t[]){0x80}, 1, 0}, \ + {0xB5, (uint8_t[]){0x43}, 1, 0}, \ + {0xB7, (uint8_t[]){0x85}, 1, 0}, \ + {0xB8, (uint8_t[]){0x20}, 1, 0}, \ + {0xC0, (uint8_t[]){0x09}, 1, 0}, \ + {0xC1, (uint8_t[]){0x78}, 1, 0}, \ + {0xC2, (uint8_t[]){0x78}, 1, 0}, \ + {0xD0, (uint8_t[]){0x88}, 1, 0}, \ + {0xE0, (uint8_t[]){0x00, 0x00, 0x02}, 3, 0}, \ + {0xE1, (uint8_t[]){0x03, 0xA0, 0x00, 0x00, 0x04, 0xA0, 0x00, 0x00, 0x00, 0x20, 0x20}, 11, 0}, \ + {0xE2, (uint8_t[]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 13, 0}, \ + {0xE3, (uint8_t[]){0x00, 0x00, 0x11, 0x00}, 4, 0}, \ + {0xE4, (uint8_t[]){0x22, 0x00}, 2, 0}, \ + {0xE5, (uint8_t[]){0x05, 0xEC, 0xF6, 0xCA, 0x07, 0xEE, 0xF6, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 16, 0}, \ + {0xE6, (uint8_t[]){0x00, 0x00, 0x11, 0x00}, 4, 0}, \ + {0xE7, (uint8_t[]){0x22, 0x00}, 2, 0}, \ + {0xE8, (uint8_t[]){0x06, 0xED, 0xF6, 0xCA, 0x08, 0xEF, 0xF6, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 16, 0}, \ + {0xE9, (uint8_t[]){0x36, 0x00}, 2, 0}, \ + {0xEB, (uint8_t[]){0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00}, 1, 0}, \ + {0xED, (uint8_t[]){0xFF, 0xFF, 0xFF, 0xBA, 0x0A, 0xFF, 0x45, 0xFF, 0xFF, 0x54, 0xFF, 0xA0, 0xAB, 0xFF, 0xFF, 0xFF}, 16, 0}, \ + {0xEF, (uint8_t[]){0x08, 0x08, 0x08, 0x45, 0x3F, 0x54}, 6, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0}, \ + {0xE8, (uint8_t[]){0x00, 0x0E}, 2, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0}, \ + {0x11, (uint8_t[]){0x00}, 1, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0}, \ + {0xE8, (uint8_t[]){0x00, 0x0C}, 2, 0}, \ + {0xE8, (uint8_t[]){0x00, 0x00}, 2, 0}, \ + {0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0}, \ + {0x36, (uint8_t[]){0x00}, 1, 0}, \ + {0x3A, (uint8_t[]){0x66}, 1, 0}, \ + {0x29, (uint8_t[]){0x00}, 1, 0},\ + } + +/** + * @brief LCD specific flags configuration + * + * These flags are specific to the "3-wire SPI + RGB" bus. + */ +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB) && ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL +/** + * @brief Enable IO multiplex + * + * Set to 1 if the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs. Then, the control panel + * and its pins (except CS signal) will be released after LCD call `init()`. All `*_by_cmd` flags will be invalid. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX (1) // typically set to 0 +/** + * @brief Mirror by command + * + * Set to 1 if the `mirror()` function will be implemented by LCD command. Otherwise, the function will be implemented by + * software. Only valid when `ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX` is 0. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_MIRROR_BY_CMD (!ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX) +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB888) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (8) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (0) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CST816S + +/** + * @brief Touch bus type selection + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (15) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (16) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (7) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (0) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (0) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX48480028_MD80ET.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480028_MD80ET.h new file mode 100644 index 00000000..1155a6f9 --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX48480028_MD80ET.h @@ -0,0 +1,378 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_UEDX48480028_MD80ET.h + * @brief Configuration file for Viewe UEDX48480028-MD80ET + * @author Viewe@VIEWESMART + * @link + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX48480028-MD80ET" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (480) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (480) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER GC9503 + +/** + * @brief LCD bus type selection + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_RGB) + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB + + /** + * @brief RGB bus + */ + /** + * Set to 0 if using simple "RGB" interface which does not contain "3-wire SPI" interface. + */ + #define ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL (1) // 0/1. Typically set to 1 + + #if ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For control panel (3wire-SPI) */ + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_CS (18) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SCK (13) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SDA (12) + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CS_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SCL_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_SDA_USE_EXPNADER (0) // Set to 1 if the signal is controlled by an IO expander + #define ESP_PANEL_BOARD_LCD_RGB_SPI_MODE (0) // 0-3, typically set to 0 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_CMD_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_PARAM_BYTES (1) // Typically set to 8 + #define ESP_PANEL_BOARD_LCD_RGB_SPI_USE_DC_BIT (1) // 0/1. Typically set to 1 +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + /* For refresh panel (RGB) */ + #define ESP_PANEL_BOARD_LCD_RGB_CLK_HZ (16 * 1000 * 1000) + // To increase the upper limit of the PCLK, see: https://docs.espressif.com/projects/esp-faq/en/latest/software-framework/peripherals/lcd.html#how-can-i-increase-the-upper-limit-of-pclk-settings-on-esp32-s3-while-ensuring-normal-rgb-screen-display + #define ESP_PANEL_BOARD_LCD_RGB_HPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_HBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_HFP (40) + #define ESP_PANEL_BOARD_LCD_RGB_VPW (8) + #define ESP_PANEL_BOARD_LCD_RGB_VBP (20) + #define ESP_PANEL_BOARD_LCD_RGB_VFP (50) + #define ESP_PANEL_BOARD_LCD_RGB_PCLK_ACTIVE_NEG (0) // 0: rising edge, 1: falling edge. Typically set to 0 + // The following sheet shows the valid combinations of + // data width and pixel bits: + // ┏---------------------------------┳- -------------------------------┓ + #define ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH (16) // | 16 | 8 | + #define ESP_PANEL_BOARD_LCD_RGB_PIXEL_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) // | ESP_PANEL_LCD_COLOR_BITS_RGB565 | ESP_PANEL_LCD_COLOR_BITS_RGB888 | + // ┗---------------------------------┻---------------------------------┛ + // To understand color format of RGB LCD, see: https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/rgb_lcd.html#color-formats + #define ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_BOARD_WIDTH * 10) + // Bounce buffer size in bytes. It is used to avoid screen drift + // for ESP32-S3. Typically set to `ESP_PANEL_BOARD_WIDTH * 10` + // The size should satisfy `size * N = LCD_width * LCD_height`, + // where N is an even number. + // For more details, see: https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/FAQ.md#how-to-fix-screen-drift-issue-when-driving-rgb-lcd-with-esp32-s3 + #define ESP_PANEL_BOARD_LCD_RGB_IO_HSYNC (46) + #define ESP_PANEL_BOARD_LCD_RGB_IO_VSYNC (3) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DE (17) // -1 if not used + #define ESP_PANEL_BOARD_LCD_RGB_IO_PCLK (9) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DISP (-1) // -1 if not used. Typically set to -1 + + // The following sheet shows the mapping of ESP GPIOs to + // LCD data pins with different data width and color format: + // ┏------┳- ------------┳--------------------------┓ + // | ESP: | 8-bit RGB888 | 16-bit RGB565 | + // |------|--------------|--------------------------| + // | LCD: | RGB888 | RGB565 | RGB666 | RGB888 | + // ┗------|--------------|--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA0 (10) // | D0 | B0 | B0-1 | B0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA1 (11) // | D1 | B1 | B2 | B4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA2 (12) // | D2 | B2 | B3 | B5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA3 (13) // | D3 | B3 | B4 | B6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA4 (14) // | D4 | B4 | B5 | B7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA5 (21) // | D5 | G0 | G0 | G0-2 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA6 (47) // | D6 | G1 | G1 | G3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA7 (48) // | D7 | G2 | G2 | G4 | +#if ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH > 8 // ┗--------------┫--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA8 (45) // | G3 | G3 | G5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA9 (38) // | G4 | G4 | G6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA10 (39) // | G5 | G5 | G7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA11 (40) // | R0 | R0-1 | R0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA12 (41) // | R1 | R2 | R4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA13 (42) // | R2 | R3 | R5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA14 (2) // | R3 | R4 | R6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA15 (1) // | R4 | R5 | R7 | + // ┗--------┻--------┻--------┛ +#endif // ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +#define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD() \ + { \ + {0xFF, (uint8_t []){0x77,0x01,0x00,0x00,0x13}, 5, 0},\ + {0xEF, (uint8_t []){0x08}, 1, 0},\ + {0xFF, (uint8_t []){0x77,0x01,0x00,0x00,0x10}, 5, 0},\ + {0xC0, (uint8_t []){0x3B,0x00}, 2, 0},\ + {0xC1, (uint8_t []){0x10,0x0C}, 2, 0},\ + {0xC2, (uint8_t []){0x07,0x0A}, 2, 0},\ + {0xC7, (uint8_t []){0x00}, 1, 0},\ + {0xCC, (uint8_t []){0x10}, 1, 0},\ + {0xCD, (uint8_t []){0x08}, 1, 0},\ + {0xB0, (uint8_t []){0x05,0x12,0x98,0x0E,0x0F,0x07,0x07,0x09,0x09,0x23,0x05,0x52,0x0F,0x67,0x2C,0x11} , 16, 0},\ + {0xB1, (uint8_t []){0x0B,0x11,0x97,0x0C,0x12,0x06,0x06,0x08,0x08,0x22,0x03,0x51,0x11,0x66,0x2B,0x0F} , 16, 0},\ + {0xFF, (uint8_t []){0x77,0x01,0x00,0x00,0x11}, 5, 0},\ + {0xB0, (uint8_t []){0x5D}, 1, 0},\ + {0xB1, (uint8_t []){0x2D}, 1, 0},\ + {0xB2, (uint8_t []){0x81}, 1, 0},\ + {0xB3, (uint8_t []){0x80}, 1, 0},\ + {0xB5, (uint8_t []){0x4E}, 1, 0},\ + {0xB7, (uint8_t []){0x85}, 1, 0},\ + {0xB8, (uint8_t []){0x20}, 1, 0},\ + {0xC0, (uint8_t []){0x09}, 1, 0},\ + {0xC1, (uint8_t []){0x78}, 1, 0},\ + {0xC2, (uint8_t []){0x78}, 1, 0},\ + {0xD0, (uint8_t []){0x88}, 1, 0},\ + {0xE0, (uint8_t []){0x00,0x00,0x02}, 3, 0},\ + {0xE1, (uint8_t []){0x06,0x30,0x08,0x30,0x05,0x30,0x07,0x30,0x00,0x33,0x33}, 11, 0},\ + {0xE2, (uint8_t []){0x11,0x11,0x33,0x33,0xF4,0x00,0x00,0x00,0xF4,0x00,0x00,0x00}, 12, 0},\ + {0xE3, (uint8_t []){0x00,0x00,0x11,0x11}, 4, 0},\ + {0xE4, (uint8_t []){0x44,0x44}, 2, 0},\ + {0xE5, (uint8_t []){0x0D,0xF5,0x30,0xF0,0x0F,0xF7,0x30,0xF0,0x09,0xF1,0x30,0xF0,0x0B,0xF3,0x30,0xF0}, 16, 0},\ + {0xE6, (uint8_t []){0x00,0x00,0x11,0x11}, 4, 0},\ + {0xE7, (uint8_t []){0x44,0x44}, 2, 0},\ + {0xE8, (uint8_t []){0x0C,0xF4,0x30,0xF0,0x0E,0xF6,0x30,0xF0,0x08,0xF0,0x30,0xF0,0x0A,0xF2,0x30,0xF0}, 16, 0},\ + {0xE9, (uint8_t []){0x36, 0x01}, 2, 0},\ + {0xEB, (uint8_t []){0x00,0x01,0xE4,0xE4,0x44,0x88,0x40}, 7, 0},\ + {0xED, (uint8_t []){0xFF,0x10,0xAF,0x76,0x54,0x2B,0xCF,0xFF,0xFF,0xFC,0xB2,0x45,0x67,0xFA,0x01,0xFF} , 16, 0},\ + {0xEF, (uint8_t []){0x08,0x08,0x08,0x45,0x3F,0x54}, 6, 0},\ + {0xFF, (uint8_t []){0x77,0x01,0x00,0x00,0x00}, 5, 0},\ + {0x11, (uint8_t []){0X00}, 1, 0},\ + {0x3A, (uint8_t []){0x66}, 1, 0},\ + {0x36, (uint8_t []){0x00}, 1, 0},\ + {0x35, (uint8_t []){0x00}, 1, 0},\ + {0x29, (uint8_t []){0x00}, 1, 0},\ + {0x00, (uint8_t []){0x00}, 0xff},\ + } + +/** + * @brief LCD specific flags configuration + * + * These flags are specific to the "3-wire SPI + RGB" bus. + */ +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB) && ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL +/** + * @brief Enable IO multiplex + * + * Set to 1 if the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs. Then, the control panel + * and its pins (except CS signal) will be released after LCD call `init()`. All `*_by_cmd` flags will be invalid. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX (1) // typically set to 0 +/** + * @brief Mirror by command + * + * Set to 1 if the `mirror()` function will be implemented by LCD command. Otherwise, the function will be implemented by + * software. Only valid when `ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX` is 0. + */ +#define ESP_PANEL_BOARD_LCD_FLAGS_MIRROR_BY_CMD (!ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX) +#endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL + +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB888) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (8) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (1) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CST820 + +/** + * @brief Touch bus type selection + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (15) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (16) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (7) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (0) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (0) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/BOARD_VIEWE_UEDX80480050E_AC_A.h b/src/board/supported/viewe/BOARD_VIEWE_UEDX80480050E_AC_A.h new file mode 100644 index 00000000..6f30ea6e --- /dev/null +++ b/src/board/supported/viewe/BOARD_VIEWE_UEDX80480050E_AC_A.h @@ -0,0 +1,296 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_UEDX80480050E_AC_A.h + * @brief Configuration file for Viewe UEDX80480050E-AC-A + * @author Viewe@VIEWESMART + * @link https://viewedisplay.com/product/esp32-5-inch-800x480-rgb-ips-tft-display-touch-screen-arduino-lvgl/ + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Viewe:UEDX80480050E-AC-A" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (800) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (480) // Panel height (vertical, in pixels) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief LCD panel configuration flag (0/1) + * + * Set to `1` to enable LCD panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_LCD (1) + +#if ESP_PANEL_BOARD_USE_LCD +/** + * @brief LCD controller selection + */ +#define ESP_PANEL_BOARD_LCD_CONTROLLER ST7262 + +/** + * @brief LCD bus type selection + */ +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_RGB) + +/** + * @brief LCD bus parameters configuration + * + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. + * For detailed parameter explanations, see: + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html + */ +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB + + /** + * @brief RGB bus + */ + /** + * Set to 0 if using simple "RGB" interface which does not contain "3-wire SPI" interface. + */ + #define ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL (0) // 0/1. Typically set to 1 + + /* For refresh panel (RGB) */ + #define ESP_PANEL_BOARD_LCD_RGB_CLK_HZ (20 * 1000 * 1000) + // To increase the upper limit of the PCLK, see: https://docs.espressif.com/projects/esp-faq/en/latest/software-framework/peripherals/lcd.html#how-can-i-increase-the-upper-limit-of-pclk-settings-on-esp32-s3-while-ensuring-normal-rgb-screen-display + #define ESP_PANEL_BOARD_LCD_RGB_HPW (1) + #define ESP_PANEL_BOARD_LCD_RGB_HBP (42) + #define ESP_PANEL_BOARD_LCD_RGB_HFP (20) + #define ESP_PANEL_BOARD_LCD_RGB_VPW (10) + #define ESP_PANEL_BOARD_LCD_RGB_VBP (12) + #define ESP_PANEL_BOARD_LCD_RGB_VFP (4) + #define ESP_PANEL_BOARD_LCD_RGB_PCLK_ACTIVE_NEG (1) // 0: rising edge, 1: falling edge. Typically set to 0 + // The following sheet shows the valid combinations of + // data width and pixel bits: + // ┏---------------------------------┳- -------------------------------┓ + #define ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH (16) // | 16 | 8 | + #define ESP_PANEL_BOARD_LCD_RGB_PIXEL_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) // | ESP_PANEL_LCD_COLOR_BITS_RGB565 | ESP_PANEL_LCD_COLOR_BITS_RGB888 | + // ┗---------------------------------┻---------------------------------┛ + // To understand color format of RGB LCD, see: https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/rgb_lcd.html#color-formats + #define ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_BOARD_WIDTH * 10) + // Bounce buffer size in bytes. It is used to avoid screen drift + // for ESP32-S3. Typically set to `ESP_PANEL_BOARD_WIDTH * 10` + // The size should satisfy `size * N = LCD_width * LCD_height`, + // where N is an even number. + // For more details, see: https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/FAQ.md#how-to-fix-screen-drift-issue-when-driving-rgb-lcd-with-esp32-s3 + #define ESP_PANEL_BOARD_LCD_RGB_IO_HSYNC (6) + #define ESP_PANEL_BOARD_LCD_RGB_IO_VSYNC (5) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DE (4) // -1 if not used + #define ESP_PANEL_BOARD_LCD_RGB_IO_PCLK (7) + #define ESP_PANEL_BOARD_LCD_RGB_IO_DISP (39) // -1 if not used. Typically set to -1 + + // The following sheet shows the mapping of ESP GPIOs to + // LCD data pins with different data width and color format: + // ┏------┳- ------------┳--------------------------┓ + // | ESP: | 8-bit RGB888 | 16-bit RGB565 | + // |------|--------------|--------------------------| + // | LCD: | RGB888 | RGB565 | RGB666 | RGB888 | + // ┗------|--------------|--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA0 (14) // | D0 | B0 | B0-1 | B0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA1 (13) // | D1 | B1 | B2 | B4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA2 (12) // | D2 | B2 | B3 | B5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA3 (9) // | D3 | B3 | B4 | B6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA4 (8) // | D4 | B4 | B5 | B7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA5 (20) // | D5 | G0 | G0 | G0-2 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA6 (19) // | D6 | G1 | G1 | G3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA7 (18) // | D7 | G2 | G2 | G4 | +#if ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH > 8 // ┗--------------┫--------|--------|--------| + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA8 (17) // | G3 | G3 | G5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA9 (16) // | G4 | G4 | G6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA10 (15) // | G5 | G5 | G7 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA11 (38) // | R0 | R0-1 | R0-3 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA12 (47) // | R1 | R2 | R4 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA13 (48) // | R2 | R3 | R5 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA14 (41) // | R3 | R4 | R6 | + #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA15 (21) // | R4 | R5 | R7 | + // ┗--------┻--------┻--------┛ +#endif // ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH + +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE + +/** + * @brief LCD color configuration + */ +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB888) + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (0) // 0/1 + +/** + * @brief LCD transformation configuration + */ +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] + +/** + * @brief LCD reset pin configuration + */ +#define ESP_PANEL_BOARD_LCD_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_LCD + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Touch panel configuration flag (0/1) + * + * Set to `1` to enable touch panel support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_TOUCH (0) + +#if ESP_PANEL_BOARD_USE_TOUCH +/** + * @brief Touch controller selection + */ +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER GT911 + +/** + * @brief Touch bus type selection + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) + +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` + * ensure that the host is initialized only once. + */ +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 +#endif + +/** + * @brief Touch bus parameters configuration + */ +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + /** + * @brief I2C bus + */ + /* For general */ + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (20) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (19) +#endif + /* For panel */ + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. + // - For touchs with only one address, set to 0 + // - For touchs with multiple addresses, set to 0 or + // the address. Like GT911, there are two addresses: + // 0x5D(default) and 0x14 + +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE + +/** + * @brief Touch panel transformation flags + */ +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 + +/** + * @brief Touch panel control pins + */ +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high +#define ESP_PANEL_BOARD_TOUCH_INT_IO (-1) // Interrupt pin, -1 if not used +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_USE_TOUCH + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Backlight configuration flag (0/1) + * + * Set to `1` to enable backlight support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) + +#if ESP_PANEL_BOARD_USE_BACKLIGHT +/** + * @brief Backlight control type selection + */ +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + + /** + * @brief Backlight control pin configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_IO (40) // Output GPIO pin number + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high + +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE + +/** + * @brief Backlight idle state configuration (0/1) + * + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. + */ +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (0) + +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief IO expander configuration flag (0/1) + * + * Set to `1` to enable IO expander support, `0` to disable + */ +#define ESP_PANEL_BOARD_USE_EXPANDER (0) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions. These version numbers are used to check compatibility between this + * configuration file and the library. Rules for version numbers: + * 1. Major version mismatch: Configurations are incompatible, must use library version + * 2. Minor version mismatch: May be missing new configurations, recommended to update + * 3. Patch version mismatch: No impact on functionality + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-ON* diff --git a/src/board/supported/viewe/Kconfig.viewe b/src/board/supported/viewe/Kconfig.viewe index b7e51b28..37a1f8a1 100644 --- a/src/board/supported/viewe/Kconfig.viewe +++ b/src/board/supported/viewe/Kconfig.viewe @@ -1,3 +1,38 @@ +config BOARD_VIEWE_SMARTRING + bool "SMARTRING" + help + https://github.com/VIEWESMART/SMARTRING/tree/main/information + +config BOARD_VIEWE_UEDX24240013_MD50E + bool "UEDX24240013-MD50E" + help + https://github.com/VIEWESMART/UEDX24240013-MD50ESP32_1.3inch-Knob/tree/main/information + +config BOARD_VIEWE_UEDX46460015_MD50ET + bool "UEDX46460015-MD50ET" + help + https://github.com/VIEWESMART/UEDX46460015-MD50ESP32-1.5inch-Touch-Knob-Display/tree/main/datasheet + +config BOARD_VIEWE_UEDX48480021_MD80E + bool "UEDX48480021_MD80E" + help + https://github.com/VIEWESMART/UEDX48480021-MD80ESP32_2.1inch-Knob/tree/main/information + +config BOARD_VIEWE_UEDX48480021_MD80E_V2 + bool "UEDX48480021_MD80E_V2" + help + https://github.com/VIEWESMART/UEDX48480021-MD80ESP32_2.1inch-Knob/tree/main/information + +config BOARD_VIEWE_UEDX48480021_MD80ET + bool "UEDX48480021_MD80ET" + help + https://github.com/VIEWESMART/UEDX48480021-MD80ESP32-2.1inch-Touch-Knob-Display/tree/main/information + +config BOARD_VIEWE_UEDX48480028_MD80ET + bool "UEDX48480028_MD80ET" + help + https://github.com/VIEWESMART/UEDX48480021-MD80ESP32-2.1inch-Touch-Knob-Display/tree/main/information + config BOARD_VIEWE_UEDX24320024E_WB_A bool "UEDX24320024E-WB-A" help @@ -38,6 +73,9 @@ config BOARD_VIEWE_UEDX80480050E_WB_A help https://viewedisplay.com/product/esp32-5-inch-800x480-rgb-ips-tft-display-touch-screen-arduino-lvgl/ +config BOARD_VIEWE_UEDX80480050E_AC_A + bool "UEDX80480050E-AC-A" + config BOARD_VIEWE_UEDX80480050E_WB_A_2 bool "UEDX80480050E-WB-A-2" help diff --git a/src/drivers/touch/esp_panel_touch_cst820.cpp b/src/drivers/touch/esp_panel_touch_cst820.cpp new file mode 100644 index 00000000..87461442 --- /dev/null +++ b/src/drivers/touch/esp_panel_touch_cst820.cpp @@ -0,0 +1,52 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_panel_touch_conf_internal.h" +#if ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST820 + +#include "utils/esp_panel_utils_log.h" +#include "esp_panel_touch_cst816s.hpp" + +namespace esp_panel::drivers { + +TouchCST820::~TouchCST820() +{ + ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS(); + + ESP_UTILS_CHECK_FALSE_EXIT(del(), "Delete failed"); + + ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS(); +} + +bool TouchCST820::begin() +{ + ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS(); + + ESP_UTILS_CHECK_FALSE_RETURN(!isOverState(State::BEGIN), false, "Already begun"); + + // Initialize the touch if not initialized + if (!isOverState(State::INIT)) { + ESP_UTILS_CHECK_FALSE_RETURN(init(), false, "Init failed"); + } + + // Create touch panel + ESP_UTILS_CHECK_ERROR_RETURN( + esp_lcd_touch_new_i2c_cst816s( + getBus()->getControlPanelHandle(), getConfig().getDeviceFullConfig(), &touch_panel + ), false, "Create touch panel failed" + ); + ESP_UTILS_LOGD("Create touch panel(@%p)", touch_panel); + + setState(State::BEGIN); + + ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS(); + + return true; +} + +} // namespace esp_panel::drivers + +#endif // ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST820 diff --git a/src/drivers/touch/esp_panel_touch_cst820.hpp b/src/drivers/touch/esp_panel_touch_cst820.hpp new file mode 100644 index 00000000..a346a354 --- /dev/null +++ b/src/drivers/touch/esp_panel_touch_cst820.hpp @@ -0,0 +1,87 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "port/esp_lcd_touch_cst816s.h" +#include "esp_panel_touch_conf_internal.h" +#include "esp_panel_touch.hpp" + +namespace esp_panel::drivers { + +/** + * @brief CST820 touch controller + * + * This class provides implementation for CST820 touch controller, inheriting from + * the base Touch class to provide common touch functionality + */ +class TouchCST820 : public Touch { +public: + /** + * @brief Default basic attributes for CST820 + */ + static constexpr BasicAttributes BASIC_ATTRIBUTES_DEFAULT = { + .name = "CST820", + .max_points_num = 1, + }; + + /** + * @brief Construct a touch device instance with individual configuration parameters + * + * @param bus Bus interface for communicating with the touch device + * @param width Panel width in pixels + * @param height Panel height in pixels + * @param rst_io Reset GPIO pin number (-1 if unused) + * @param int_io Interrupt GPIO pin number (-1 if unused) + */ + TouchCST820(Bus *bus, uint16_t width, uint16_t height, int rst_io = -1, int int_io = -1): + Touch(BASIC_ATTRIBUTES_DEFAULT, bus, width, height, rst_io, int_io) + { + } + + /** + * @brief Construct a touch device instance with configuration + * + * @param[in] bus Pointer to the bus interface for communicating with the touch device + * @param[in] config Configuration structure containing device settings and parameters + */ + TouchCST820(Bus *bus, const Config &config): Touch(BASIC_ATTRIBUTES_DEFAULT, bus, config) {} + + /** + * @brief Construct a touch device instance with bus configuration and device configuration + * + * @param[in] bus_config Bus configuration + * @param[in] touch_config Touch configuration + * @note This constructor creates a new bus instance using the provided bus configuration + */ + TouchCST820(const BusFactory::Config &bus_config, const Config &touch_config): + Touch(BASIC_ATTRIBUTES_DEFAULT, bus_config, touch_config) + { + } + + /** + * @brief Destruct touch device + */ + ~TouchCST820() override; + + /** + * @brief Startup the touch device + * + * @return `true` if success, otherwise false + * + * @note This function should be called after `init()` + */ + bool begin() override; +}; + +} // namespace esp_panel::drivers + +/** + * @brief Deprecated type alias for backward compatibility + * @deprecated Use `esp_panel::drivers::TouchCST820` instead + */ +using ESP_PanelTouch_CST820 [[deprecated("Use `esp_panel::drivers::TouchCST820` instead")]] = + esp_panel::drivers::TouchCST820; diff --git a/src/drivers/touch/port/esp_lcd_touch_cst820.c b/src/drivers/touch/port/esp_lcd_touch_cst820.c new file mode 100644 index 00000000..e09d6f4c --- /dev/null +++ b/src/drivers/touch/port/esp_lcd_touch_cst820.c @@ -0,0 +1,214 @@ +/* + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * @file esp_lcd_touch_cst820.c + * @brief ESP LCD touch: CST820 + * @author Viewe@VIEWESMART + */ + +#include "../esp_panel_touch_conf_internal.h" +#if ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST820 + +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "driver/gpio.h" +#include "esp_system.h" +#include "esp_err.h" +#include "esp_log.h" +#include "esp_check.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_touch.h" + +#include "utils/esp_panel_utils_log.h" +#include "esp_utils_helpers.h" +#include "esp_lcd_touch_cst820.h" + +#define POINT_NUM_MAX (1) + +#define DATA_START_REG (0x00) +#define CHIP_ID_REG (0xA7) + +static const char *TAG = "CST820"; + +static esp_err_t read_data(esp_lcd_touch_handle_t tp); +static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num); +static esp_err_t del(esp_lcd_touch_handle_t tp); + +static esp_err_t i2c_read_bytes(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len); + +static esp_err_t reset(esp_lcd_touch_handle_t tp); +static esp_err_t read_id(esp_lcd_touch_handle_t tp); + +esp_err_t esp_lcd_touch_new_i2c_cst820(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *tp) +{ + ESP_LOGI(TAG, "version: %d.%d.%d", ESP_LCD_TOUCH_CST820_VER_MAJOR, ESP_LCD_TOUCH_CST820_VER_MINOR, + ESP_LCD_TOUCH_CST820_VER_PATCH); + ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_ARG, TAG, "Invalid io"); + ESP_RETURN_ON_FALSE(config, ESP_ERR_INVALID_ARG, TAG, "Invalid config"); + ESP_RETURN_ON_FALSE(tp, ESP_ERR_INVALID_ARG, TAG, "Invalid touch handle"); + + /* Prepare main structure */ + esp_err_t ret = ESP_OK; + esp_lcd_touch_handle_t cst820 = calloc(1, sizeof(esp_lcd_touch_t)); + ESP_GOTO_ON_FALSE(cst820, ESP_ERR_NO_MEM, err, TAG, "Touch handle malloc failed"); + + /* Communication interface */ + cst820->io = io; + /* Only supported callbacks are set */ + cst820->read_data = read_data; + cst820->get_xy = get_xy; + cst820->del = del; + /* Mutex */ + cst820->data.lock.owner = portMUX_FREE_VAL; + /* Save config */ + memcpy(&cst820->config, config, sizeof(esp_lcd_touch_config_t)); + + /* Prepare pin for touch interrupt */ + if (cst820->config.int_gpio_num != GPIO_NUM_NC) { + const gpio_config_t int_gpio_config = { + .mode = GPIO_MODE_INPUT, + .intr_type = (cst820->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), + .pin_bit_mask = BIT64(cst820->config.int_gpio_num) + }; + ESP_GOTO_ON_ERROR(gpio_config(&int_gpio_config), err, TAG, "GPIO intr config failed"); + + /* Register interrupt callback */ + if (cst820->config.interrupt_callback) { + esp_lcd_touch_register_interrupt_callback(cst820, cst820->config.interrupt_callback); + } + } + /* Prepare pin for touch controller reset */ + if (cst820->config.rst_gpio_num != GPIO_NUM_NC) { + const gpio_config_t rst_gpio_config = { + .mode = GPIO_MODE_OUTPUT, + .pin_bit_mask = BIT64(cst820->config.rst_gpio_num) + }; + ESP_GOTO_ON_ERROR(gpio_config(&rst_gpio_config), err, TAG, "GPIO reset config failed"); + } + /* Reset controller */ + ESP_GOTO_ON_ERROR(reset(cst820), err, TAG, "Reset failed"); + /* Read product id */ + ESP_GOTO_ON_ERROR(read_id(cst820), err, TAG, "Read version failed"); + *tp = cst820; + + return ESP_OK; +err: + if (cst820) { + del(cst820); + } + ESP_LOGE(TAG, "Initialization failed!"); + return ret; +} + +static esp_err_t read_data(esp_lcd_touch_handle_t tp) +{ + typedef struct { + uint8_t num; + uint8_t x_h : 4; + uint8_t : 4; + uint8_t x_l; + uint8_t y_h : 4; + uint8_t : 4; + uint8_t y_l; + } data_t; + + data_t point; + // ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, DATA_START_REG, (uint8_t *)&point, sizeof(data_t)), TAG, "I2C read failed"); + + /*CST820 */ + uint8_t lvalue[15]={0}; + uint8_t gesture_id=0; + uint16_t x=0; + uint16_t y=0; + ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, DATA_START_REG, (uint8_t *)lvalue, sizeof(lvalue)), TAG, "I2C read failed"); + gesture_id = lvalue[1]; + point.num =lvalue[2]; + x = (((uint16_t)(lvalue[3]&0x0f))<<8) | lvalue[4]; + y = (((uint16_t)(lvalue[5]&0x0f))<<8) | lvalue[6]; + + portENTER_CRITICAL(&tp->data.lock); + point.num = (point.num > POINT_NUM_MAX ? POINT_NUM_MAX : point.num); + tp->data.points = point.num; + /* Fill all coordinates */ + for (int i = 0; i < tp->data.points ; i++) { + tp->data.coords[i].x = x; + tp->data.coords[i].y = y; + } + portEXIT_CRITICAL(&tp->data.lock); + + return ESP_OK; +} + +static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num) +{ + portENTER_CRITICAL(&tp->data.lock); + /* Count of points */ + *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); + for (size_t i = 0; i < *point_num; i++) { + x[i] = tp->data.coords[i].x; + y[i] = tp->data.coords[i].y; + + if (strength) { + strength[i] = tp->data.coords[i].strength; + } + } + /* Invalidate */ + tp->data.points = 0; + portEXIT_CRITICAL(&tp->data.lock); + + return (*point_num > 0); +} + +static esp_err_t del(esp_lcd_touch_handle_t tp) +{ + /* Reset GPIO pin settings */ + if (tp->config.int_gpio_num != GPIO_NUM_NC) { + gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } + } + if (tp->config.rst_gpio_num != GPIO_NUM_NC) { + gpio_reset_pin(tp->config.rst_gpio_num); + } + /* Release memory */ + free(tp); + + return ESP_OK; +} + +static esp_err_t reset(esp_lcd_touch_handle_t tp) +{ + if (tp->config.rst_gpio_num != GPIO_NUM_NC) { + ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level failed"); + vTaskDelay(pdMS_TO_TICKS(200)); + ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, !tp->config.levels.reset), TAG, "GPIO set level failed"); + vTaskDelay(pdMS_TO_TICKS(200)); + } + + return ESP_OK; +} + +static esp_err_t read_id(esp_lcd_touch_handle_t tp) +{ + uint8_t id; + ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, CHIP_ID_REG, &id, 1), TAG, "I2C read failed"); + ESP_LOGI(TAG, "IC id: %d", id); + return ESP_OK; +} + +static esp_err_t i2c_read_bytes(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len) +{ + ESP_RETURN_ON_FALSE(data, ESP_ERR_INVALID_ARG, TAG, "Invalid data"); + + return esp_lcd_panel_io_rx_param(tp->io, reg, data, len); +} + +#endif // ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST820 diff --git a/src/drivers/touch/port/esp_lcd_touch_cst820.h b/src/drivers/touch/port/esp_lcd_touch_cst820.h new file mode 100644 index 00000000..1b8a155e --- /dev/null +++ b/src/drivers/touch/port/esp_lcd_touch_cst820.h @@ -0,0 +1,62 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file esp_lcd_touch_cst820.h + * @brief ESP LCD touch: CST820 + * @author Viewe@VIEWESMART + */ + +#pragma once + +#include "esp_lcd_touch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESP_LCD_TOUCH_CST816S_VER_MAJOR (0) +#define ESP_LCD_TOUCH_CST816S_VER_MINOR (0) +#define ESP_LCD_TOUCH_CST816S_VER_PATCH (1) + +/** + * @brief Create a new CST816S touch driver + * + * @note The I2C communication should be initialized before use this function. + * + * @param io LCD panel IO handle, it should be created by `esp_lcd_new_panel_io_i2c()` + * @param config Touch panel configuration + * @param tp Touch panel handle + * @return + * - ESP_OK: on success + */ +esp_err_t esp_lcd_touch_new_i2c_cst820(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *tp); + +/** + * @brief I2C address of the CST816S controller + * + */ +#define ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS (0x15) + +/** + * @brief Touch IO configuration structure + * + */ +#define ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG() \ + { \ + .dev_addr = ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS, \ + .control_phase_bytes = 1, \ + .dc_bit_offset = 0, \ + .lcd_cmd_bits = 8, \ + .flags = \ + { \ + .disable_control_phase = 1, \ + } \ + } + +#ifdef __cplusplus +} +#endif