From 77dd050491167752c7f52c2997557dfa26a1f504 Mon Sep 17 00:00:00 2001 From: Y1hsiaochunnn Date: Mon, 11 Nov 2024 10:24:24 +0800 Subject: [PATCH 1/3] add LCD controller JD9365 --- src/ESP_Panel_Library.h | 1 + src/lcd/JD9365.cpp | 60 ++++ src/lcd/JD9365.h | 59 ++++ src/lcd/base/esp_lcd_jd9365.c | 616 ++++++++++++++++++++++++++++++++++ src/lcd/base/esp_lcd_jd9365.h | 96 ++++++ 5 files changed, 832 insertions(+) create mode 100644 src/lcd/JD9365.cpp create mode 100644 src/lcd/JD9365.h create mode 100644 src/lcd/base/esp_lcd_jd9365.c create mode 100644 src/lcd/base/esp_lcd_jd9365.h diff --git a/src/ESP_Panel_Library.h b/src/ESP_Panel_Library.h index 870a0620..bb63e6fd 100644 --- a/src/ESP_Panel_Library.h +++ b/src/ESP_Panel_Library.h @@ -26,6 +26,7 @@ /* LCD */ #include "lcd/ESP_PanelLcd.h" #include "lcd/EK79007.h" +#include "lcd/JD9365.h" #include "lcd/EK9716B.h" #include "lcd/GC9503.h" #include "lcd/GC9A01.h" diff --git a/src/lcd/JD9365.cpp b/src/lcd/JD9365.cpp new file mode 100644 index 00000000..51ee8a21 --- /dev/null +++ b/src/lcd/JD9365.cpp @@ -0,0 +1,60 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/soc_caps.h" + +#if SOC_MIPI_DSI_SUPPORTED +#include "ESP_PanelLog.h" +#include "JD9365.h" + +static const char *TAG = "JD9365_CPP"; + +ESP_PanelLcd_JD9365::ESP_PanelLcd_JD9365(ESP_PanelBus *bus, uint8_t color_bits, int rst_io): + ESP_PanelLcd(bus, color_bits, rst_io) +{ + disabled_functions.set_gap = 1; + disabled_functions.swap_xy = 1; +} + +ESP_PanelLcd_JD9365::ESP_PanelLcd_JD9365(ESP_PanelBus *bus, const esp_lcd_panel_dev_config_t &panel_config): + ESP_PanelLcd(bus, panel_config) +{ + disabled_functions.set_gap = 1; + disabled_functions.swap_xy = 1; +} + +ESP_PanelLcd_JD9365::~ESP_PanelLcd_JD9365() +{ + ESP_PANEL_ENABLE_TAG_DEBUG_LOG(); + + if (handle == NULL) { + goto end; + } + + if (!del()) { + ESP_LOGE(TAG, "Delete device failed"); + } + +end: + ESP_LOGD(TAG, "Destroyed"); +} + +bool ESP_PanelLcd_JD9365::init(void) +{ + ESP_PANEL_CHECK_NULL_RET(bus, false, "Invalid bus"); + + /* Load MIPI-DSI configurations from bus to vendor configurations */ + ESP_PANEL_CHECK_FALSE_RET(loadVendorConfigFromBus(), false, "Load vendor config from bus failed"); + + /* Create panel handle */ + ESP_PANEL_CHECK_ERR_RET( + esp_lcd_new_panel_jd9365(bus->getPanelIO_Handle(), &panel_config, &handle), false, "Create panel failed" + ); + + return true; +} + +#endif diff --git a/src/lcd/JD9365.h b/src/lcd/JD9365.h new file mode 100644 index 00000000..6294e511 --- /dev/null +++ b/src/lcd/JD9365.h @@ -0,0 +1,59 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "soc/soc_caps.h" + +#if SOC_MIPI_DSI_SUPPORTED +#include "ESP_PanelLcd.h" +#include "base/esp_lcd_vendor_types.h" +#include "base/esp_lcd_jd9365.h" + +/** + * @brief JD9365 LCD device object class + * + * @note This class is a derived class of `ESP_PanelLcd`, user can use it directly + */ +class ESP_PanelLcd_JD9365: public ESP_PanelLcd { +public: + /** + * @brief Construct a new LCD device in a simple way, the `init()` function should be called after this function + * + * @note This function uses some default values to config the LCD device, please use `config*()` functions to + * change them + * @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier + * for initialization sequence code, and use `configVendorCommands()` to configure + * + * @param bus Pointer of panel bus + * @param color_bits Bits per pixel (16/18/24) + * @param rst_io Reset pin, set to -1 if no use + */ + ESP_PanelLcd_JD9365(ESP_PanelBus *bus, uint8_t color_bits, int rst_io = -1); + + /** + * @brief Construct a new LCD in a complex way, the `init()` function should be called after this function + * + * @param bus Pointer of panel bus + * @param panel_config LCD device configuration + */ + ESP_PanelLcd_JD9365(ESP_PanelBus *bus, const esp_lcd_panel_dev_config_t &panel_config); + + /** + * @brief Destroy the LCD device + * + */ + ~ESP_PanelLcd_JD9365() override; + + /** + * @brief Initialize the LCD device, the `begin()` function should be called after this function + * + * @note This function typically calls `esp_lcd_new_panel_*()` to create the LCD panel handle + * + * @return true if success, otherwise false + */ + bool init(void) override; +}; +#endif diff --git a/src/lcd/base/esp_lcd_jd9365.c b/src/lcd/base/esp_lcd_jd9365.c new file mode 100644 index 00000000..4efb96b4 --- /dev/null +++ b/src/lcd/base/esp_lcd_jd9365.c @@ -0,0 +1,616 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/soc_caps.h" + +#if SOC_MIPI_DSI_SUPPORTED +#include "esp_check.h" +#include "esp_log.h" +#include "esp_lcd_panel_commands.h" +#include "esp_lcd_panel_interface.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_mipi_dsi.h" +#include "esp_lcd_panel_vendor.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "driver/gpio.h" +#include "esp_lcd_jd9365.h" + +#define JD9365_CMD_PAGE (0xE0) +#define JD9365_PAGE_USER (0x00) + +#define JD9365_CMD_DSI_INT0 (0x80) +#define JD9365_DSI_1_LANE (0x00) +#define JD9365_DSI_2_LANE (0x01) +#define JD9365_DSI_3_LANE (0x10) +#define JD9365_DSI_4_LANE (0x11) + +#define JD9365_CMD_GS_BIT (1 << 0) +#define JD9365_CMD_SS_BIT (1 << 1) + +typedef struct +{ + esp_lcd_panel_io_handle_t io; + int reset_gpio_num; + uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register + uint8_t colmod_val; // save surrent value of LCD_CMD_COLMOD register + const esp_lcd_panel_vendor_init_cmd_t *init_cmds; + uint16_t init_cmds_size; + uint8_t lane_num; + struct + { + unsigned int reset_level : 1; + } flags; + // To save the original functions of MIPI DPI panel + esp_err_t (*del)(esp_lcd_panel_t *panel); + esp_err_t (*init)(esp_lcd_panel_t *panel); +} jd9365_panel_t; + +static const char *TAG = "jd9365"; + +static esp_err_t panel_jd9365_del(esp_lcd_panel_t *panel); +static esp_err_t panel_jd9365_init(esp_lcd_panel_t *panel); +static esp_err_t panel_jd9365_reset(esp_lcd_panel_t *panel); +static esp_err_t panel_jd9365_invert_color(esp_lcd_panel_t *panel, bool invert_color_data); +static esp_err_t panel_jd9365_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y); +static esp_err_t panel_jd9365_swap_xy(esp_lcd_panel_t *panel, bool swap_axes); +static esp_err_t panel_jd9365_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap); +static esp_err_t panel_jd9365_disp_on_off(esp_lcd_panel_t *panel, bool on_off); + +esp_err_t esp_lcd_new_panel_jd9365(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, + esp_lcd_panel_handle_t *ret_panel) +{ + ESP_LOGI(TAG, "version: %d.%d.%d", ESP_LCD_JD9365_VER_MAJOR, ESP_LCD_JD9365_VER_MINOR, + ESP_LCD_JD9365_VER_PATCH); + ESP_RETURN_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, TAG, "invalid arguments"); + jd9365_vendor_config_t *vendor_config = (jd9365_vendor_config_t *)panel_dev_config->vendor_config; + ESP_RETURN_ON_FALSE(vendor_config && vendor_config->mipi_config.dpi_config && vendor_config->mipi_config.dsi_bus, ESP_ERR_INVALID_ARG, TAG, + "invalid vendor config"); + + esp_err_t ret = ESP_OK; + jd9365_panel_t *jd9365 = (jd9365_panel_t *)calloc(1, sizeof(jd9365_panel_t)); + ESP_RETURN_ON_FALSE(jd9365, ESP_ERR_NO_MEM, TAG, "no mem for jd9365 panel"); + + if (panel_dev_config->reset_gpio_num >= 0) + { + gpio_config_t io_conf = { + .mode = GPIO_MODE_OUTPUT, + .pin_bit_mask = 1ULL << panel_dev_config->reset_gpio_num, + }; + ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for RST line failed"); + } + + switch (panel_dev_config->color_space) + { + case LCD_RGB_ELEMENT_ORDER_RGB: + jd9365->madctl_val = 0; + break; + case LCD_RGB_ELEMENT_ORDER_BGR: + jd9365->madctl_val |= LCD_CMD_BGR_BIT; + break; + default: + ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space"); + break; + } + + switch (panel_dev_config->bits_per_pixel) + { + case 16: // RGB565 + jd9365->colmod_val = 0x55; + break; + case 18: // RGB666 + jd9365->colmod_val = 0x66; + break; + case 24: // RGB888 + jd9365->colmod_val = 0x77; + break; + default: + ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width"); + break; + } + + uint8_t ID[3]; + ESP_GOTO_ON_ERROR(esp_lcd_panel_io_rx_param(io, 0x04, ID, 3), err, TAG, "read ID failed"); + ESP_LOGI(TAG, "LCD ID: %02X %02X %02X", ID[0], ID[1], ID[2]); + + jd9365->io = io; + jd9365->init_cmds = vendor_config->init_cmds; + jd9365->init_cmds_size = vendor_config->init_cmds_size; + jd9365->lane_num = vendor_config->mipi_config.lane_num; + jd9365->reset_gpio_num = panel_dev_config->reset_gpio_num; + jd9365->flags.reset_level = panel_dev_config->flags.reset_active_high; + + // Create MIPI DPI panel + esp_lcd_panel_handle_t panel_handle = NULL; + ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(vendor_config->mipi_config.dsi_bus, vendor_config->mipi_config.dpi_config, &panel_handle), err, TAG, + "create MIPI DPI panel failed"); + ESP_LOGD(TAG, "new MIPI DPI panel @%p", panel_handle); + + // Save the original functions of MIPI DPI panel + jd9365->del = panel_handle->del; + jd9365->init = panel_handle->init; + // Overwrite the functions of MIPI DPI panel + panel_handle->del = panel_jd9365_del; + panel_handle->init = panel_jd9365_init; + panel_handle->reset = panel_jd9365_reset; + panel_handle->mirror = panel_jd9365_mirror; + panel_handle->swap_xy = panel_jd9365_swap_xy; + panel_handle->set_gap = panel_jd9365_set_gap; + panel_handle->invert_color = panel_jd9365_invert_color; + panel_handle->disp_on_off = panel_jd9365_disp_on_off; + panel_handle->user_data = jd9365; + *ret_panel = panel_handle; + ESP_LOGD(TAG, "new jd9365 panel @%p", jd9365); + + return ESP_OK; + +err: + if (jd9365) + { + if (panel_dev_config->reset_gpio_num >= 0) + { + gpio_reset_pin(panel_dev_config->reset_gpio_num); + } + free(jd9365); + } + return ret; +} + +static const esp_lcd_panel_vendor_init_cmd_t vendor_specific_init_default[] = { + // {cmd, { data }, data_size, delay_ms} + // {0xE0, (uint8_t[]){0x00}, 1, 0}, + {0xE0, (uint8_t[]){0x00}, 1, 0}, + {0xE1, (uint8_t[]){0x93}, 1, 0}, + {0xE2, (uint8_t[]){0x65}, 1, 0}, + {0xE3, (uint8_t[]){0xF8}, 1, 0}, + {0x80, (uint8_t[]){0x01}, 1, 0}, + + {0xE0, (uint8_t[]){0x01}, 1, 0}, + {0x00, (uint8_t[]){0x00}, 1, 0}, + {0x01, (uint8_t[]){0x38}, 1, 0}, + {0x03, (uint8_t[]){0x10}, 1, 0}, + {0x04, (uint8_t[]){0x38}, 1, 0}, + + {0x0C, (uint8_t[]){0x74}, 1, 0}, + + {0x17, (uint8_t[]){0x00}, 1, 0}, + {0x18, (uint8_t[]){0xAF}, 1, 0}, + {0x19, (uint8_t[]){0x00}, 1, 0}, + {0x1A, (uint8_t[]){0x00}, 1, 0}, + {0x1B, (uint8_t[]){0xAF}, 1, 0}, + {0x1C, (uint8_t[]){0x00}, 1, 0}, + + {0x35, (uint8_t[]){0x26}, 1, 0}, + + {0x37, (uint8_t[]){0x09}, 1, 0}, + + {0x38, (uint8_t[]){0x04}, 1, 0}, + {0x39, (uint8_t[]){0x00}, 1, 0}, + {0x3A, (uint8_t[]){0x01}, 1, 0}, + {0x3C, (uint8_t[]){0x78}, 1, 0}, + {0x3D, (uint8_t[]){0xFF}, 1, 0}, + {0x3E, (uint8_t[]){0xFF}, 1, 0}, + {0x3F, (uint8_t[]){0x7F}, 1, 0}, + + {0x40, (uint8_t[]){0x06}, 1, 0}, + {0x41, (uint8_t[]){0xA0}, 1, 0}, + {0x42, (uint8_t[]){0x81}, 1, 0}, + {0x43, (uint8_t[]){0x1E}, 1, 0}, + {0x44, (uint8_t[]){0x0D}, 1, 0}, + {0x45, (uint8_t[]){0x28}, 1, 0}, + //{0x4A, (uint8_t[]){0x35}, 1, 0},//bist + + {0x55, (uint8_t[]){0x02}, 1, 0}, + {0x57, (uint8_t[]){0x69}, 1, 0}, + {0x59, (uint8_t[]){0x0A}, 1, 0}, + {0x5A, (uint8_t[]){0x2A}, 1, 0}, + {0x5B, (uint8_t[]){0x17}, 1, 0}, + + {0x5D, (uint8_t[]){0x7F}, 1, 0}, + {0x5E, (uint8_t[]){0x6A}, 1, 0}, + {0x5F, (uint8_t[]){0x5B}, 1, 0}, + {0x60, (uint8_t[]){0x4F}, 1, 0}, + {0x61, (uint8_t[]){0x4A}, 1, 0}, + {0x62, (uint8_t[]){0x3D}, 1, 0}, + {0x63, (uint8_t[]){0x41}, 1, 0}, + {0x64, (uint8_t[]){0x2A}, 1, 0}, + {0x65, (uint8_t[]){0x44}, 1, 0}, + {0x66, (uint8_t[]){0x43}, 1, 0}, + {0x67, (uint8_t[]){0x44}, 1, 0}, + {0x68, (uint8_t[]){0x62}, 1, 0}, + {0x69, (uint8_t[]){0x52}, 1, 0}, + {0x6A, (uint8_t[]){0x59}, 1, 0}, + {0x6B, (uint8_t[]){0x4C}, 1, 0}, + {0x6C, (uint8_t[]){0x48}, 1, 0}, + {0x6D, (uint8_t[]){0x3A}, 1, 0}, + {0x6E, (uint8_t[]){0x26}, 1, 0}, + {0x6F, (uint8_t[]){0x00}, 1, 0}, + {0x70, (uint8_t[]){0x7F}, 1, 0}, + {0x71, (uint8_t[]){0x6A}, 1, 0}, + {0x72, (uint8_t[]){0x5B}, 1, 0}, + {0x73, (uint8_t[]){0x4F}, 1, 0}, + {0x74, (uint8_t[]){0x4A}, 1, 0}, + {0x75, (uint8_t[]){0x3D}, 1, 0}, + {0x76, (uint8_t[]){0x41}, 1, 0}, + {0x77, (uint8_t[]){0x2A}, 1, 0}, + {0x78, (uint8_t[]){0x44}, 1, 0}, + {0x79, (uint8_t[]){0x43}, 1, 0}, + {0x7A, (uint8_t[]){0x44}, 1, 0}, + {0x7B, (uint8_t[]){0x62}, 1, 0}, + {0x7C, (uint8_t[]){0x52}, 1, 0}, + {0x7D, (uint8_t[]){0x59}, 1, 0}, + {0x7E, (uint8_t[]){0x4C}, 1, 0}, + {0x7F, (uint8_t[]){0x48}, 1, 0}, + {0x80, (uint8_t[]){0x3A}, 1, 0}, + {0x81, (uint8_t[]){0x26}, 1, 0}, + {0x82, (uint8_t[]){0x00}, 1, 0}, + + {0xE0, (uint8_t[]){0x02}, 1, 0}, + {0x00, (uint8_t[]){0x42}, 1, 0}, + {0x01, (uint8_t[]){0x42}, 1, 0}, + {0x02, (uint8_t[]){0x40}, 1, 0}, + {0x03, (uint8_t[]){0x40}, 1, 0}, + {0x04, (uint8_t[]){0x5E}, 1, 0}, + {0x05, (uint8_t[]){0x5E}, 1, 0}, + {0x06, (uint8_t[]){0x5F}, 1, 0}, + {0x07, (uint8_t[]){0x5F}, 1, 0}, + {0x08, (uint8_t[]){0x5F}, 1, 0}, + {0x09, (uint8_t[]){0x57}, 1, 0}, + {0x0A, (uint8_t[]){0x57}, 1, 0}, + {0x0B, (uint8_t[]){0x77}, 1, 0}, + {0x0C, (uint8_t[]){0x77}, 1, 0}, + {0x0D, (uint8_t[]){0x47}, 1, 0}, + {0x0E, (uint8_t[]){0x47}, 1, 0}, + {0x0F, (uint8_t[]){0x45}, 1, 0}, + {0x10, (uint8_t[]){0x45}, 1, 0}, + {0x11, (uint8_t[]){0x4B}, 1, 0}, + {0x12, (uint8_t[]){0x4B}, 1, 0}, + {0x13, (uint8_t[]){0x49}, 1, 0}, + {0x14, (uint8_t[]){0x49}, 1, 0}, + {0x15, (uint8_t[]){0x5F}, 1, 0}, + + {0x16, (uint8_t[]){0x41}, 1, 0}, + {0x17, (uint8_t[]){0x41}, 1, 0}, + {0x18, (uint8_t[]){0x40}, 1, 0}, + {0x19, (uint8_t[]){0x40}, 1, 0}, + {0x1A, (uint8_t[]){0x5E}, 1, 0}, + {0x1B, (uint8_t[]){0x5E}, 1, 0}, + {0x1C, (uint8_t[]){0x5F}, 1, 0}, + {0x1D, (uint8_t[]){0x5F}, 1, 0}, + {0x1E, (uint8_t[]){0x5F}, 1, 0}, + {0x1F, (uint8_t[]){0x57}, 1, 0}, + {0x20, (uint8_t[]){0x57}, 1, 0}, + {0x21, (uint8_t[]){0x77}, 1, 0}, + {0x22, (uint8_t[]){0x77}, 1, 0}, + {0x23, (uint8_t[]){0x46}, 1, 0}, + {0x24, (uint8_t[]){0x46}, 1, 0}, + {0x25, (uint8_t[]){0x44}, 1, 0}, + {0x26, (uint8_t[]){0x44}, 1, 0}, + {0x27, (uint8_t[]){0x4A}, 1, 0}, + {0x28, (uint8_t[]){0x4A}, 1, 0}, + {0x29, (uint8_t[]){0x48}, 1, 0}, + {0x2A, (uint8_t[]){0x48}, 1, 0}, + {0x2B, (uint8_t[]){0x5F}, 1, 0}, + + {0x2C, (uint8_t[]){0x01}, 1, 0}, + {0x2D, (uint8_t[]){0x01}, 1, 0}, + {0x2E, (uint8_t[]){0x00}, 1, 0}, + {0x2F, (uint8_t[]){0x00}, 1, 0}, + {0x30, (uint8_t[]){0x1F}, 1, 0}, + {0x31, (uint8_t[]){0x1F}, 1, 0}, + {0x32, (uint8_t[]){0x1E}, 1, 0}, + {0x33, (uint8_t[]){0x1E}, 1, 0}, + {0x34, (uint8_t[]){0x1F}, 1, 0}, + {0x35, (uint8_t[]){0x17}, 1, 0}, + {0x36, (uint8_t[]){0x17}, 1, 0}, + {0x37, (uint8_t[]){0x37}, 1, 0}, + {0x38, (uint8_t[]){0x37}, 1, 0}, + {0x39, (uint8_t[]){0x08}, 1, 0}, + {0x3A, (uint8_t[]){0x08}, 1, 0}, + {0x3B, (uint8_t[]){0x0A}, 1, 0}, + {0x3C, (uint8_t[]){0x0A}, 1, 0}, + {0x3D, (uint8_t[]){0x04}, 1, 0}, + {0x3E, (uint8_t[]){0x04}, 1, 0}, + {0x3F, (uint8_t[]){0x06}, 1, 0}, + {0x40, (uint8_t[]){0x06}, 1, 0}, + {0x41, (uint8_t[]){0x1F}, 1, 0}, + + {0x42, (uint8_t[]){0x02}, 1, 0}, + {0x43, (uint8_t[]){0x02}, 1, 0}, + {0x44, (uint8_t[]){0x00}, 1, 0}, + {0x45, (uint8_t[]){0x00}, 1, 0}, + {0x46, (uint8_t[]){0x1F}, 1, 0}, + {0x47, (uint8_t[]){0x1F}, 1, 0}, + {0x48, (uint8_t[]){0x1E}, 1, 0}, + {0x49, (uint8_t[]){0x1E}, 1, 0}, + {0x4A, (uint8_t[]){0x1F}, 1, 0}, + {0x4B, (uint8_t[]){0x17}, 1, 0}, + {0x4C, (uint8_t[]){0x17}, 1, 0}, + {0x4D, (uint8_t[]){0x37}, 1, 0}, + {0x4E, (uint8_t[]){0x37}, 1, 0}, + {0x4F, (uint8_t[]){0x09}, 1, 0}, + {0x50, (uint8_t[]){0x09}, 1, 0}, + {0x51, (uint8_t[]){0x0B}, 1, 0}, + {0x52, (uint8_t[]){0x0B}, 1, 0}, + {0x53, (uint8_t[]){0x05}, 1, 0}, + {0x54, (uint8_t[]){0x05}, 1, 0}, + {0x55, (uint8_t[]){0x07}, 1, 0}, + {0x56, (uint8_t[]){0x07}, 1, 0}, + {0x57, (uint8_t[]){0x1F}, 1, 0}, + + {0x58, (uint8_t[]){0x40}, 1, 0}, + {0x5B, (uint8_t[]){0x30}, 1, 0}, + {0x5C, (uint8_t[]){0x00}, 1, 0}, + {0x5D, (uint8_t[]){0x34}, 1, 0}, + {0x5E, (uint8_t[]){0x05}, 1, 0}, + {0x5F, (uint8_t[]){0x02}, 1, 0}, + {0x63, (uint8_t[]){0x00}, 1, 0}, + {0x64, (uint8_t[]){0x6A}, 1, 0}, + {0x67, (uint8_t[]){0x73}, 1, 0}, + {0x68, (uint8_t[]){0x07}, 1, 0}, + {0x69, (uint8_t[]){0x08}, 1, 0}, + {0x6A, (uint8_t[]){0x6A}, 1, 0}, + {0x6B, (uint8_t[]){0x08}, 1, 0}, + + {0x6C, (uint8_t[]){0x00}, 1, 0}, + {0x6D, (uint8_t[]){0x00}, 1, 0}, + {0x6E, (uint8_t[]){0x00}, 1, 0}, + {0x6F, (uint8_t[]){0x88}, 1, 0}, + + {0x75, (uint8_t[]){0xFF}, 1, 0}, + {0x77, (uint8_t[]){0xDD}, 1, 0}, + {0x78, (uint8_t[]){0x2C}, 1, 0}, + {0x79, (uint8_t[]){0x15}, 1, 0}, + {0x7A, (uint8_t[]){0x17}, 1, 0}, + {0x7D, (uint8_t[]){0x14}, 1, 0}, + {0x7E, (uint8_t[]){0x82}, 1, 0}, + + {0xE0, (uint8_t[]){0x04}, 1, 0}, + {0x00, (uint8_t[]){0x0E}, 1, 0}, + {0x02, (uint8_t[]){0xB3}, 1, 0}, + {0x09, (uint8_t[]){0x61}, 1, 0}, + {0x0E, (uint8_t[]){0x48}, 1, 0}, + + {0x37, (uint8_t[]){0x58}, 1, 0}, // 全志 + {0x2B, (uint8_t[]){0x0F}, 1, 0}, // 全志 + + {0xE0, (uint8_t[]){0x00}, 1, 0}, + + {0xE6, (uint8_t[]){0x02}, 1, 0}, + {0xE7, (uint8_t[]){0x0C}, 1, 0}, + + {0x11, (uint8_t[]){0x00}, 1, 120}, + + {0x29, (uint8_t[]){0x00}, 1, 20}, +}; + +static esp_err_t panel_jd9365_del(esp_lcd_panel_t *panel) +{ + jd9365_panel_t *jd9365 = (jd9365_panel_t *)panel->user_data; + + if (jd9365->reset_gpio_num >= 0) + { + gpio_reset_pin(jd9365->reset_gpio_num); + } + // Delete MIPI DPI panel + jd9365->del(panel); + free(jd9365); + ESP_LOGD(TAG, "del jd9365 panel @%p", jd9365); + + return ESP_OK; +} + +static esp_err_t panel_jd9365_init(esp_lcd_panel_t *panel) +{ + jd9365_panel_t *jd9365 = (jd9365_panel_t *)panel->user_data; + esp_lcd_panel_io_handle_t io = jd9365->io; + const esp_lcd_panel_vendor_init_cmd_t *init_cmds = NULL; + uint16_t init_cmds_size = 0; + uint8_t lane_command = JD9365_DSI_2_LANE; + bool is_user_set = true; + bool is_cmd_overwritten = false; + + switch (jd9365->lane_num) + { + case 1: + lane_command = JD9365_DSI_1_LANE; + break; + case 2: + lane_command = JD9365_DSI_2_LANE; + break; + case 3: + lane_command = JD9365_DSI_3_LANE; + break; + case 4: + lane_command = JD9365_DSI_4_LANE; + break; + default: + ESP_LOGE(TAG, "Invalid lane number %d", jd9365->lane_num); + return ESP_ERR_INVALID_ARG; + } + + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, JD9365_CMD_PAGE, (uint8_t[]){JD9365_PAGE_USER}, 1), TAG, "send command failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]){ + jd9365->madctl_val, + }, + 1), + TAG, "send command failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD, (uint8_t[]){ + jd9365->colmod_val, + }, + 1), + TAG, "send command failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, JD9365_CMD_DSI_INT0, (uint8_t[]){ + lane_command, + }, + 1), + TAG, "send command failed"); + + // vendor specific initialization, it can be different between manufacturers + // should consult the LCD supplier for initialization sequence code + if (jd9365->init_cmds) + { + init_cmds = jd9365->init_cmds; + init_cmds_size = jd9365->init_cmds_size; + } + else + { + init_cmds = vendor_specific_init_default; + init_cmds_size = sizeof(vendor_specific_init_default) / sizeof(esp_lcd_panel_vendor_init_cmd_t); + } + + for (int i = 0; i < init_cmds_size; i++) + { + // Check if the command has been used or conflicts with the internal + if (is_user_set && (init_cmds[i].data_bytes > 0)) + { + switch (init_cmds[i].cmd) + { + case LCD_CMD_MADCTL: + is_cmd_overwritten = true; + jd9365->madctl_val = ((uint8_t *)init_cmds[i].data)[0]; + break; + case LCD_CMD_COLMOD: + is_cmd_overwritten = true; + jd9365->colmod_val = ((uint8_t *)init_cmds[i].data)[0]; + break; + default: + is_cmd_overwritten = false; + break; + } + + if (is_cmd_overwritten) + { + is_cmd_overwritten = false; + ESP_LOGW(TAG, "The %02Xh command has been used and will be overwritten by external initialization sequence", + init_cmds[i].cmd); + } + } + + // Send command + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, init_cmds[i].cmd, init_cmds[i].data, init_cmds[i].data_bytes), TAG, "send command failed"); + vTaskDelay(pdMS_TO_TICKS(init_cmds[i].delay_ms)); + + // Check if the current cmd is the "page set" cmd + if ((init_cmds[i].cmd == JD9365_CMD_PAGE) && (init_cmds[i].data_bytes > 0)) + { + is_user_set = (((uint8_t *)init_cmds[i].data)[0] == JD9365_PAGE_USER); + } + } + ESP_LOGD(TAG, "send init commands success"); + + ESP_RETURN_ON_ERROR(jd9365->init(panel), TAG, "init MIPI DPI panel failed"); + + return ESP_OK; +} + +static esp_err_t panel_jd9365_reset(esp_lcd_panel_t *panel) +{ + jd9365_panel_t *jd9365 = (jd9365_panel_t *)panel->user_data; + esp_lcd_panel_io_handle_t io = jd9365->io; + + // Perform hardware reset + if (jd9365->reset_gpio_num >= 0) + { + gpio_set_level(jd9365->reset_gpio_num, !jd9365->flags.reset_level); + vTaskDelay(pdMS_TO_TICKS(5)); + gpio_set_level(jd9365->reset_gpio_num, jd9365->flags.reset_level); + vTaskDelay(pdMS_TO_TICKS(10)); + gpio_set_level(jd9365->reset_gpio_num, !jd9365->flags.reset_level); + vTaskDelay(pdMS_TO_TICKS(120)); + } + else if (io) + { // Perform software reset + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0), TAG, "send command failed"); + vTaskDelay(pdMS_TO_TICKS(120)); + } + + return ESP_OK; +} + +static esp_err_t panel_jd9365_invert_color(esp_lcd_panel_t *panel, bool invert_color_data) +{ + jd9365_panel_t *jd9365 = (jd9365_panel_t *)panel->user_data; + esp_lcd_panel_io_handle_t io = jd9365->io; + uint8_t command = 0; + + ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_STATE, TAG, "invalid panel IO"); + + if (invert_color_data) + { + command = LCD_CMD_INVON; + } + else + { + command = LCD_CMD_INVOFF; + } + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed"); + + return ESP_OK; +} + +static esp_err_t panel_jd9365_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y) +{ + jd9365_panel_t *jd9365 = (jd9365_panel_t *)panel->user_data; + esp_lcd_panel_io_handle_t io = jd9365->io; + uint8_t madctl_val = jd9365->madctl_val; + + ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_STATE, TAG, "invalid panel IO"); + + // Control mirror through LCD command + if (mirror_x) + { + madctl_val |= JD9365_CMD_GS_BIT; + } + else + { + madctl_val &= ~JD9365_CMD_GS_BIT; + } + if (mirror_y) + { + madctl_val |= JD9365_CMD_SS_BIT; + } + else + { + madctl_val &= ~JD9365_CMD_SS_BIT; + } + + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]){madctl_val}, 1), TAG, "send command failed"); + jd9365->madctl_val = madctl_val; + + return ESP_OK; +} + +static esp_err_t panel_jd9365_swap_xy(esp_lcd_panel_t *panel, bool swap_axes) +{ + ESP_LOGW(TAG, "swap_xy is not supported by this panel"); + return ESP_ERR_NOT_SUPPORTED; +} + +static esp_err_t panel_jd9365_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap) +{ + ESP_LOGE(TAG, "set_gap is not supported by this panel"); + return ESP_ERR_NOT_SUPPORTED; +} + +static esp_err_t panel_jd9365_disp_on_off(esp_lcd_panel_t *panel, bool on_off) +{ + jd9365_panel_t *jd9365 = (jd9365_panel_t *)panel->user_data; + esp_lcd_panel_io_handle_t io = jd9365->io; + int command = 0; + + if (on_off) + { + command = LCD_CMD_DISPON; + } + else + { + command = LCD_CMD_DISPOFF; + } + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed"); + return ESP_OK; +} +#endif diff --git a/src/lcd/base/esp_lcd_jd9365.h b/src/lcd/base/esp_lcd_jd9365.h new file mode 100644 index 00000000..de10dfaf --- /dev/null +++ b/src/lcd/base/esp_lcd_jd9365.h @@ -0,0 +1,96 @@ + +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "soc/soc_caps.h" + +#if SOC_MIPI_DSI_SUPPORTED +#include +#include "esp_lcd_panel_vendor.h" +#include "esp_lcd_mipi_dsi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESP_LCD_EK79007_VER_MAJOR (1) +#define ESP_LCD_EK79007_VER_MINOR (0) +#define ESP_LCD_EK79007_VER_PATCH (0) + +/** + * @brief Create LCD panel for model JD9365 + * + * @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code. + * + * @param[in] io LCD panel IO handle + * @param[in] panel_dev_config General panel device configuration + * @param[out] ret_panel Returned LCD panel handle + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_OK on success + * - Otherwise on fail + */ +esp_err_t esp_lcd_new_panel_jd9365(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, + esp_lcd_panel_handle_t *ret_panel); + +/** + * @brief MIPI-DSI bus configuration structure + * + */ +#define JD9365_PANEL_BUS_DSI_2CH_CONFIG() \ + { \ + .bus_id = 0, \ + .num_data_lanes = 2, \ + .phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, \ + .lane_bit_rate_mbps = 1500, \ + } + +/** + * @brief MIPI-DBI panel IO configuration structure + * + */ +#define JD9365_PANEL_IO_DBI_CONFIG() \ + { \ + .virtual_channel = 0, \ + .lcd_cmd_bits = 8, \ + .lcd_param_bits = 8, \ + } + +/** + * @brief MIPI DPI configuration structure + * + * @note refresh_rate = (dpi_clock_freq_mhz * 1000000) / (h_res + hsync_pulse_width + hsync_back_porch + hsync_front_porch) + * / (v_res + vsync_pulse_width + vsync_back_porch + vsync_front_porch) + * + * @param[in] px_format Pixel format of the panel + * + */ +#define JD9365_800_1280_PANEL_60HZ_DPI_CONFIG(px_format) \ + { \ + .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, \ + .dpi_clock_freq_mhz = 80, \ + .virtual_channel = 0, \ + .pixel_format = px_format, \ + .num_fbs = 1, \ + .video_timing = { \ + .h_size = 800, \ + .v_size = 1280, \ + .hsync_back_porch = 20, \ + .hsync_pulse_width = 20, \ + .hsync_front_porch = 40, \ + .vsync_back_porch = 10, \ + .vsync_pulse_width = 4, \ + .vsync_front_porch = 30, \ + }, \ + .flags.use_dma2d = true, \ + } +#endif /* SOC_MIPI_DSI_SUPPORTED */ + +#ifdef __cplusplus +} +#endif From 504f6f39b5f4216051c8ab275ca51d37362cf438 Mon Sep 17 00:00:00 2001 From: Y1hsiaochunnn Date: Mon, 11 Nov 2024 10:58:28 +0800 Subject: [PATCH 2/3] add support for Waveshare ESP32-P4-NANO --- ESP_Panel_Board_Supported.h | 3 + README.md | 12 +- README_CN.md | 12 +- docs/Board_Instructions.md | 54 +++-- .../v8/Porting/ESP_Panel_Board_Supported.h | 3 + .../v8/Rotation/ESP_Panel_Board_Supported.h | 3 + .../PanelTest/ESP_Panel_Board_Supported.h | 3 + .../src/ESP_Panel_Board_Supported.h | 3 + .../v8/Porting/ESP_Panel_Board_Supported.h | 3 + .../v8/WiFiClock/ESP_Panel_Board_Supported.h | 3 + library.properties | 2 +- src/ESP_Panel_Board_Kconfig.h | 10 + src/board/ESP_PanelBoard.h | 1 + src/board/waveshare/ESP32_P4_NANO.h | 225 ++++++++++++++++++ src/board/waveshare/Kconfig.waveshare | 5 + .../sdkconfig.ci.waveshare_esp32_p4_nano | 15 ++ .../sdkconfig.ci.waveshare_esp32_p4_nano | 10 + 17 files changed, 328 insertions(+), 39 deletions(-) create mode 100644 src/board/waveshare/ESP32_P4_NANO.h create mode 100644 test_apps/lvgl_port/sdkconfig.ci.waveshare_esp32_p4_nano create mode 100644 test_apps/panel/sdkconfig.ci.waveshare_esp32_p4_nano diff --git a/ESP_Panel_Board_Supported.h b/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/ESP_Panel_Board_Supported.h +++ b/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/README.md b/README.md index 1f63c5e7..d2f83d8a 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,13 @@ Please refer to the documentation - [How to Use](./docs/How_To_Use.md). Below is the list of [supported development boards](docs/Board_Instructions.md): -| **Manufacturer** | **Board Model** | -| ---------------- | --------------- | +| **Manufacturer** | **Board Model** | +| ---------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Espressif](docs/Board_Instructions.md#espressif) | ESP32-C3-LCDkit, ESP32-S3-BOX, ESP32-S3-BOX-3, ESP32-S3-BOX-3B, ESP32-S3-BOX-3(beta), ESP32-S3-BOX-Lite, ESP32-S3-EYE, ESP32-S3-Korvo-2, ESP32-S3-LCD-EV-Board, ESP32-S3-LCD-EV-Board-2, ESP32-S3-USB-OTG, ESP32-P4-Function-EV-Board | -| [Elecrow](docs/Board_Instructions.md#elecrow) | CrowPanel 7.0" | -| [M5Stack](docs/Board_Instructions.md#m5stack) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | -| [Jingcai](docs/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | -| [Waveshare](docs/Board_Instructions.md#waveshare) | ESP32-S3-Touch-LCD-4.3, ESP32-S3-Touch-LCD-1.85, ESP32-S3-Touch-LCD-2.1 | +| [Elecrow](docs/Board_Instructions.md#elecrow) | CrowPanel 7.0" | +| [M5Stack](docs/Board_Instructions.md#m5stack) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | +| [Jingcai](docs/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | +| [Waveshare](docs/Board_Instructions.md#waveshare) | ESP32-S3-Touch-LCD-4.3, ESP32-S3-Touch-LCD-1.85, ESP32-S3-Touch-LCD-2.1, ESP32-P4-NANO | Developers and manufacturers are welcome to contribute PRs to add more boards. For details, please refer to the [Board Contribution Guide](./docs/Board_Contribution_Guide.md). diff --git a/README_CN.md b/README_CN.md index 682e99ce..607ebfba 100644 --- a/README_CN.md +++ b/README_CN.md @@ -34,13 +34,13 @@ ESP32_Display_Panel 的功能框图如下所示,主要包含以下特性: 下面是支持的[开发板列表](docs/Board_Instructions.md): -| **厂商** | **开发板型号** | -| -------- | -------------- | +| **厂商** | **开发板型号** | +| -------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Espressif](docs/Board_Instructions.md#espressif) | ESP32-C3-LCDkit, ESP32-S3-BOX, ESP32-S3-BOX-3, ESP32-S3-BOX-3B, ESP32-S3-BOX-3(beta), ESP32-S3-BOX-Lite, ESP32-S3-EYE, ESP32-S3-Korvo-2, ESP32-S3-LCD-EV-Board, ESP32-S3-LCD-EV-Board-2, ESP32-S3-USB-OTG, ESP32-P4-Function-EV-Board | -| [M5Stack](docs/Board_Instructions.md#m5stack) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | -| [Elecrow](docs/Board_Instructions.md#elecrow) | CrowPanel 7.0" | -| [Jingcai](docs/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | -| [Waveshare](docs/Board_Instructions.md#waveshare) | ESP32-S3-Touch-LCD-4.3, ESP32-S3-Touch-LCD-1.85, ESP32-S3-Touch-LCD-2.1 | +| [M5Stack](docs/Board_Instructions.md#m5stack) | M5STACK-M5CORE2, M5STACK-M5DIAL, M5STACK-M5CORES3 | +| [Elecrow](docs/Board_Instructions.md#elecrow) | CrowPanel 7.0" | +| [Jingcai](docs/Board_Instructions.md#shenzhen-jingcai-intelligent) | ESP32-4848S040C_I_Y_3 | +| [Waveshare](docs/Board_Instructions.md#waveshare) | ESP32-S3-Touch-LCD-4.3, ESP32-S3-Touch-LCD-1.85, ESP32-S3-Touch-LCD-2.1, ESP32-P4-NANO | 欢迎开发者和厂商贡献 PR 来添加更多的开发板,详细说明请参考 [`开发板贡献指南`](./docs/Board_Contribution_Guide_CN.md)。 diff --git a/docs/Board_Instructions.md b/docs/Board_Instructions.md index 7650cb87..35e65ef1 100644 --- a/docs/Board_Instructions.md +++ b/docs/Board_Instructions.md @@ -41,37 +41,39 @@ ## [Waveshare](https://www.waveshare.com/) -| **Picture** | **Name** | **LCD Bus** | **LCD Controller** | **LCD resolution** | **Touch Bus** | **Touch Controller** | -| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: | :--------------: | :----------------: | ------------------ | :-----------: | :------------------: | -| | [ESP32-S3-Touch-LCD-4.3](https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm) | RGB | ST7262 | 800x480 | I2C | GT911 | -| | [ESP32-S3-Touch-LCD-1.85](https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm) | QSPI | ST77916 | 360x360 | I2C | CST816 | -| | [ESP32-S3-Touch-LCD-1.85](https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm) | RGB | ST7701 | 480x480 | I2C | CST820 (CST816-like) | +| **Picture** | **Name** | **LCD Bus** | **LCD Controller** | **LCD resolution** | **Touch Bus** | **Touch Controller** | +|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------:|:-----------:|:------------------:|--------------------|:-------------:|:--------------------:| +| | [ESP32-S3-Touch-LCD-4.3](https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm) | RGB | ST7262 | 800x480 | I2C | GT911 | +| | [ESP32-S3-Touch-LCD-1.85](https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm) | QSPI | ST77916 | 360x360 | I2C | CST816 | +| | [ESP32-S3-Touch-LCD-1.85](https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm) | RGB | ST7701 | 480x480 | I2C | CST820 (CST816-like) | +| | [ESP32-P4-NANO](https://www.waveshare.com/esp32-p4-nano.htm) | MIPI-DSI | JD9365 | 800x1280 | I2C | GT9271 | ## Recommended Configurations in the Arduino IDE Below are recommended configurations for developing GUI applications on different development boards. These settings can be adjusted according to specific requirements, and users can navigate to the `Tools` menu in the Arduino IDE to configure the following settings. -| Supported Boards | Selected Board | PSRAM | Flash Mode | Flash Size | USB CDC On Boot | Partition Scheme | -| :------------------------------: | :----------------: | :------: | :--------: | :--------: | :-------------: | :---------------------: | -| ESP32-C3-LCDkit | ESP32C3 Dev Module | Disabled | QIO | 4MB (32Mb) | Enabled | Default 4MB with spiffs | -| ESP32-S3-BOX | ESP32-S3-BOX | - | - | - | - | 16M Flash (3MB) | -| ESP32-S3-BOX-3 & ESP32-S3-BOX-3B | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | -| ESP32-S3-BOX-3(beta) | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | -| ESP32-S3-BOX-Lite | ESP32-S3-BOX | - | - | - | - | 16M Flash (3MB) | -| ESP32-S3-EYE | ESP32S3 Dev Module | OPI | QIO 80MHz | 8MB | Enabled | 8M with spiffs | -| ESP32-S3-Korvo-2 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Disabled | 16M Flash (3MB) | -| ESP32-S3-LCD-EV-Board | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | **See Note 1** | 16M Flash (3MB) | -| ESP32-S3-LCD-EV-Board-2 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | **See Note 1** | 16M Flash (3MB) | -| ESP32-S3-USB-OTG | ESP32-S3-USB-OTG | - | - | - | - | 8M with spiffs | -| ESP32-P4-Function-EV-Board | ESP32P4 Dev Module | Enabled | QIO | 16MB | Disabled | 16M Flash (3MB) | -| M5STACK-M5CORE2 | M5Stack-Core2 | Enabled | - | - | - | Default | -| M5STACK-M5DIAL | ESP32S3 Dev Module | OPI | QIO 80MHz | 8MB | Disabled | Default | -| M5STACK-M5CORES3 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | Default 4MB with spiffs | -| ESP32-4848S040C_I_Y_3 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Disabled | 16M Flash (3MB) | -| ElecrowCrowPanel 7.0" | ESP32S3 Dev Module | OPI | QIO 80MHz | 4MB | Disabled | Huge App (3MB) | -| Waveshare-ESP32-S3-Touch-LCD-4.3 | ESP32S3 Dev Module | OPI | QIO 80MHz | 8MB | Disabled | 8M with spiffs | -| Waveshare-ESP32-S3-Touch-LCD-1.85 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | -| Waveshare-ESP32-S3-Touch-LCD-2.1 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | +| Supported Boards | Selected Board | PSRAM | Flash Mode | Flash Size | USB CDC On Boot | Partition Scheme | +|:---------------------------------:|:------------------:|:--------:|:----------:|:----------:|:---------------:|:-----------------------:| +| ESP32-C3-LCDkit | ESP32C3 Dev Module | Disabled | QIO | 4MB (32Mb) | Enabled | Default 4MB with spiffs | +| ESP32-S3-BOX | ESP32-S3-BOX | - | - | - | - | 16M Flash (3MB) | +| ESP32-S3-BOX-3 & ESP32-S3-BOX-3B | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | +| ESP32-S3-BOX-3(beta) | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | +| ESP32-S3-BOX-Lite | ESP32-S3-BOX | - | - | - | - | 16M Flash (3MB) | +| ESP32-S3-EYE | ESP32S3 Dev Module | OPI | QIO 80MHz | 8MB | Enabled | 8M with spiffs | +| ESP32-S3-Korvo-2 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Disabled | 16M Flash (3MB) | +| ESP32-S3-LCD-EV-Board | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | **See Note 1** | 16M Flash (3MB) | +| ESP32-S3-LCD-EV-Board-2 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | **See Note 1** | 16M Flash (3MB) | +| ESP32-S3-USB-OTG | ESP32-S3-USB-OTG | - | - | - | - | 8M with spiffs | +| ESP32-P4-Function-EV-Board | ESP32P4 Dev Module | Enabled | QIO | 16MB | Disabled | 16M Flash (3MB) | +| M5STACK-M5CORE2 | M5Stack-Core2 | Enabled | - | - | - | Default | +| M5STACK-M5DIAL | ESP32S3 Dev Module | OPI | QIO 80MHz | 8MB | Disabled | Default | +| M5STACK-M5CORES3 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | Default 4MB with spiffs | +| ESP32-4848S040C_I_Y_3 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Disabled | 16M Flash (3MB) | +| ElecrowCrowPanel 7.0" | ESP32S3 Dev Module | OPI | QIO 80MHz | 4MB | Disabled | Huge App (3MB) | +| Waveshare-ESP32-S3-Touch-LCD-4.3 | ESP32S3 Dev Module | OPI | QIO 80MHz | 8MB | Disabled | 8M with spiffs | +| Waveshare-ESP32-S3-Touch-LCD-1.85 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | +| Waveshare-ESP32-S3-Touch-LCD-2.1 | ESP32S3 Dev Module | OPI | QIO 80MHz | 16MB | Enabled | 16M Flash (3MB) | +| Waveshare-ESP32-P4-NANO | ESP32P4 Dev Module | Enabled | QIO | 16MB | Disabled | 16M Flash (3MB) | **Notes:** diff --git a/examples/LVGL/v8/Porting/ESP_Panel_Board_Supported.h b/examples/LVGL/v8/Porting/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/examples/LVGL/v8/Porting/ESP_Panel_Board_Supported.h +++ b/examples/LVGL/v8/Porting/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/examples/LVGL/v8/Rotation/ESP_Panel_Board_Supported.h b/examples/LVGL/v8/Rotation/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/examples/LVGL/v8/Rotation/ESP_Panel_Board_Supported.h +++ b/examples/LVGL/v8/Rotation/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/examples/Panel/PanelTest/ESP_Panel_Board_Supported.h b/examples/Panel/PanelTest/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/examples/Panel/PanelTest/ESP_Panel_Board_Supported.h +++ b/examples/Panel/PanelTest/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/examples/PlatformIO/src/ESP_Panel_Board_Supported.h b/examples/PlatformIO/src/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/examples/PlatformIO/src/ESP_Panel_Board_Supported.h +++ b/examples/PlatformIO/src/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/examples/SquareLine/v8/Porting/ESP_Panel_Board_Supported.h b/examples/SquareLine/v8/Porting/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/examples/SquareLine/v8/Porting/ESP_Panel_Board_Supported.h +++ b/examples/SquareLine/v8/Porting/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Supported.h b/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Supported.h index 75d5c84a..fc018f4b 100644 --- a/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Supported.h +++ b/examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Supported.h @@ -82,11 +82,14 @@ * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 (ESP32_S3_Touch_LCD_4_3): https://www.waveshare.com/esp32-s3-touch-lcd-4.3.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 (ESP32_S3_Touch_LCD_1_85): https://www.waveshare.com/esp32-s3-touch-lcd-1.85.htm * - BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 (ESP32_S3_Touch_LCD_2_1): https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + * - BOARD_WAVESHARE_ESP32_P4_NANO (ESP32_P4_NANO): https://www.waveshare.com/esp32-p4-nano.htm * */ // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85 // #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 +// #define BOARD_WAVESHARE_ESP32_P4_NANO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// diff --git a/library.properties b/library.properties index c3cf1a04..69e15cdd 100644 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=0.2.0 author=espressif maintainer=espressif sentence=ESP32_Display_Panel is a library designed for ESP SoCs to drive display panels and facilitate rapid GUI development. -paragraph=Currently supported boards:ESP32-C3-LCDkit,ESP32-S3-BOX,ESP32-S3-BOX-3,ESP32-S3-BOX-3B,ESP32-S3-BOX-3(beta),ESP32-S3-BOX-Lite,ESP32-S3-EYE,ESP32-S3-Korvo-2,ESP32-S3-LCD-EV-Board,ESP32-S3-LCD-EV-Board-2,ESP32-S3-USB-OTG,ESP32-P4-Function-EV-Board,M5STACK-M5CORE2,M5STACK-M5DIAL,M5STACK-M5CORES3,ESP32-4848S040C_I_Y_3,ESP32-S3-Touch-LCD-4.3,ESP32-S3-Touch-LCD-1.85,ESP32-S3-Touch-LCD-2.1. Currently supported devices: Bus,LCD,Touch,Backlight,IO expander. Currently supported Bus: I2C,SPI,QSPI,3-wire SPI + RGB,MIPI-DSI. Currently supported LCD controllers: EK9716B,EK79007,GC9A01,GC9B71,GC9503,ILI9341,ILI9881C,NV3022B,ST7262,ST7701,ST7789,ST7796,ST77916,ST77922. Currently supported Touch controllers: CST816S,FT5x06,GT1151,GT911,ST7123,TT21100,XPT2046. +paragraph=Currently supported boards:ESP32-C3-LCDkit,ESP32-S3-BOX,ESP32-S3-BOX-3,ESP32-S3-BOX-3B,ESP32-S3-BOX-3(beta),ESP32-S3-BOX-Lite,ESP32-S3-EYE,ESP32-S3-Korvo-2,ESP32-S3-LCD-EV-Board,ESP32-S3-LCD-EV-Board-2,ESP32-S3-USB-OTG,ESP32-P4-Function-EV-Board,M5STACK-M5CORE2,M5STACK-M5DIAL,M5STACK-M5CORES3,ESP32-4848S040C_I_Y_3,ESP32-S3-Touch-LCD-4.3,ESP32-S3-Touch-LCD-1.85,ESP32-S3-Touch-LCD-2.1,ESP32-P4-NANO. Currently supported devices: Bus,LCD,Touch,Backlight,IO expander. Currently supported Bus: I2C,SPI,QSPI,3-wire SPI + RGB,MIPI-DSI. Currently supported LCD controllers: EK9716B,EK79007,GC9A01,GC9B71,GC9503,ILI9341,ILI9881C,NV3022B,ST7262,ST7701,ST7789,ST7796,ST77916,ST77922. Currently supported Touch controllers: CST816S,FT5x06,GT1151,GT911,ST7123,TT21100,XPT2046. category=Other architectures=esp32 url=https://github.com/esp-arduino-libs/ESP32_Display_Panel diff --git a/src/ESP_Panel_Board_Kconfig.h b/src/ESP_Panel_Board_Kconfig.h index ebe9fb6e..c7b66f12 100644 --- a/src/ESP_Panel_Board_Kconfig.h +++ b/src/ESP_Panel_Board_Kconfig.h @@ -145,6 +145,16 @@ #define BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 CONFIG_BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 #endif #endif + #ifndef BOARD_WAVESHARE_ESP32_P4_NANO + #ifdef CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO + #define BOARD_WAVESHARE_ESP32_P4_NANO CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO + #endif + #endif + #ifndef BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 + #ifdef CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 + #define BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 + #endif + #endif #endif /* ESP_PANEL_USE_SUPPORTED_BOARD */ /** diff --git a/src/board/ESP_PanelBoard.h b/src/board/ESP_PanelBoard.h index 50816c8e..e6e68179 100644 --- a/src/board/ESP_PanelBoard.h +++ b/src/board/ESP_PanelBoard.h @@ -36,6 +36,7 @@ + defined(BOARD_WAVESHARE_ESP32_S3_Touch_LCD_4_3) \ + defined(BOARD_WAVESHARE_ESP32_S3_Touch_LCD_1_85) \ + defined(BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1) \ + + defined(BOARD_WAVESHARE_ESP32_P4_NANO) > 1 #error "Multiple boards enabled! Please check file `ESP_Panel_Board_Supported.h` and make sure only one board is enabled." #endif diff --git a/src/board/waveshare/ESP32_P4_NANO.h b/src/board/waveshare/ESP32_P4_NANO.h new file mode 100644 index 00000000..29fed94c --- /dev/null +++ b/src/board/waveshare/ESP32_P4_NANO.h @@ -0,0 +1,225 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +// *INDENT-OFF* + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the LCD panel ///////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/* Set to 1 when using an LCD panel */ +#define ESP_PANEL_USE_LCD (1) // 0/1 + +#if ESP_PANEL_USE_LCD +/** + * LCD Controller Name. + */ +#define ESP_PANEL_LCD_NAME JD9365 + +/* LCD resolution in pixels */ +#define ESP_PANEL_LCD_WIDTH (800) +#define ESP_PANEL_LCD_HEIGHT (1280) + +/* LCD Bus Settings */ +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * It is useful if other devices use the same host. Please ensure that the host is initialized only once. + * + * Note: This macro is not useful for the MIPI-DSI bus. + * + */ +#define ESP_PANEL_LCD_BUS_SKIP_INIT_HOST (0) // 0/1 +/** + * LCD Bus Type. + */ +#define ESP_PANEL_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_MIPI_DSI) +/** + * LCD Bus Parameters. + * + * Please refer to https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/lcd.html and + * https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html for more details. + * + */ +#if ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_MIPI_DSI + + #define ESP_PANEL_LCD_MIPI_DSI_LANE_NUM (2) // ESP32-P4 supports 1 or 2 lanes + #define ESP_PANEL_LCD_MIPI_DSI_LANE_RATE_MBPS (1500) // Single lane bit rate, should consult the LCD supplier or check the + // LCD drive IC datasheet for the supported lane rate. + // ESP32-P4 supports max 1500Mbps + #define ESP_PANEL_LCD_MIPI_DSI_PHY_LDO_ID (3) // -1 if not used + #define ESP_PANEL_LCD_MIPI_DPI_CLK_MHZ (80) + #define ESP_PANEL_LCD_MIPI_DPI_PIXEL_BITS (ESP_PANEL_LCD_RGB565_COLOR_BITS_16) + #define ESP_PANEL_LCD_MIPI_DSI_HPW (20) + #define ESP_PANEL_LCD_MIPI_DSI_HBP (20) + #define ESP_PANEL_LCD_MIPI_DSI_HFP (40) + #define ESP_PANEL_LCD_MIPI_DSI_VPW (4) + #define ESP_PANEL_LCD_MIPI_DSI_VBP (10) + #define ESP_PANEL_LCD_MIPI_DSI_VFP (30) + +#endif /* ESP_PANEL_LCD_BUS_TYPE */ + +/** + * 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. + * + * There are two formats for the sequence code: + * 1. Raw data: {command, (uint8_t []){ data0, data1, ... }, data_size, delay_ms} + * 2. Formatter: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and + * ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command) + */ +/* +#define ESP_PANEL_LCD_VENDOR_INIT_CMD() \ + { \ + {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0}, \ + {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0}, \ + {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0}, \ + {0x29, (uint8_t []){0x00}, 0, 120}, \ + or \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}), \ + ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}), \ + ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29), \ + } +*/ + +/* LCD Color Settings */ +/* LCD color depth in bits */ +#define ESP_PANEL_LCD_COLOR_BITS (ESP_PANEL_LCD_MIPI_DPI_PIXEL_BITS) // 8/16/18/24, typically same as the pixel bits +/* + * LCD RGB Element Order. Choose one of the following: + * - 0: RGB + * - 1: BGR + */ +#define ESP_PANEL_LCD_BGR_ORDER (0) // 0/1 +#define ESP_PANEL_LCD_INEVRT_COLOR (0) // 0/1 + +/* LCD Transformation Flags */ +// #define ESP_PANEL_LCD_SWAP_XY (0) // 0/1 +// #define ESP_PANEL_LCD_MIRROR_X (0) // 0/1 +// #define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1 + +/* LCD Other Settings */ +/* IO num of RESET pin, set to -1 if not use */ +#define ESP_PANEL_LCD_IO_RST (-1) +#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level + +#endif /* ESP_PANEL_USE_LCD */ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////// Please update the following macros to configure the touch panel /////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/* Set to 1 when using an touch panel */ +#define ESP_PANEL_USE_TOUCH (1) // 0/1 +#if ESP_PANEL_USE_TOUCH +/** + * Touch controller name. + */ +#define ESP_PANEL_TOUCH_NAME GT911 + +/* Touch resolution in pixels */ +#define ESP_PANEL_TOUCH_H_RES (ESP_PANEL_LCD_WIDTH) // Typically set to the same value as the width of LCD +#define ESP_PANEL_TOUCH_V_RES (ESP_PANEL_LCD_HEIGHT) // Typically set to the same value as the height of LCD + +/* Touch Panel Bus Settings */ +/** + * If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance. + * It is useful if other devices use the same host. Please ensure that the host is initialized only once. + */ +#define ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1 +/** + * Touch panel bus type. + */ +#define ESP_PANEL_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C) +/* Touch panel bus parameters */ +#if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C + + #define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0 + #define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address +#if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST + #define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000) + // Typically set to 400K + #define ESP_PANEL_TOUCH_I2C_SCL_PULLUP (0) // 0/1 + #define ESP_PANEL_TOUCH_I2C_SDA_PULLUP (0) // 0/1 + #define ESP_PANEL_TOUCH_I2C_IO_SCL (8) + #define ESP_PANEL_TOUCH_I2C_IO_SDA (7) +#endif + +#endif + +/* Touch Transformation Flags */ +#define ESP_PANEL_TOUCH_SWAP_XY (0) // 0/1 +#define ESP_PANEL_TOUCH_MIRROR_X (1) // 0/1 +#define ESP_PANEL_TOUCH_MIRROR_Y (1) // 0/1 + +/* Touch Other Settings */ +/* IO num of RESET pin, set to -1 if not use */ +#define ESP_PANEL_TOUCH_IO_RST (-1) +#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level +/* IO num of INT pin, set to -1 if not use */ +#define ESP_PANEL_TOUCH_IO_INT (-1) +#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level + +#endif /* ESP_PANEL_USE_TOUCH */ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the backlight //////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define ESP_PANEL_USE_BACKLIGHT (1) // 0/1 +#if ESP_PANEL_USE_BACKLIGHT +/* Backlight pin */ +#define ESP_PANEL_BACKLIGHT_IO (26) // IO num of backlight pin +#define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level + +/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ +#define ESP_PANEL_BACKLIGHT_IDLE_OFF (0) // 0: on, 1: off + +/* Set to 1 if use PWM for brightness control */ +#define ESP_PANEL_LCD_BL_USE_PWM (1) // 0/1 +#endif /* ESP_PANEL_USE_BACKLIGHT */ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please update the following macros to configure the IO expander ////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/* Set to 0 if not using IO Expander */ +#define ESP_PANEL_USE_EXPANDER (0) // 0/1 + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// Please utilize the following macros to execute any additional code if required. ////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// #define ESP_PANEL_BEGIN_START_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_LCD_START_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_LCD_END_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_TOUCH_START_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_TOUCH_END_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_BACKLIGHT_END_FUNCTION( panel ) +// #define ESP_PANEL_BEGIN_END_FUNCTION( panel ) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////// File Version /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Do not change the following versions, they are used to check if the configurations in this file are compatible with + * the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows: + * + * 1. If the major version is not consistent, then the configurations in this file are incompatible with the library + * and must be replaced with the file from the library. + * 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to + * default values. It is recommended to replace it with the file from the library. + * 3. Even if the patch version is not consistent, it will not affect normal functionality. + * + */ +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 3 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 + +// *INDENT-OFF* diff --git a/src/board/waveshare/Kconfig.waveshare b/src/board/waveshare/Kconfig.waveshare index bc6f3a84..285577f7 100644 --- a/src/board/waveshare/Kconfig.waveshare +++ b/src/board/waveshare/Kconfig.waveshare @@ -12,3 +12,8 @@ config BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1 bool "ESP32_S3_Touch_LCD_2_1" help https://www.waveshare.com/esp32-s3-touch-lcd-2.1.htm + +config BOARD_WAVESHARE_ESP32_P4_NANO + bool "ESP32_P4_NANO" + help + https://www.waveshare.com/esp32-p4-nano.htm diff --git a/test_apps/lvgl_port/sdkconfig.ci.waveshare_esp32_p4_nano b/test_apps/lvgl_port/sdkconfig.ci.waveshare_esp32_p4_nano new file mode 100644 index 00000000..a5815a9f --- /dev/null +++ b/test_apps/lvgl_port/sdkconfig.ci.waveshare_esp32_p4_nano @@ -0,0 +1,15 @@ +CONFIG_IDF_TARGET="esp32p4" +CONFIG_BOARD_MANUFACTURER_ALL=y +CONFIG_BOARD_ESP32_P4_FUNCTION_EV_BOARD=y + +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_HEX=y +CONFIG_SPIRAM_SPEED_200M=y +CONFIG_SPIRAM_XIP_FROM_PSRAM=y +CONFIG_IDF_EXPERIMENTAL_FEATURES=y + +# Improve FPS +CONFIG_CACHE_L2_CACHE_256KB=y +CONFIG_CACHE_L2_CACHE_LINE_128B=y + +CONFIG_LVGL_PORT_AVOID_TEARING_MODE_3=y diff --git a/test_apps/panel/sdkconfig.ci.waveshare_esp32_p4_nano b/test_apps/panel/sdkconfig.ci.waveshare_esp32_p4_nano new file mode 100644 index 00000000..c2a39505 --- /dev/null +++ b/test_apps/panel/sdkconfig.ci.waveshare_esp32_p4_nano @@ -0,0 +1,10 @@ +CONFIG_IDF_TARGET="esp32p4" +CONFIG_COMPILER_OPTIMIZATION_PERF=y +CONFIG_BOARD_MANUFACTURER_ALL=y +CONFIG_BOARD_ESP32_P4_FUNCTION_EV_BOARD=y + +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_HEX=y +CONFIG_SPIRAM_SPEED_200M=y +CONFIG_SPIRAM_XIP_FROM_PSRAM=y +CONFIG_IDF_EXPERIMENTAL_FEATURES=y From 104c39f8156281965a4b57f5c04591bee52ff00b Mon Sep 17 00:00:00 2001 From: Y1hsiaochunnn Date: Tue, 12 Nov 2024 09:05:58 +0800 Subject: [PATCH 3/3] Some of the recommendations have been revised --- ESP_Panel_Board_Supported.h | 2 +- README.md | 12 ++++++------ README_CN.md | 2 +- library.properties | 2 +- src/ESP_Panel_Board_Kconfig.h | 5 ----- src/board/ESP_PanelBoard.h | 2 ++ src/board/waveshare/ESP32_P4_NANO.h | 1 + 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ESP_Panel_Board_Supported.h b/ESP_Panel_Board_Supported.h index fc018f4b..2f930b76 100644 --- a/ESP_Panel_Board_Supported.h +++ b/ESP_Panel_Board_Supported.h @@ -106,7 +106,7 @@ * */ #define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MAJOR 0 -#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MINOR 6 +#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MINOR 7 #define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_PATCH 0 #endif diff --git a/README.md b/README.md index d2f83d8a..1602a4be 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,12 @@ Developers and manufacturers are welcome to contribute PRs to add more boards. F Below is the list of [supported LCD controllers](docs/LCD_Controllers.md): -| **Manufacturer** | **Model** | -| ---------------- | --------- | -| Fitipower | EK9716B, EK79007 | -| GalaxyCore | GC9A01, GC9B71, GC9503 | -| Ilitek | ILI9341, ILI9881C | -| NewVision | NV3022B | +| **Manufacturer** | **Model** | +| ---------------- |--------------------------------------------------| +| Fitipower | EK9716B, EK79007,JD9365 | +| GalaxyCore | GC9A01, GC9B71, GC9503 | +| Ilitek | ILI9341, ILI9881C | +| NewVision | NV3022B | | Sitronix | ST7262, ST7701, ST7789, ST7796, ST77916, ST77922 | ### Touch Controllers diff --git a/README_CN.md b/README_CN.md index 607ebfba..36aa8fe1 100644 --- a/README_CN.md +++ b/README_CN.md @@ -50,7 +50,7 @@ ESP32_Display_Panel 的功能框图如下所示,主要包含以下特性: | **厂商** | **型号** | | -------- | -------- | -| Fitipower | EK9716B, EK79007 | +| Fitipower | EK9716B, EK79007,JD9365 | | GalaxyCore | GC9A01, GC9B71, GC9503 | | Ilitek | ILI9341, ILI9881C | | NewVision | NV3022B | diff --git a/library.properties b/library.properties index 69e15cdd..dcf8f0b8 100644 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=0.2.0 author=espressif maintainer=espressif sentence=ESP32_Display_Panel is a library designed for ESP SoCs to drive display panels and facilitate rapid GUI development. -paragraph=Currently supported boards:ESP32-C3-LCDkit,ESP32-S3-BOX,ESP32-S3-BOX-3,ESP32-S3-BOX-3B,ESP32-S3-BOX-3(beta),ESP32-S3-BOX-Lite,ESP32-S3-EYE,ESP32-S3-Korvo-2,ESP32-S3-LCD-EV-Board,ESP32-S3-LCD-EV-Board-2,ESP32-S3-USB-OTG,ESP32-P4-Function-EV-Board,M5STACK-M5CORE2,M5STACK-M5DIAL,M5STACK-M5CORES3,ESP32-4848S040C_I_Y_3,ESP32-S3-Touch-LCD-4.3,ESP32-S3-Touch-LCD-1.85,ESP32-S3-Touch-LCD-2.1,ESP32-P4-NANO. Currently supported devices: Bus,LCD,Touch,Backlight,IO expander. Currently supported Bus: I2C,SPI,QSPI,3-wire SPI + RGB,MIPI-DSI. Currently supported LCD controllers: EK9716B,EK79007,GC9A01,GC9B71,GC9503,ILI9341,ILI9881C,NV3022B,ST7262,ST7701,ST7789,ST7796,ST77916,ST77922. Currently supported Touch controllers: CST816S,FT5x06,GT1151,GT911,ST7123,TT21100,XPT2046. +paragraph=Currently supported boards:ESP32-C3-LCDkit,ESP32-S3-BOX,ESP32-S3-BOX-3,ESP32-S3-BOX-3B,ESP32-S3-BOX-3(beta),ESP32-S3-BOX-Lite,ESP32-S3-EYE,ESP32-S3-Korvo-2,ESP32-S3-LCD-EV-Board,ESP32-S3-LCD-EV-Board-2,ESP32-S3-USB-OTG,ESP32-P4-Function-EV-Board,M5STACK-M5CORE2,M5STACK-M5DIAL,M5STACK-M5CORES3,ESP32-4848S040C_I_Y_3,ESP32-S3-Touch-LCD-4.3,ESP32-S3-Touch-LCD-1.85,ESP32-S3-Touch-LCD-2.1,ESP32-P4-NANO. Currently supported devices: Bus,LCD,Touch,Backlight,IO expander. Currently supported Bus: I2C,SPI,QSPI,3-wire SPI + RGB,MIPI-DSI. Currently supported LCD controllers: EK9716B,EK79007,GC9A01,GC9B71,GC9503,ILI9341,ILI9881C,JD9365,NV3022B,ST7262,ST7701,ST7789,ST7796,ST77916,ST77922. Currently supported Touch controllers: CST816S,FT5x06,GT1151,GT911,ST7123,TT21100,XPT2046. category=Other architectures=esp32 url=https://github.com/esp-arduino-libs/ESP32_Display_Panel diff --git a/src/ESP_Panel_Board_Kconfig.h b/src/ESP_Panel_Board_Kconfig.h index c7b66f12..40a1376c 100644 --- a/src/ESP_Panel_Board_Kconfig.h +++ b/src/ESP_Panel_Board_Kconfig.h @@ -150,11 +150,6 @@ #define BOARD_WAVESHARE_ESP32_P4_NANO CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO #endif #endif - #ifndef BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 - #ifdef CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 - #define BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 CONFIG_BOARD_WAVESHARE_ESP32_P4_NANO_800_1280 - #endif - #endif #endif /* ESP_PANEL_USE_SUPPORTED_BOARD */ /** diff --git a/src/board/ESP_PanelBoard.h b/src/board/ESP_PanelBoard.h index e6e68179..b8be1c40 100644 --- a/src/board/ESP_PanelBoard.h +++ b/src/board/ESP_PanelBoard.h @@ -89,6 +89,8 @@ #include "board/waveshare/ESP32_S3_Touch_LCD_1_85.h" #elif defined(BOARD_WAVESHARE_ESP32_S3_Touch_LCD_2_1) #include "board/waveshare/ESP32_S3_Touch_LCD_2_1.h" +#elif defined(BOARD_WAVESHARE_ESP32_P4_NANO) + #include "board/waveshare/ESP32_P4_NANO.h" #else #error "Unknown board selected! Please check file `ESP_Panel_Board_Supported.h` and make sure only one board is enabled." #endif diff --git a/src/board/waveshare/ESP32_P4_NANO.h b/src/board/waveshare/ESP32_P4_NANO.h index 29fed94c..caa0649e 100644 --- a/src/board/waveshare/ESP32_P4_NANO.h +++ b/src/board/waveshare/ESP32_P4_NANO.h @@ -120,6 +120,7 @@ #if ESP_PANEL_USE_TOUCH /** * Touch controller name. + * Since the driver for the GT9271 is compatible with the GT911, the GT911 is used here. */ #define ESP_PANEL_TOUCH_NAME GT911