Advertisement
Guest User

Untitled

a guest
May 21st, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 34.07 KB | Software | 0 0
  1. /*
  2.  * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
  3.  *
  4.  * SPDX-License-Identifier: Apache-2.0
  5.  */
  6. /**
  7.  * @file   esp_panel_board_custom_conf.h
  8.  * @brief  Configuration file for custom ESP development boards
  9.  * @author
  10.  * @link
  11.  *
  12.  * This file contains all the configurations needed for a custom board using ESP Panel.
  13.  * Users can modify these configurations according to their hardware design.
  14.  */
  15.  
  16. #pragma once
  17.  
  18. // *INDENT-OFF*
  19.  
  20. /**
  21.  * @brief Flag to enable custom board configuration (0/1)
  22.  *
  23.  * Set to `1` to enable custom board configuration, `0` to disable
  24.  */
  25. #define ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM  (1)
  26.  
  27. #if ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM
  28. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  29. ///////////////////////// Please update the following macros to configure general parameters ///////////////////////////
  30. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. /**
  32.  * @brief Board name (format: "Manufacturer:Model")
  33.  */
  34. #define ESP_PANEL_BOARD_NAME                "Custom:Custom"
  35.  
  36. /**
  37.  * @brief Panel resolution configuration in pixels
  38.  */
  39. #define ESP_PANEL_BOARD_WIDTH               (1280)   // Panel width (horizontal, in pixels)
  40. #define ESP_PANEL_BOARD_HEIGHT              (800)   // Panel height (vertical, in pixels)
  41.  
  42. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  43. //////////////////////////// Please update the following macros to configure the LCD panel /////////////////////////////
  44. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  45. /**
  46.  * @brief LCD panel configuration flag (0/1)
  47.  *
  48.  * Set to `1` to enable LCD panel support, `0` to disable
  49.  */
  50. #define ESP_PANEL_BOARD_USE_LCD             (1)
  51.  
  52. #if ESP_PANEL_BOARD_USE_LCD
  53. /**
  54.  * @brief LCD controller selection
  55.  *
  56.  * Supported controllers:
  57.  * - `AXS15231B`
  58.  * - `EK9716B`, `EK79007`
  59.  * - `GC9A01`, `GC9B71`, `GC9503`
  60.  * - `HX8399`
  61.  * - `ILI9341`, `ILI9881C`
  62.  * - `JD9165`, `JD9365`
  63.  * - `NV3022B`
  64.  * - `SH8601`
  65.  * - `SPD2010`
  66.  * - `ST7262`, `ST7701`, `ST7703`, `ST7789`, `ST7796`, `ST77903`, `ST77916`, `ST77922`
  67.  */
  68. #define ESP_PANEL_BOARD_LCD_CONTROLLER      JD9365
  69.  
  70. /**
  71.  * @brief LCD bus type selection
  72.  *
  73.  * Supported bus types:
  74.  * - `ESP_PANEL_BUS_TYPE_SPI`
  75.  * - `ESP_PANEL_BUS_TYPE_QSPI`
  76.  * - `ESP_PANEL_BUS_TYPE_RGB` (ESP32-S3 only)
  77.  * - `ESP_PANEL_BUS_TYPE_MIPI_DSI` (ESP32-P4 only)
  78.  */
  79. #define ESP_PANEL_BOARD_LCD_BUS_TYPE        (ESP_PANEL_BUS_TYPE_MIPI_DSI)
  80.  
  81. #if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI) || \
  82.     (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI)
  83. /**
  84.  * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
  85.  *
  86.  * For drivers which created by this library, even if they use the same host, the host will be initialized only once.
  87.  * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1`
  88.  * ensure that the host is initialized only once.
  89.  */
  90. #define ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST      (0)     // 0/1. Typically set to 0
  91. #endif
  92.  
  93. /**
  94.  * @brief LCD bus parameters configuration
  95.  *
  96.  * Configure parameters based on the selected bus type. Parameters for other bus types will be ignored.
  97.  * For detailed parameter explanations, see:
  98.  * https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32s3/api-reference/peripherals/lcd/index.html
  99.  * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html
  100.  */
  101. #if ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI
  102.  
  103.     /**
  104.      * @brief SPI bus
  105.      */
  106.     /* For general */
  107.     #define ESP_PANEL_BOARD_LCD_SPI_HOST_ID         (1)     // Typically set to 1
  108. #if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST
  109.     /* For host */
  110.     #define ESP_PANEL_BOARD_LCD_SPI_IO_SCK          (7)
  111.     #define ESP_PANEL_BOARD_LCD_SPI_IO_MOSI         (6)
  112.     #define ESP_PANEL_BOARD_LCD_SPI_IO_MISO         (-1)    // -1 if not used
  113. #endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST
  114.     /* For panel */
  115.     #define ESP_PANEL_BOARD_LCD_SPI_IO_CS           (5)     // -1 if not used
  116.     #define ESP_PANEL_BOARD_LCD_SPI_IO_DC           (4)
  117.     #define ESP_PANEL_BOARD_LCD_SPI_MODE            (0)     // 0-3. Typically set to 0
  118.     #define ESP_PANEL_BOARD_LCD_SPI_CLK_HZ          (40 * 1000 * 1000)
  119.                                                             // Should be an integer divisor of 80M, typically set to 40M
  120.     #define ESP_PANEL_BOARD_LCD_SPI_CMD_BITS        (8)     // Typically set to 8
  121.     #define ESP_PANEL_BOARD_LCD_SPI_PARAM_BITS      (8)     // Typically set to 8
  122.  
  123. #elif ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI
  124.  
  125.     /**
  126.      * @brief QSPI bus
  127.      */
  128.     /* For general */
  129.     #define ESP_PANEL_BOARD_LCD_QSPI_HOST_ID        (1)     // Typically set to 1
  130. #if !ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST
  131.     /* For host */
  132.     #define ESP_PANEL_BOARD_LCD_QSPI_IO_SCK         (9)
  133.     #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA0       (10)
  134.     #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA1       (11)
  135.     #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA2       (12)
  136.     #define ESP_PANEL_BOARD_LCD_QSPI_IO_DATA3       (13)
  137. #endif // ESP_PANEL_BOARD_LCD_BUS_SKIP_INIT_HOST
  138.     /* For panel */
  139.     #define ESP_PANEL_BOARD_LCD_QSPI_IO_CS          (5)     // -1 if not used
  140.     #define ESP_PANEL_BOARD_LCD_QSPI_MODE           (0)     // 0-3, typically set to 0
  141.     #define ESP_PANEL_BOARD_LCD_QSPI_CLK_HZ         (40 * 1000 * 1000)
  142.                                                             // Should be an integer divisor of 80M, typically set to 40M
  143.     #define ESP_PANEL_BOARD_LCD_QSPI_CMD_BITS       (32)    // Typically set to 32
  144.     #define ESP_PANEL_BOARD_LCD_QSPI_PARAM_BITS     (8)     // Typically set to 8
  145.  
  146. #elif ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB
  147.  
  148.     /**
  149.      * @brief RGB bus
  150.      */
  151.     /**
  152.      * Set to 0 if using simple "RGB" interface which does not contain "3-wire SPI" interface.
  153.      */
  154.     #define ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL       (1) // 0/1. Typically set to 1
  155.  
  156. #if ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL
  157.     /* For control panel (3wire-SPI) */
  158.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_CS               (0)
  159.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SCK              (1)
  160.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_IO_SDA              (2)
  161.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_CS_USE_EXPNADER     (0) // Set to 1 if the signal is controlled by an IO expander
  162.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_SCL_USE_EXPNADER    (0) // Set to 1 if the signal is controlled by an IO expander
  163.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_SDA_USE_EXPNADER    (0) // Set to 1 if the signal is controlled by an IO expander
  164.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_MODE                (0) // 0-3, typically set to 0
  165.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_CMD_BYTES           (1) // Typically set to 1
  166.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_PARAM_BYTES         (1) // Typically set to 1
  167.     #define ESP_PANEL_BOARD_LCD_RGB_SPI_USE_DC_BIT          (1) // 0/1. Typically set to 1
  168. #endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL
  169.     /* For refresh panel (RGB) */
  170.     #define ESP_PANEL_BOARD_LCD_RGB_CLK_HZ          (16 * 1000 * 1000)
  171.                                                             // 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
  172.     #define ESP_PANEL_BOARD_LCD_RGB_HPW             (10)
  173.     #define ESP_PANEL_BOARD_LCD_RGB_HBP             (10)
  174.     #define ESP_PANEL_BOARD_LCD_RGB_HFP             (20)
  175.     #define ESP_PANEL_BOARD_LCD_RGB_VPW             (10)
  176.     #define ESP_PANEL_BOARD_LCD_RGB_VBP             (10)
  177.     #define ESP_PANEL_BOARD_LCD_RGB_VFP             (10)
  178.     #define ESP_PANEL_BOARD_LCD_RGB_PCLK_ACTIVE_NEG (0)     // 0: rising edge, 1: falling edge. Typically set to 0
  179.                                                                                         // The following sheet shows the valid combinations of
  180.                                                                                         // data width and pixel bits:
  181.                                                                                         // ┏---------------------------------┳- -------------------------------┓
  182.     #define ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH      (16)                                // |                16               |               8                 |
  183.     #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 |
  184.                                                                                         // ┗---------------------------------┻---------------------------------┛
  185.                                                             // 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
  186.     #define ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE (ESP_PANEL_BOARD_WIDTH * 10)
  187.                                                             // Bounce buffer size in bytes. It is used to avoid screen drift
  188.                                                             // for ESP32-S3. Typically set to `ESP_PANEL_BOARD_WIDTH * 10`
  189.                                                             // The size should satisfy `size * N = LCD_width * LCD_height`,
  190.                                                             // where N is an even number.
  191.                                                             // 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
  192.     #define ESP_PANEL_BOARD_LCD_RGB_IO_HSYNC        (46)
  193.     #define ESP_PANEL_BOARD_LCD_RGB_IO_VSYNC        (3)
  194.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DE           (17)    // -1 if not used
  195.     #define ESP_PANEL_BOARD_LCD_RGB_IO_PCLK         (9)
  196.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DISP         (-1)    // -1 if not used. Typically set to -1
  197.  
  198.                                                             // The following sheet shows the mapping of ESP GPIOs to
  199.                                                             // LCD data pins with different data width and color format:
  200.                                                             // ┏------┳- ------------┳--------------------------┓
  201.                                                             // | ESP: | 8-bit RGB888 |      16-bit RGB565       |
  202.                                                             // |------|--------------|--------------------------|
  203.                                                             // | LCD: |    RGB888    | RGB565 | RGB666 | RGB888 |
  204.                                                             // ┗------|--------------|--------|--------|--------|
  205.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA0        (10)    //        |      D0      |   B0   |  B0-1  |   B0-3 |
  206.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA1        (11)    //        |      D1      |   B1   |  B2    |   B4   |
  207.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA2        (12)    //        |      D2      |   B2   |  B3    |   B5   |
  208.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA3        (13)    //        |      D3      |   B3   |  B4    |   B6   |
  209.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA4        (14)    //        |      D4      |   B4   |  B5    |   B7   |
  210.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA5        (21)    //        |      D5      |   G0   |  G0    |   G0-2 |
  211.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA6        (47)    //        |      D6      |   G1   |  G1    |   G3   |
  212.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA7        (48)    //        |      D7      |   G2   |  G2    |   G4   |
  213. #if ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH > 8                  //        ┗--------------┫--------|--------|--------|
  214.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA8        (45)    //                       |   G3   |  G3    |   G5   |
  215.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA9        (38)    //                       |   G4   |  G4    |   G6   |
  216.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA10       (39)    //                       |   G5   |  G5    |   G7   |
  217.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA11       (40)    //                       |   R0   |  R0-1  |   R0-3 |
  218.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA12       (41)    //                       |   R1   |  R2    |   R4   |
  219.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA13       (42)    //                       |   R2   |  R3    |   R5   |
  220.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA14       (2)     //                       |   R3   |  R4    |   R6   |
  221.     #define ESP_PANEL_BOARD_LCD_RGB_IO_DATA15       (1)     //                       |   R4   |  R5    |   R7   |
  222.                                                             //                       ┗--------┻--------┻--------┛
  223. #endif // ESP_PANEL_BOARD_LCD_RGB_DATA_WIDTH
  224.  
  225. #elif ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_MIPI_DSI
  226.  
  227.     /**
  228.      * @brief MIPI DSI bus
  229.      */
  230.     /* For host */
  231.     #define ESP_PANEL_BOARD_LCD_MIPI_DSI_LANE_NUM           (2)     // ESP32-P4 supports 1 or 2 lanes
  232.     #define ESP_PANEL_BOARD_LCD_MIPI_DSI_LANE_RATE_MBPS     (1000)  // Single lane bit rate, should check the LCD drive IC
  233.                                                                     // datasheet for the supported lane rate. Different
  234.                                                                     // color format (RGB565/RGB888) may have different
  235.                                                                     // lane bit rate requirements.
  236.                                                                     // ESP32-P4 supports max 1500Mbps
  237.     /* For refresh panel (DPI) */
  238.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_CLK_MHZ            (52)
  239.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_PIXEL_BITS         (ESP_PANEL_LCD_COLOR_BITS_RGB565)
  240.                                                                     // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888
  241.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_HPW                (10)
  242.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_HBP                (160)
  243.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_HFP                (160)
  244.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_VPW                (1)
  245.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_VBP                (23)
  246.     #define ESP_PANEL_BOARD_LCD_MIPI_DPI_VFP                (12)
  247.     /* For DSI power PHY */
  248.     #define ESP_PANEL_BOARD_LCD_MIPI_PHY_LDO_ID             (3)     // -1 if not used.
  249.  
  250. #else
  251.  
  252.     #error "The function is not ready and will be implemented in the future."
  253.  
  254. #endif // ESP_PANEL_BOARD_LCD_BUS_TYPE
  255.  
  256. /**
  257.  * @brief LCD specific flags configuration
  258.  *
  259.  * These flags are specific to the "3-wire SPI + RGB" bus.
  260.  */
  261. #if (ESP_PANEL_BOARD_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB) && ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL
  262. /**
  263.  * @brief Enable IO multiplex
  264.  *
  265.  * Set to 1 if the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs. Then, the control panel
  266.  * and its pins (except CS signal) will be released after LCD call `init()`. All `*_by_cmd` flags will be invalid.
  267.  */
  268. #define ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX       (0) // typically set to 0
  269. /**
  270.  * @brief Mirror by command
  271.  *
  272.  * Set to 1 if the `mirror()` function will be implemented by LCD command. Otherwise, the function will be implemented by
  273.  * software. Only valid when `ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX` is 0.
  274.  */
  275. #define ESP_PANEL_BOARD_LCD_FLAGS_MIRROR_BY_CMD             (!ESP_PANEL_BOARD_LCD_FLAGS_ENABLE_IO_MULTIPLEX)
  276. #endif // ESP_PANEL_BOARD_LCD_RGB_USE_CONTROL_PANEL
  277.  
  278. /**
  279.  * @brief LCD vendor initialization commands
  280.  *
  281.  * Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for
  282.  * initialization sequence code. Please uncomment and change the following macro definitions. Otherwise, the LCD driver
  283.  * will use the default initialization sequence code.
  284.  *
  285.  * The initialization sequence can be specified in two formats:
  286.  * 1. Raw format:
  287.  *    {command, (uint8_t []){data0, data1, ...}, data_size, delay_ms}
  288.  * 2. Helper macros:
  289.  *    - ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, {data0, data1, ...})
  290.  *    - ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
  291.  */
  292. /*
  293. #define ESP_PANEL_BOARD_LCD_VENDOR_INIT_CMD()                       \
  294.     {                                                               \
  295.         {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},   \
  296.         {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0},                     \
  297.         {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0},                     \
  298.         {0x29, (uint8_t []){0x00}, 0, 120},                         \
  299.         or
  300.         ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}), \
  301.         ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}),                   \
  302.         ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}),                   \
  303.         ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29),                               \
  304.     }
  305. */
  306.  
  307. /**
  308.  * @brief LCD color configuration
  309.  */
  310. #define ESP_PANEL_BOARD_LCD_COLOR_BITS          (ESP_PANEL_LCD_COLOR_BITS_RGB565)
  311.                                                         // ESP_PANEL_LCD_COLOR_BITS_RGB565/RGB666/RGB888
  312. #define ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER     (0)     // 0: RGB, 1: BGR
  313. #define ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT    (0)     // 0/1
  314.  
  315. /**
  316.  * @brief LCD transformation configuration
  317.  */
  318. #define ESP_PANEL_BOARD_LCD_SWAP_XY             (0)     // 0/1
  319. #define ESP_PANEL_BOARD_LCD_MIRROR_X            (0)     // 0/1
  320. #define ESP_PANEL_BOARD_LCD_MIRROR_Y            (0)     // 0/1
  321. #define ESP_PANEL_BOARD_LCD_GAP_X               (0)     // [0, ESP_PANEL_BOARD_WIDTH]
  322. #define ESP_PANEL_BOARD_LCD_GAP_Y               (0)     // [0, ESP_PANEL_BOARD_HEIGHT]
  323.  
  324. /**
  325.  * @brief LCD reset pin configuration
  326.  */
  327. #define ESP_PANEL_BOARD_LCD_RST_IO              (-1)    // Reset pin, -1 if not used
  328. #define ESP_PANEL_BOARD_LCD_RST_LEVEL           (0)     // Reset active level, 0: low, 1: high
  329.  
  330. #endif // ESP_PANEL_BOARD_USE_LCD
  331.  
  332. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  333. //////////////////////////// Please update the following macros to configure the touch panel ///////////////////////////
  334. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  335. /**
  336.  * @brief Touch panel configuration flag (0/1)
  337.  *
  338.  * Set to `1` to enable touch panel support, `0` to disable
  339.  */
  340. #define ESP_PANEL_BOARD_USE_TOUCH               (0)
  341.  
  342. #if ESP_PANEL_BOARD_USE_TOUCH
  343. /**
  344.  * @brief Touch controller selection
  345.  *
  346.  * Supported controllers:
  347.  * - `AXS15231B`
  348.  * - `CHSC6540`
  349.  * - `CST816S`
  350.  * - `FT5x06`
  351.  * - `GT911`, `GT1151`
  352.  * - `SPD2010`
  353.  * - `ST1633`, `ST7123`
  354.  * - `STMPE610`
  355.  * - `TT21100`
  356.  * - `XPT2046`
  357.  */
  358. #define ESP_PANEL_BOARD_TOUCH_CONTROLLER        TT21100
  359.  
  360. /**
  361.  * @brief Touch bus type selection
  362.  *
  363.  * Supported types:
  364.  * - `ESP_PANEL_BUS_TYPE_I2C`
  365.  * - `ESP_PANEL_BUS_TYPE_SPI`
  366.  */
  367. #define ESP_PANEL_BOARD_TOUCH_BUS_TYPE          (ESP_PANEL_BUS_TYPE_I2C)
  368.  
  369. #if (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C) || \
  370.     (ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI)
  371. /**
  372.  * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
  373.  *
  374.  * For drivers which created by this library, even if they use the same host, the host will be initialized only once.
  375.  * So it is not necessary to set the macro to `1`. For other drivers (like `Wire`), please set the macro to `1`
  376.  * ensure that the host is initialized only once.
  377.  */
  378. #define ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST        (0)     // 0/1. Typically set to 0
  379. #endif
  380.  
  381. /**
  382.  * @brief Touch bus parameters configuration
  383.  */
  384. #if ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C
  385.  
  386.     /**
  387.      * @brief I2C bus
  388.      */
  389.     /* For general */
  390.     #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID           (0)     // Typically set to 0
  391. #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST
  392.     /* For host */
  393.     #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ            (400 * 1000)
  394.                                                                 // Typically set to 400K
  395.     #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP        (1)     // 0/1. Typically set to 1
  396.     #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP        (1)     // 0/1. Typically set to 1
  397.     #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL            (18)
  398.     #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA            (8)
  399. #endif
  400.     /* For panel */
  401.     #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS           (0)     // Typically set to 0 to use the default address.
  402.                                                                 // - For touchs with only one address, set to 0
  403.                                                                 // - For touchs with multiple addresses, set to 0 or
  404.                                                                 //   the address. Like GT911, there are two addresses:
  405.                                                                 //   0x5D(default) and 0x14
  406.  
  407. #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI
  408.  
  409.     /**
  410.      * @brief SPI bus
  411.      */
  412.     /* For general */
  413.     #define ESP_PANEL_BOARD_TOUCH_SPI_HOST_ID           (1)     // Typically set to 1
  414. #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST
  415.     /* For host */
  416.     #define ESP_PANEL_BOARD_TOUCH_SPI_IO_SCK            (7)
  417.     #define ESP_PANEL_BOARD_TOUCH_SPI_IO_MOSI           (6)
  418.     #define ESP_PANEL_BOARD_TOUCH_SPI_IO_MISO           (9)
  419. #endif
  420.     /* For panel */
  421.     #define ESP_PANEL_BOARD_TOUCH_SPI_IO_CS             (5)
  422.     #define ESP_PANEL_BOARD_TOUCH_SPI_CLK_HZ            (1 * 1000 * 1000)  // Should be integer divisor of 80M
  423.  
  424. #else
  425.  
  426.     #error "The function is not ready and will be implemented in the future."
  427.  
  428. #endif // ESP_PANEL_BOARD_TOUCH_BUS_TYPE
  429.  
  430. /**
  431.  * @brief Touch panel transformation flags
  432.  */
  433. #define ESP_PANEL_BOARD_TOUCH_SWAP_XY           (0)     // 0/1
  434. #define ESP_PANEL_BOARD_TOUCH_MIRROR_X          (0)     // 0/1
  435. #define ESP_PANEL_BOARD_TOUCH_MIRROR_Y          (0)     // 0/1
  436.  
  437. /**
  438.  * @brief Touch panel control pins
  439.  */
  440. #define ESP_PANEL_BOARD_TOUCH_RST_IO            (-1)    // Reset pin, -1 if not used
  441. #define ESP_PANEL_BOARD_TOUCH_RST_LEVEL         (0)     // Reset active level, 0: low, 1: high
  442. #define ESP_PANEL_BOARD_TOUCH_INT_IO            (-1)    // Interrupt pin, -1 if not used
  443. #define ESP_PANEL_BOARD_TOUCH_INT_LEVEL         (0)     // Interrupt active level, 0: low, 1: high
  444.  
  445. #endif // ESP_PANEL_BOARD_USE_TOUCH
  446.  
  447. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  448. ///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
  449. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  450. /**
  451.  * @brief Backlight configuration flag (0/1)
  452.  *
  453.  * Set to `1` to enable backlight support, `0` to disable
  454.  */
  455. #define ESP_PANEL_BOARD_USE_BACKLIGHT           (0)
  456.  
  457. #if ESP_PANEL_BOARD_USE_BACKLIGHT
  458. /**
  459.  * @brief Backlight control type selection
  460.  *
  461.  * Supported types:
  462.  * - `ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO`: Use GPIO switch to control the backlight, only support on/off
  463.  * - `ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER`: Use IO expander to control the backlight, only support on/off
  464.  * - `ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC`: Use LEDC PWM to control the backlight, support brightness adjustment
  465.  * - `ESP_PANEL_BACKLIGHT_TYPE_CUSTOM`: Use custom function to control the backlight
  466.  */
  467. #define ESP_PANEL_BOARD_BACKLIGHT_TYPE          (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC)
  468.  
  469. #if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO) || \
  470.     (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_SWITCH_EXPANDER) || \
  471.     (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC)
  472.  
  473.     /**
  474.      * @brief Backlight control pin configuration
  475.      */
  476.     #define ESP_PANEL_BOARD_BACKLIGHT_IO        (38)    // Output GPIO pin number
  477.     #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL  (1)     // Active level, 0: low, 1: high
  478.  
  479. #if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC
  480.     /**
  481.      * @brief PWM parameters configuration
  482.      */
  483.     #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ   (5000)  // LEDC timer frequency.
  484.                                                             // Different backlight driver chips may have different
  485.                                                             // frequency limits, please refer to the datasheet of
  486.                                                             // the specific chip.
  487.                                                             // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188
  488.  
  489.     #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION  (10) // LEDC timer duty resolution.
  490.                                                                 // The frequency and duty resolution of the LEDC timer
  491.                                                                 // need to be properly matched, please refer to:
  492.                                                                 // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions
  493. #endif
  494.  
  495. #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM
  496.  
  497.     /**
  498.      * @brief Custom backlight control function
  499.      *
  500.      * @param[in] percent    Brightness percentage (0-100)
  501.      * @param[in] user_data  User data pointer, typically points to Board instance.
  502.      *
  503.      * @return true on success, false on failure
  504.      */
  505.     #define ESP_PANEL_BOARD_BACKLIGHT_CUSTOM_FUNCTION(percent, user_data)  \
  506.         {  \
  507.             auto board = static_cast<Board *>(user_data);  \
  508.             return true; \
  509.         }
  510.  
  511. #endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE
  512.  
  513. /**
  514.  * @brief Backlight idle state configuration (0/1)
  515.  *
  516.  * Set to 1 if want to turn off the backlight after initializing. Otherwise, the backlight will be on.
  517.  */
  518. #define ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF      (0)
  519.  
  520. #endif // ESP_PANEL_BOARD_USE_BACKLIGHT
  521.  
  522. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  523. ///////////////////////////// Please update the following macros to configure the IO expander //////////////////////////
  524. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  525. /**
  526.  * @brief IO expander configuration flag (0/1)
  527.  *
  528.  * Set to `1` to enable IO expander support, `0` to disable
  529.  */
  530. #define ESP_PANEL_BOARD_USE_EXPANDER            (0)
  531.  
  532. #if ESP_PANEL_BOARD_USE_EXPANDER
  533. /**
  534.  * @brief IO expander chip selection
  535.  *
  536.  * Supported chips:
  537.  * - `CH422G`
  538.  * - `HT8574`
  539.  * - `TCA95XX_8BIT`
  540.  * - `TCA95XX_16BIT`
  541.  */
  542. #define ESP_PANEL_BOARD_EXPANDER_CHIP           TCA95XX_8BIT
  543.  
  544. /**
  545.  * @brief IO expander I2C bus parameters configuration
  546.  */
  547. /**
  548.  * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
  549.  *
  550.  * For drivers which created by this library, even if they use the same host, the host will be initialized only once.
  551.  * So it is not necessary to set the macro to `1`. For other devices, please set the macro to `1` ensure that the
  552.  * host is initialized only once.
  553.  */
  554. #define ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST     (0)     // 0/1
  555. /* For general */
  556. #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID        (0)     // Typically set to 0
  557. /* For host */
  558. #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST
  559. #define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ         (400 * 1000)
  560.                                                             // Typically set to 400K
  561. #define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP     (1)     // 0/1. Typically set to 1
  562. #define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP     (1)     // 0/1. Typically set to 1
  563. #define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL         (18)
  564. #define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA         (8)
  565. #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST
  566. /* For device */
  567. #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS        (0x20)  // The actual I2C address. Even for the same model of IC,
  568.                                                             // the I2C address may be different, and confirmation based on
  569.                                                             // the actual hardware connection is required
  570. #endif // ESP_PANEL_BOARD_USE_EXPANDER
  571.  
  572. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  573. /////////////////////// Please utilize the following macros to execute any additional code if required /////////////////
  574. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  575. /**
  576.  * @brief Pre-begin function for board initialization
  577.  *
  578.  * @param[in] p Pointer to the board object
  579.  * @return true on success, false on failure
  580.  */
  581. /*
  582. #define ESP_PANEL_BOARD_PRE_BEGIN_FUNCTION(p) \
  583.     {  \
  584.         auto board = static_cast<Board *>(p);  \
  585.         return true;    \
  586.     }
  587. */
  588.  
  589. /**
  590.  * @brief Post-begin function for board initialization
  591.  *
  592.  * @param[in] p Pointer to the board object
  593.  * @return true on success, false on failure
  594.  */
  595. /*
  596. #define ESP_PANEL_BOARD_POST_BEGIN_FUNCTION(p) \
  597.     {  \
  598.         auto board = static_cast<Board *>(p);  \
  599.         return true;    \
  600.     }
  601. */
  602.  
  603. /**
  604.  * @brief Pre-delete function for board initialization
  605.  *
  606.  * @param[in] p Pointer to the board object
  607.  * @return true on success, false on failure
  608.  */
  609. /*
  610. #define ESP_PANEL_BOARD_PRE_DEL_FUNCTION(p) \
  611.     {  \
  612.         auto board = static_cast<Board *>(p);  \
  613.         return true;    \
  614.     }
  615. */
  616.  
  617. /**
  618.  * @brief Post-delete function for board initialization
  619.  *
  620.  * @param[in] p Pointer to the board object
  621.  * @return true on success, false on failure
  622.  */
  623. /*
  624. #define ESP_PANEL_BOARD_POST_DEL_FUNCTION(p) \
  625.     {  \
  626.         auto board = static_cast<Board *>(p);  \
  627.         return true;    \
  628.     }
  629. */
  630.  
  631. /**
  632.  * @brief Pre-begin function for IO expander initialization
  633.  *
  634.  * @param[in] p Pointer to the board object
  635.  * @return true on success, false on failure
  636.  */
  637. /*
  638. #define ESP_PANEL_BOARD_EXPANDER_PRE_BEGIN_FUNCTION(p) \
  639.     {  \
  640.         auto board = static_cast<Board *>(p);  \
  641.         return true;    \
  642.     }
  643. */
  644.  
  645. /**
  646.  * @brief Post-begin function for IO expander initialization
  647.  *
  648.  * @param[in] p Pointer to the board object
  649.  * @return true on success, false on failure
  650.  */
  651. /*
  652. #define ESP_PANEL_BOARD_EXPANDER_POST_BEGIN_FUNCTION(p) \
  653.     {  \
  654.         auto board = static_cast<Board *>(p);  \
  655.         return true;    \
  656.     }
  657. */
  658.  
  659. /**
  660.  * @brief Pre-begin function for LCD initialization
  661.  *
  662.  * @param[in] p Pointer to the board object
  663.  * @return true on success, false on failure
  664.  */
  665. /*
  666. #define ESP_PANEL_BOARD_LCD_PRE_BEGIN_FUNCTION(p) \
  667.     {  \
  668.         auto board = static_cast<Board *>(p);  \
  669.         return true;    \
  670.     }
  671. */
  672.  
  673. /**
  674.  * @brief Post-begin function for LCD initialization
  675.  *
  676.  * @param[in] p Pointer to the board object
  677.  * @return true on success, false on failure
  678.  */
  679. /*
  680. #define ESP_PANEL_BOARD_LCD_POST_BEGIN_FUNCTION(p) \
  681.     {  \
  682.         auto board = static_cast<Board *>(p);  \
  683.         return true;    \
  684.     }
  685. */
  686.  
  687. /**
  688.  * @brief Pre-begin function for touch panel initialization
  689.  *
  690.  * @param[in] p Pointer to the board object
  691.  * @return true on success, false on failure
  692.  */
  693. /*
  694. #define ESP_PANEL_BOARD_TOUCH_PRE_BEGIN_FUNCTION(p) \
  695.     {  \
  696.         auto board = static_cast<Board *>(p);  \
  697.         return true;    \
  698.     }
  699. */
  700.  
  701. /**
  702.  * @brief Post-begin function for touch panel initialization
  703.  *
  704.  * @param[in] p Pointer to the board object
  705.  * @return true on success, false on failure
  706.  */
  707. /*
  708. #define ESP_PANEL_BOARD_TOUCH_POST_BEGIN_FUNCTION(p) \
  709.     {  \
  710.         auto board = static_cast<Board *>(p);  \
  711.         return true;    \
  712.     }
  713. */
  714.  
  715. /**
  716.  * @brief Pre-begin function for backlight initialization
  717.  *
  718.  * @param[in] p Pointer to the board object
  719.  * @return true on success, false on failure
  720.  */
  721. /*
  722. #define ESP_PANEL_BOARD_BACKLIGHT_PRE_BEGIN_FUNCTION(p) \
  723.     {  \
  724.         auto board = static_cast<Board *>(p);  \
  725.         return true;    \
  726.     }
  727. */
  728.  
  729. /**
  730.  * @brief Post-begin function for backlight initialization
  731.  *
  732.  * @param[in] p Pointer to the board object
  733.  * @return true on success, false on failure
  734.  */
  735. /*
  736. #define ESP_PANEL_BOARD_BACKLIGHT_POST_BEGIN_FUNCTION(p) \
  737.     {  \
  738.         auto board = static_cast<Board *>(p);  \
  739.         return true;    \
  740.     }
  741. */
  742.  
  743. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  744. /////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
  745. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  746. /**
  747.  * Do not change the following versions. These version numbers are used to check compatibility between this
  748.  * configuration file and the library. Rules for version numbers:
  749.  * 1. Major version mismatch: Configurations are incompatible, must use library version
  750.  * 2. Minor version mismatch: May be missing new configurations, recommended to update
  751.  * 3. Patch version mismatch: No impact on functionality
  752.  */
  753. #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1
  754. #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1
  755. #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0
  756.  
  757. #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM
  758.  
  759. // *INDENT-ON*
  760.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement