|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | +/** |
| 7 | + * @file BOARD_ESP32_S3_TOUCH_LCD_1_85C.h |
| 8 | + * @brief Configuration file for Waveshare ESP32_S3_TOUCH_LCD_1_85C |
| 9 | + * @author @martinroger & Waveshare@H-sw123 |
| 10 | + * @link https://www.waveshare.com/esp32-s3-touch-lcd-1.85c.htm |
| 11 | + */ |
| 12 | + |
| 13 | +#pragma once |
| 14 | + |
| 15 | +// *INDENT-OFF* |
| 16 | + |
| 17 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 18 | +//////////////////////////// Please update the following macros to configure general panel ///////////////////////////// |
| 19 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 20 | +/** |
| 21 | + * @brief Board name |
| 22 | + */ |
| 23 | +#define ESP_PANEL_BOARD_NAME "Waveshare:ESP32_S3_TOUCH_LCD_1_85C" |
| 24 | + |
| 25 | +/** |
| 26 | + * @brief Panel resolution configuration in pixels |
| 27 | + */ |
| 28 | +#define ESP_PANEL_BOARD_WIDTH (360) // Panel width (horizontal, in pixels) |
| 29 | +#define ESP_PANEL_BOARD_HEIGHT (360) // Panel height (vertical, in pixels) |
| 30 | + |
| 31 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// |
| 33 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | +/** |
| 35 | + * @brief LCD panel configuration flag (0/1) |
| 36 | + * |
| 37 | + * Set to `1` to enable LCD panel support, `0` to disable |
| 38 | + */ |
| 39 | +#define ESP_PANEL_BOARD_USE_LCD (1) |
| 40 | + |
| 41 | +#if ESP_PANEL_BOARD_USE_LCD |
| 42 | +/** |
| 43 | + * @brief LCD controller selection |
| 44 | + */ |
| 45 | +#define ESP_PANEL_BOARD_LCD_CONTROLLER ST77916 |
| 46 | + |
| 47 | +/** |
| 48 | + * @brief LCD bus type selection |
| 49 | + */ |
| 50 | +#define ESP_PANEL_BOARD_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_QSPI) |
| 51 | + |
| 52 | +#if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) || \ |
| 53 | + (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI) |
| 54 | +/** |
| 55 | + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. |
| 56 | + * |
| 57 | + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. |
| 58 | + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` |
| 59 | + * ensure that the host is initialized only once. |
| 60 | + */ |
| 61 | +#define ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 |
| 62 | +#endif |
| 63 | + |
| 64 | +/** |
| 65 | + * @brief LCD bus parameters configuration |
| 66 | + * |
| 67 | + * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored. |
| 68 | + * For detailed parameter explanations, see: |
| 69 | + * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html |
| 70 | + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html |
| 71 | + */ |
| 72 | +#if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI |
| 73 | + |
| 74 | + /** |
| 75 | + * @brief QSPI bus |
| 76 | + */ |
| 77 | + /* For general */ |
| 78 | + #define ESP_PANEL_BOARD_LCD_QSPI_HOST_ID (2) |
| 79 | +#if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST |
| 80 | + /* For host */ |
| 81 | + #define ESP_PANEL_BOARD_LCD_QSPI_IO_SCK (40) |
| 82 | + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA0 (46) |
| 83 | + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA1 (45) |
| 84 | + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA2 (42) |
| 85 | + #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA3 (41) |
| 86 | +#endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST |
| 87 | + /* For panel */ |
| 88 | + #define ESP_PANEL_BOARD_LCD_QSPI_IO_CS (21) // -1 if not used |
| 89 | + #define ESP_PANEL_BOARD_LCD_QSPI_MODE (0) // 0-3, typically set to 0 |
| 90 | + #define ESP_PANEL_BOARD_LCD_QSPI_CLK_HZ (80 * 1000 * 1000) |
| 91 | + // Should be an integer divisor of 80M, typically set to 40M |
| 92 | + #define ESP_PANEL_BOARD_LCD_QSPI_CMD_BITS (32) // Typically set to 32 |
| 93 | + #define ESP_PANEL_BOARD_LCD_QSPI_PARAM_BITS (8) // Typically set to 8 |
| 94 | + |
| 95 | +#endif // ESP_PANEL_BOARD_LCD_BUS_TYPE |
| 96 | + |
| 97 | +/** |
| 98 | + * @brief LCD color configuration |
| 99 | + */ |
| 100 | +#define ESP_PANEL_BOARD_LCD_COLOR_BITS (ESP_PANEL_LCD_COLOR_BITS_RGB565) |
| 101 | + // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888 |
| 102 | +#define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER (0) // 0: RGB, 1: BGR |
| 103 | +#define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT (1) // 0/1 |
| 104 | + |
| 105 | +/** |
| 106 | + * @brief LCD transformation configuration |
| 107 | + */ |
| 108 | +#define ESP_PANEL_BOARD_LCD_SWAP_XY (0) // 0/1 |
| 109 | +#define ESP_PANEL_BOARD_LCD_MIRROR_X (0) // 0/1 |
| 110 | +#define ESP_PANEL_BOARD_LCD_MIRROR_Y (0) // 0/1 |
| 111 | +#define ESP_PANEL_BOARD_LCD_GAP_X (0) // [0, ESP_PANEL_BOARD_WIDTH] |
| 112 | +#define ESP_PANEL_BOARD_LCD_GAP_Y (0) // [0, ESP_PANEL_BOARD_HEIGHT] |
| 113 | + |
| 114 | +/** |
| 115 | + * @brief LCD reset pin configuration |
| 116 | + */ |
| 117 | +#define ESP_PANEL_BOARD_LCD_RST_IO (-1) // Reset pin, -1 if not used |
| 118 | +#define ESP_PANEL_BOARD_LCD_RST_LEVEL (0) // Reset active level, 0: low, 1: high |
| 119 | + |
| 120 | +#endif // ESP_PANEL_BOARD_USE_LCD |
| 121 | + |
| 122 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 123 | +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// |
| 124 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 125 | +/** |
| 126 | + * @brief Touch panel configuration flag (0/1) |
| 127 | + * |
| 128 | + * Set to `1` to enable touch panel support, `0` to disable |
| 129 | + */ |
| 130 | +#define ESP_PANEL_BOARD_USE_TOUCH (1) |
| 131 | + |
| 132 | +#if ESP_PANEL_BOARD_USE_TOUCH |
| 133 | +/** |
| 134 | + * @brief Touch controller selection |
| 135 | + */ |
| 136 | +#define ESP_PANEL_BOARD_TOUCH_CONTROLLER CST816S |
| 137 | + |
| 138 | +/** |
| 139 | + * @brief Touch bus type selection |
| 140 | + */ |
| 141 | +#define ESP_PANEL_BOARD_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) |
| 142 | + |
| 143 | +#if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \ |
| 144 | + (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) |
| 145 | +/** |
| 146 | + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. |
| 147 | + * |
| 148 | + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. |
| 149 | + * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1` |
| 150 | + * ensure that the host is initialized only once. |
| 151 | + */ |
| 152 | +#define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1. Typically set to 0 |
| 153 | +#endif |
| 154 | + |
| 155 | +/** |
| 156 | + * @brief Touch bus parameters configuration |
| 157 | + */ |
| 158 | +#if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C |
| 159 | + |
| 160 | + /** |
| 161 | + * @brief I2C bus |
| 162 | + */ |
| 163 | + /* For general */ |
| 164 | + #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (1) // Typically set to 0 |
| 165 | +#if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST |
| 166 | + /* For host */ |
| 167 | + #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) |
| 168 | + // Typically set to 400K |
| 169 | + #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 |
| 170 | + #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 |
| 171 | + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (10) |
| 172 | + #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (11) |
| 173 | +#endif |
| 174 | + /* For panel */ |
| 175 | + #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. |
| 176 | + // - For touchs with only one address, set to 0 |
| 177 | + // - For touchs with multiple addresses, set to 0 or |
| 178 | + // the address. Like GT911, there are two addresses: |
| 179 | + // 0x5D(default) and 0x14 |
| 180 | + |
| 181 | +#endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE |
| 182 | + |
| 183 | +/** |
| 184 | + * @brief Touch panel transformation flags |
| 185 | + */ |
| 186 | +#define ESP_PANEL_BOARD_TOUCH_SWAP_XY (0) // 0/1 |
| 187 | +#define ESP_PANEL_BOARD_TOUCH_MIRROR_X (0) // 0/1 |
| 188 | +#define ESP_PANEL_BOARD_TOUCH_MIRROR_Y (0) // 0/1 |
| 189 | + |
| 190 | +/** |
| 191 | + * @brief Touch panel control pins |
| 192 | + */ |
| 193 | +#define ESP_PANEL_BOARD_TOUCH_RST_IO (-1) // Reset pin, -1 if not used |
| 194 | +#define ESP_PANEL_BOARD_TOUCH_RST_LEVEL (0) // Reset active level, 0: low, 1: high |
| 195 | +#define ESP_PANEL_BOARD_TOUCH_INT_IO (4) // Interrupt pin, -1 if not used |
| 196 | +#define ESP_PANEL_BOARD_TOUCH_INT_LEVEL (0) // Interrupt active level, 0: low, 1: high |
| 197 | + |
| 198 | +#endif // ESP_PANEL_BOARD_USE_TOUCH |
| 199 | + |
| 200 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 201 | +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// |
| 202 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 203 | +/** |
| 204 | + * @brief Backlight configuration flag (0/1) |
| 205 | + * |
| 206 | + * Set to `1` to enable backlight support, `0` to disable |
| 207 | + */ |
| 208 | +#define ESP_PANEL_BOARD_USE_BACKLIGHT (1) |
| 209 | + |
| 210 | +#if ESP_PANEL_BOARD_USE_BACKLIGHT |
| 211 | +/** |
| 212 | + * @brief Backlight control type selection |
| 213 | + */ |
| 214 | +#define ESP_PANEL_BOARD_BACKLIGHT_TYPE (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) |
| 215 | + |
| 216 | +#if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \ |
| 217 | + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \ |
| 218 | + (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) |
| 219 | + |
| 220 | + /** |
| 221 | + * @brief Backlight control pin configuration |
| 222 | + */ |
| 223 | + #define ESP_PANEL_BOARD_BACKLIGHT_IO (5) // Output GPIO pin number |
| 224 | + #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high |
| 225 | + |
| 226 | +#endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE |
| 227 | + |
| 228 | +/** |
| 229 | + * @brief Backlight idle state configuration (0/1) |
| 230 | + * |
| 231 | + * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on. |
| 232 | + */ |
| 233 | +#define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF (0) |
| 234 | + |
| 235 | +#endif // ESP_PANEL_BOARD_USE_BACKLIGHT |
| 236 | + |
| 237 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 238 | +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// |
| 239 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 240 | +/** |
| 241 | + * @brief IO expander configuration flag (0/1) |
| 242 | + * |
| 243 | + * Set to `1` to enable IO expander support, `0` to disable |
| 244 | + */ |
| 245 | +#define ESP_PANEL_BOARD_USE_EXPANDER (1) |
| 246 | + |
| 247 | +#if ESP_PANEL_BOARD_USE_EXPANDER |
| 248 | +/** |
| 249 | + * @brief IO expander chip selection |
| 250 | + */ |
| 251 | +#define ESP_PANEL_BOARD_EXPANDER_CHIP TCA95XX_8BIT |
| 252 | + |
| 253 | +/** |
| 254 | + * @brief IO expander I2C bus parameters configuration |
| 255 | + */ |
| 256 | +/** |
| 257 | + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. |
| 258 | + * |
| 259 | + * For drivers which created by this library, even if they use the same host, the host will be initialized only once. |
| 260 | + * So it is not necessary to set the macro to `1`. For other devices, please set the macro to `1` ensure that the |
| 261 | + * host is initialized only once. |
| 262 | + */ |
| 263 | +#define ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST (0) // 0/1 |
| 264 | +/* For general */ |
| 265 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 |
| 266 | +/* For host */ |
| 267 | +#if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST |
| 268 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) |
| 269 | + // Typically set to 400K |
| 270 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (0) // 0/1. Typically set to 1 |
| 271 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (0) // 0/1. Typically set to 1 |
| 272 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (10) |
| 273 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (11) |
| 274 | +#endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST |
| 275 | +/* For device */ |
| 276 | +#define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, |
| 277 | + // the I2C address may be different, and confirmation based on |
| 278 | + // the actual hardware connection is required |
| 279 | +#endif // ESP_PANEL_BOARD_USE_EXPANDER |
| 280 | + |
| 281 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 282 | +/////////////////////// Please utilize the following macros to execute any additional code if required ///////////////// |
| 283 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 284 | +/** |
| 285 | + * @brief Pre-begin function for LCD initialization |
| 286 | + * |
| 287 | + * @param[in] p Pointer to the board object |
| 288 | + * @return true on success, false on failure |
| 289 | + */ |
| 290 | +#define ESP_PANEL_BOARD_LCD_PRE_BEGIN_FUNCTION(p) \ |
| 291 | + { \ |
| 292 | + constexpr int LCD_RST = 1; \ |
| 293 | + auto board = static_cast<Board *>(p); \ |
| 294 | + auto expander = board->getIO_Expander()->getBase(); \ |
| 295 | + /* LCD reset */ \ |
| 296 | + expander->pinMode(LCD_RST, OUTPUT); \ |
| 297 | + expander->digitalWrite(LCD_RST, LOW); \ |
| 298 | + vTaskDelay(pdMS_TO_TICKS(10)); \ |
| 299 | + expander->digitalWrite(LCD_RST, HIGH); \ |
| 300 | + vTaskDelay(pdMS_TO_TICKS(100)); \ |
| 301 | + return true; \ |
| 302 | + } |
| 303 | + |
| 304 | +/** |
| 305 | + * @brief Pre-begin function for touch panel initialization |
| 306 | + * |
| 307 | + * @param[in] p Pointer to the board object |
| 308 | + * @return true on success, false on failure |
| 309 | + */ |
| 310 | +#define ESP_PANEL_BOARD_TOUCH_PRE_BEGIN_FUNCTION(p) \ |
| 311 | + { \ |
| 312 | + constexpr int TP_RST = 0; \ |
| 313 | + auto board = static_cast<Board *>(p); \ |
| 314 | + auto expander = board->getIO_Expander()->getBase(); \ |
| 315 | + /* Touch reset */ \ |
| 316 | + expander->pinMode(TP_RST, OUTPUT); \ |
| 317 | + expander->digitalWrite(TP_RST, LOW); \ |
| 318 | + vTaskDelay(pdMS_TO_TICKS(30)); \ |
| 319 | + expander->digitalWrite(TP_RST, HIGH); \ |
| 320 | + vTaskDelay(pdMS_TO_TICKS(50)); \ |
| 321 | + return true; \ |
| 322 | + } |
| 323 | + |
| 324 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 325 | +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// |
| 326 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 327 | +/** |
| 328 | + * Do not change the following versions. These version numbers are used to check compatibility between this |
| 329 | + * configuration file and the library. Rules for version numbers: |
| 330 | + * 1. Major version mismatch: Configurations are incompatible, must use library version |
| 331 | + * 2. Minor version mismatch: May be missing new configurations, recommended to update |
| 332 | + * 3. Patch version mismatch: No impact on functionality |
| 333 | + */ |
| 334 | +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 |
| 335 | +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 |
| 336 | +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 |
| 337 | + |
| 338 | +// *INDENT-ON* |
0 commit comments