|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#pragma once |
| 8 | + |
| 9 | +// *INDENT-OFF* |
| 10 | + |
| 11 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 12 | +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// |
| 13 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 14 | +/* Set to 1 when using an LCD panel */ |
| 15 | +#define ESP_PANEL_USE_LCD (1) // 0/1 |
| 16 | + |
| 17 | +#if ESP_PANEL_USE_LCD |
| 18 | +/** |
| 19 | + * LCD Controller Name. |
| 20 | + */ |
| 21 | +#define ESP_PANEL_LCD_NAME EK9716BD3 |
| 22 | + |
| 23 | +/* LCD resolution in pixels */ |
| 24 | +#define ESP_PANEL_LCD_WIDTH (800) |
| 25 | +#define ESP_PANEL_LCD_HEIGHT (480) |
| 26 | + |
| 27 | +/* LCD Bus Settings */ |
| 28 | +/** |
| 29 | + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. |
| 30 | + * It is useful if other devices use the same host. Please ensure that the host is initialized only once. |
| 31 | + */ |
| 32 | +#define ESP_PANEL_LCD_BUS_SKIP_INIT_HOST (1) // 0/1 |
| 33 | +/** |
| 34 | + * LCD Bus Type. |
| 35 | + */ |
| 36 | +#define ESP_PANEL_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_RGB) |
| 37 | +/** |
| 38 | + * LCD Bus Parameters. |
| 39 | + * |
| 40 | + * Please refer to https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/lcd.html and |
| 41 | + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html for more details. |
| 42 | + * |
| 43 | + */ |
| 44 | +#if ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB |
| 45 | + |
| 46 | + #define ESP_PANEL_LCD_RGB_CLK_HZ (14 * 1000 * 1000) |
| 47 | + #define ESP_PANEL_LCD_RGB_HPW (48) // Hsync pulse width x |
| 48 | + #define ESP_PANEL_LCD_RGB_HBP (40) // Hsync back porch x |
| 49 | + #define ESP_PANEL_LCD_RGB_HFP (40) // Hsync front porch x |
| 50 | + #define ESP_PANEL_LCD_RGB_VPW (31) // Vsync pulse width x |
| 51 | + #define ESP_PANEL_LCD_RGB_VBP (13) // Vsync back porch x |
| 52 | + #define ESP_PANEL_LCD_RGB_VFP (1) // Vsync front porch |
| 53 | + #define ESP_PANEL_LCD_RGB_PCLK_ACTIVE_NEG (1) // 0: rising edge, 1: falling edge |
| 54 | + #define ESP_PANEL_LCD_RGB_DATA_WIDTH (16) // 8 | 16 |
| 55 | + #define ESP_PANEL_LCD_RGB_PIXEL_BITS (16) // 24 | 16 |
| 56 | + #define ESP_PANEL_LCD_RGB_FRAME_BUF_NUM (1) // 1/2/3 |
| 57 | + #define ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_LCD_WIDTH * 10) |
| 58 | + // Bounce buffer size in bytes. This function is used to avoid screen drift. |
| 59 | + // To enable the bounce buffer, set it to a non-zero value. |
| 60 | + // Typically set to `ESP_PANEL_LCD_WIDTH * 10` |
| 61 | + #define ESP_PANEL_LCD_RGB_IO_HSYNC (39) |
| 62 | + #define ESP_PANEL_LCD_RGB_IO_VSYNC (40) |
| 63 | + #define ESP_PANEL_LCD_RGB_IO_DE (41) // -1 if not used |
| 64 | + #define ESP_PANEL_LCD_RGB_IO_PCLK (0) |
| 65 | + #define ESP_PANEL_LCD_RGB_IO_DISP (-1) // -1 if not used |
| 66 | + #define ESP_PANEL_LCD_RGB_IO_DATA0 (15) |
| 67 | + #define ESP_PANEL_LCD_RGB_IO_DATA1 (7) |
| 68 | + #define ESP_PANEL_LCD_RGB_IO_DATA2 (6) |
| 69 | + #define ESP_PANEL_LCD_RGB_IO_DATA3 (5) |
| 70 | + #define ESP_PANEL_LCD_RGB_IO_DATA4 (4) |
| 71 | + #define ESP_PANEL_LCD_RGB_IO_DATA5 (9) |
| 72 | + #define ESP_PANEL_LCD_RGB_IO_DATA6 (46) |
| 73 | + #define ESP_PANEL_LCD_RGB_IO_DATA7 (3) |
| 74 | +#if ESP_PANEL_LCD_RGB_DATA_WIDTH > 8 |
| 75 | + #define ESP_PANEL_LCD_RGB_IO_DATA8 (8) |
| 76 | + #define ESP_PANEL_LCD_RGB_IO_DATA9 (16) |
| 77 | + #define ESP_PANEL_LCD_RGB_IO_DATA10 (1) |
| 78 | + #define ESP_PANEL_LCD_RGB_IO_DATA11 (14) |
| 79 | + #define ESP_PANEL_LCD_RGB_IO_DATA12 (21) |
| 80 | + #define ESP_PANEL_LCD_RGB_IO_DATA13 (47) |
| 81 | + #define ESP_PANEL_LCD_RGB_IO_DATA14 (48) |
| 82 | + #define ESP_PANEL_LCD_RGB_IO_DATA15 (45) |
| 83 | +#endif |
| 84 | + |
| 85 | +#endif /* ESP_PANEL_LCD_BUS_TYPE */ |
| 86 | + |
| 87 | +/** |
| 88 | + * LCD Venbdor Initialization Commands. |
| 89 | + * |
| 90 | + * Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for |
| 91 | + * initialization sequence code. Please uncomment and change the following macro definitions. Otherwise, the LCD driver |
| 92 | + * will use the default initialization sequence code. |
| 93 | + * |
| 94 | + * There are two formats for the sequence code: |
| 95 | + * 1. Raw data: {command, (uint8_t []){ data0, data1, ... }, data_size, delay_ms} |
| 96 | + * 2. Formater: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and |
| 97 | + * ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command) |
| 98 | + */ |
| 99 | +// #define ESP_PANEL_LCD_VENDOR_INIT_CMD \ |
| 100 | +// { \ |
| 101 | +// {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0}, \ |
| 102 | +// {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0}, \ |
| 103 | +// {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0}, \ |
| 104 | +// {0x29, (uint8_t []){0x00}, 0, 120}, \ |
| 105 | +// or \ |
| 106 | +// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}), \ |
| 107 | +// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}), \ |
| 108 | +// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}), \ |
| 109 | +// ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29), \ |
| 110 | +// } |
| 111 | + |
| 112 | +/* LCD Color Settings */ |
| 113 | +/* LCD color depth in bits */ |
| 114 | +#define ESP_PANEL_LCD_COLOR_BITS (24) // 8/16/18/24 |
| 115 | +/* |
| 116 | + * LCD RGB Element Order. Choose one of the following: |
| 117 | + * - 0: RGB |
| 118 | + * - 1: BGR |
| 119 | + */ |
| 120 | +#define ESP_PANEL_LCD_BGR_ORDER (0) // 0/1 |
| 121 | +#define ESP_PANEL_LCD_INEVRT_COLOR (0) // 0/1 |
| 122 | + |
| 123 | +/* LCD Transformation Flags */ |
| 124 | +#define ESP_PANEL_LCD_SWAP_XY (0) // 0/1 |
| 125 | +#define ESP_PANEL_LCD_MIRROR_X (0) // 0/1 |
| 126 | +#define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 |
| 127 | + |
| 128 | +/* LCD Other Settings */ |
| 129 | +/* IO num of RESET pin, set to -1 if not use */ |
| 130 | +#define ESP_PANEL_LCD_IO_RST (-1) |
| 131 | +#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level |
| 132 | + |
| 133 | +#endif /* ESP_PANEL_USE_LCD */ |
| 134 | + |
| 135 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 136 | +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// |
| 137 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 138 | +/* Set to 1 when using an touch panel */ |
| 139 | +#define ESP_PANEL_USE_TOUCH (1) // 0/1 |
| 140 | +#if ESP_PANEL_USE_TOUCH |
| 141 | +/** |
| 142 | + * Touch controller name. |
| 143 | + */ |
| 144 | +#define ESP_PANEL_TOUCH_NAME GT911 |
| 145 | + |
| 146 | +/* Touch resolution in pixels */ |
| 147 | +#define ESP_PANEL_TOUCH_H_RES (ESP_PANEL_LCD_HEIGHT) // Typically set to the same value as the width of LCD |
| 148 | +#define ESP_PANEL_TOUCH_V_RES (ESP_PANEL_LCD_WIDTH) // Typically set to the same value as the height of LCD |
| 149 | + |
| 150 | +/* Touch Panel Bus Settings */ |
| 151 | +/** |
| 152 | + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. |
| 153 | + * It is useful if other devices use the same host. Please ensure that the host is initialized only once. |
| 154 | + */ |
| 155 | +#define ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1 |
| 156 | +/** |
| 157 | + * Touch panel bus type. |
| 158 | + */ |
| 159 | +#define ESP_PANEL_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) |
| 160 | +/* Touch panel bus parameters */ |
| 161 | +#if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C |
| 162 | + |
| 163 | + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 |
| 164 | + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address |
| 165 | +#if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST |
| 166 | + #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) |
| 167 | + // Typically set to 400K |
| 168 | + #define ESP_PANEL_TOUCH_I2C_SCL_PULLUP (0) // 0/1 |
| 169 | + #define ESP_PANEL_TOUCH_I2C_SDA_PULLUP (0) // 0/1 |
| 170 | + #define ESP_PANEL_TOUCH_I2C_IO_SCL (20) |
| 171 | + #define ESP_PANEL_TOUCH_I2C_IO_SDA (19) |
| 172 | +#endif |
| 173 | + |
| 174 | +#endif |
| 175 | + |
| 176 | +/* Touch Transformation Flags */ |
| 177 | +#define ESP_PANEL_TOUCH_SWAP_XY (0) // 0/1 |
| 178 | +#define ESP_PANEL_TOUCH_MIRROR_X (0) // 0/1 |
| 179 | +#define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1 |
| 180 | + |
| 181 | +/* Touch Other Settings */ |
| 182 | +/* IO num of RESET pin, set to -1 if not use */ |
| 183 | +#define ESP_PANEL_TOUCH_IO_RST (-1) |
| 184 | +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level |
| 185 | +/* IO num of INT pin, set to -1 if not use */ |
| 186 | +#define ESP_PANEL_TOUCH_IO_INT (38) |
| 187 | +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level |
| 188 | + |
| 189 | +#endif /* ESP_PANEL_USE_TOUCH */ |
| 190 | + |
| 191 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 192 | +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// |
| 193 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 194 | +#define ESP_PANEL_USE_BACKLIGHT (1) // 0/1 |
| 195 | +#if ESP_PANEL_USE_BACKLIGHT |
| 196 | +/* IO num of backlight pin */ |
| 197 | +#define ESP_PANEL_BACKLIGHT_IO (2) |
| 198 | +#define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level |
| 199 | + |
| 200 | +/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ |
| 201 | +#define ESP_PANEL_BACKLIGHT_IDLE_OFF (0) // 0: on, 1: off |
| 202 | + |
| 203 | +/* Set to 1 if use PWM for brightness control */ |
| 204 | +#define ESP_PANEL_LCD_BL_USE_PWM (0) // 0/1 |
| 205 | +#endif /* ESP_PANEL_USE_BACKLIGHT */ |
| 206 | + |
| 207 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 208 | +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// |
| 209 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 210 | +/* Set to 0 if not using IO Expander */ |
| 211 | +#define ESP_PANEL_USE_EXPANDER (0) // 0/1 |
| 212 | + |
| 213 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 214 | +///////////////////////////// Please utilize the following macros to execute any additional code if required. ////////// |
| 215 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 216 | +// #define ESP_PANEL_BEGIN_START_FUNCTION( panel ) |
| 217 | +// #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel ) |
| 218 | +// #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel ) |
| 219 | +#define ESP_PANEL_BEGIN_LCD_START_FUNCTION( panel ) \ |
| 220 | + |
| 221 | + { \ |
| 222 | + /* Maintain the touch INT signal in a low state during the reset process to set its I2C address to `0x5D` */ \ |
| 223 | + gpio_set_direction((gpio_num_t)ESP_PANEL_TOUCH_IO_INT, GPIO_MODE_OUTPUT); \ |
| 224 | + gpio_set_level((gpio_num_t)ESP_PANEL_TOUCH_IO_INT, 0); \ |
| 225 | + vTaskDelay(pdMS_TO_TICKS(10)); \ |
| 226 | + } |
| 227 | + |
| 228 | +// #define ESP_PANEL_BEGIN_LCD_END_FUNCTION( panel ) |
| 229 | +// #define ESP_PANEL_BEGIN_TOUCH_START_FUNCTION( panel ) |
| 230 | +// #define ESP_PANEL_BEGIN_TOUCH_END_FUNCTION( panel ) |
| 231 | +// #define ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION( panel ) |
| 232 | +// #define ESP_PANEL_BEGIN_BACKLIGHT_END_FUNCTION( panel ) |
| 233 | +// #define ESP_PANEL_BEGIN_END_FUNCTION( panel ) |
| 234 | + |
| 235 | +// *INDENT-OFF* |
0 commit comments