diff --git a/src/board/supported/esp_panel_board_config_supported.h b/src/board/supported/esp_panel_board_config_supported.h index 502d28a0..7449c975 100644 --- a/src/board/supported/esp_panel_board_config_supported.h +++ b/src/board/supported/esp_panel_board_config_supported.h @@ -92,6 +92,7 @@ + defined(BOARD_JINGCAI_JC8048W550C) \ /* Waveshare */ \ + defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85) \ + + defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C) \ + defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1) \ + defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_4_3) \ + defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_4_3_B) \ @@ -160,6 +161,8 @@ /* Waveshare */ #elif defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85) #include "waveshare/BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85.h" + #elif defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C) + #include "waveshare/BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C.h" #elif defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1) #include "waveshare/BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1.h" #elif defined(BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_4_3) diff --git a/src/board/supported/esp_panel_board_kconfig_supported.h b/src/board/supported/esp_panel_board_kconfig_supported.h index 9d9a1789..3b4068b1 100644 --- a/src/board/supported/esp_panel_board_kconfig_supported.h +++ b/src/board/supported/esp_panel_board_kconfig_supported.h @@ -118,6 +118,11 @@ #define BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85 CONFIG_BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85 #endif #endif +#ifndef BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C + #ifdef CONFIG_BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C + #define BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C CONFIG_BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C + #endif +#endif #ifndef BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1 #ifdef CONFIG_BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1 #define BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1 CONFIG_BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1 diff --git a/src/board/supported/waveshare/BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C.h b/src/board/supported/waveshare/BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C.h new file mode 100644 index 00000000..7897cfb0 --- /dev/null +++ b/src/board/supported/waveshare/BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C.h @@ -0,0 +1,338 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/** + * @file BOARD_ESP32_S3_TOUCH_LCD_1_85C.h + * @brief Configuration file for Waveshare ESP32_S3_TOUCH_LCD_1_85C + * @author @martinroger & Waveshare@H-sw123 + * @link https://www.waveshare.com/esp32-s3-touch-lcd-1.85c.htm + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Board name + */ +#define ESP_PANEL_BOARD_NAME "Waveshare:ESP32_S3_TOUCH_LCD_1_85C" + +/** + * @brief Panel resolution configuration in pixels + */ +#define ESP_PANEL_BOARD_WIDTH (360) // Panel width (horizontal, in pixels) +#define ESP_PANEL_BOARD_HEIGHT (360) // 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 ST77916 + +/** + * @brief LCD bus type selection + */ +#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 (2) +#if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST + /* For host */ + #define ESP_PANEL_BOARD_LCD_QSPI_IO_SCK (40) + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA0 (46) + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA1 (45) + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA2 (42) + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA3 (41) +#endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST + /* For panel */ + #define ESP_PANEL_BOARD_LCD_QSPI_IO_CS (21) // -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 (80 * 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 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 (1) // 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 (1) + +#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 (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 (10) + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (11) +#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 (4) // 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 (5) // 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 (1) + +#if ESP_PANEL_BOARD_USE_EXPANDER +/** + * @brief IO expander chip selection + */ +#define ESP_PANEL_BOARD_EXPANDER_CHIP TCA95XX_8BIT + +/** + * @brief IO expander I2C bus parameters configuration + */ +/** + * 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 devices, please set the macro to `1` ensure that the + * host is initialized only once. + */ +#define ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST (0) // 0/1 +/* For general */ +#define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 +/* For host */ +#if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K +#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (0) // 0/1. Typically set to 1 +#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (0) // 0/1. Typically set to 1 +#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (10) +#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (11) +#endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST +/* For device */ +#define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, + // the I2C address may be different, and confirmation based on + // the actual hardware connection is required +#endif // ESP_PANEL_BOARD_USE_EXPANDER + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Pre-begin function for LCD initialization + * + * @param[in] p Pointer to the board object + * @return true on success, false on failure + */ +#define ESP_PANEL_BOARD_LCD_PRE_BEGIN_FUNCTION(p) \ + { \ + constexpr int LCD_RST = 1; \ + auto board = static_cast(p); \ + auto expander = board->getIO_Expander()->getBase(); \ + /* LCD reset */ \ + expander->pinMode(LCD_RST, OUTPUT); \ + expander->digitalWrite(LCD_RST, LOW); \ + vTaskDelay(pdMS_TO_TICKS(10)); \ + expander->digitalWrite(LCD_RST, HIGH); \ + vTaskDelay(pdMS_TO_TICKS(100)); \ + return true; \ + } + +/** + * @brief Pre-begin function for touch panel initialization + * + * @param[in] p Pointer to the board object + * @return true on success, false on failure + */ +#define ESP_PANEL_BOARD_TOUCH_PRE_BEGIN_FUNCTION(p) \ + { \ + constexpr int TP_RST = 0; \ + auto board = static_cast(p); \ + auto expander = board->getIO_Expander()->getBase(); \ + /* Touch reset */ \ + expander->pinMode(TP_RST, OUTPUT); \ + expander->digitalWrite(TP_RST, LOW); \ + vTaskDelay(pdMS_TO_TICKS(30)); \ + expander->digitalWrite(TP_RST, HIGH); \ + vTaskDelay(pdMS_TO_TICKS(50)); \ + 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/waveshare/Kconfig.waveshare b/src/board/supported/waveshare/Kconfig.waveshare index e993d3aa..ade883dc 100644 --- a/src/board/supported/waveshare/Kconfig.waveshare +++ b/src/board/supported/waveshare/Kconfig.waveshare @@ -3,6 +3,11 @@ config BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85 help https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm +config BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_1_85C + bool "ESP32_S3_TOUCH_LCD_1_85C" + help + https://www.waveshare.com/esp32-s3-touch-lcd-1.85c.htm + config BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_2_1 bool "ESP32_S3_TOUCH_LCD_2_1" help