diff --git a/README.md b/README.md index a24616bb..e37bdc9d 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Below is a list of [supported LCD controllers](docs/LCD_Controllers.md): | **Manufacturer** | **Model** | | --------------- | --------- | +| Fitipower | EK9716B | | GalaxyCore | GC9A01, GC9B71, GC9503 | | Ilitek | ILI9341 | | NewVision | NV3022B | diff --git a/README_CN.md b/README_CN.md index 0f929db6..f7767f50 100644 --- a/README_CN.md +++ b/README_CN.md @@ -74,6 +74,7 @@ ESP32_Display_Panel 的功能框图如下所示,主要包含以下特性: | **厂商** | **型号** | | -------- | -------- | +| Fitipower | EK9716B | | GalaxyCore | GC9A01, GC9B71, GC9503 | | Ilitek | ILI9341 | | NewVision | NV3022B | diff --git a/docs/LCD_Controllers.md b/docs/LCD_Controllers.md index 8f6208ea..0b306133 100644 --- a/docs/LCD_Controllers.md +++ b/docs/LCD_Controllers.md @@ -15,3 +15,4 @@ | [ST7796](https://components.espressif.com/components/espressif/esp_lcd_st7796) | 1.2.1 | | [ST77916](https://components.espressif.com/components/espressif/esp_lcd_st77916) | 0.0.2 | | [ST77922](https://components.espressif.com/components/espressif/esp_lcd_st77922) | 0.0.2 | +| EK9716B | - | diff --git a/examples/LCD/RGB/README.md b/examples/LCD/RGB/README.md index e515bd60..ad2dfd7a 100644 --- a/examples/LCD/RGB/README.md +++ b/examples/LCD/RGB/README.md @@ -1,8 +1,12 @@ -| Supported ESP SoCs | ESP32-S3 | -| ------------------ | -------- | +| Supported ESP SoCs | +| ------------------ | +| ESP32-S3 | + +| Supported LCD Controllers | +| ------------------------- | +| EK9716B | +| ST7262 | -| Supported LCD Controllers | ST7262 | -| ------------------------- | ------ | # Single RGB LCD Example diff --git a/library.properties b/library.properties index e29ffed2..2f8a775e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESP32_Display_Panel -version=0.1.5 +version=0.1.6 author=espressif maintainer=espressif sentence=ESP32_Display_Panel is an Arduino library designed for ESP SoCs to drive display panels and facilitate rapid GUI development. diff --git a/src/ESP_PanelVersions.h b/src/ESP_PanelVersions.h index ac7043f8..6d15df0f 100644 --- a/src/ESP_PanelVersions.h +++ b/src/ESP_PanelVersions.h @@ -11,7 +11,7 @@ /* Library Version */ #define ESP_PANEL_VERSION_MAJOR 0 #define ESP_PANEL_VERSION_MINOR 1 -#define ESP_PANEL_VERSION_PATCH 5 +#define ESP_PANEL_VERSION_PATCH 6 /* File `ESP_Panel_Conf.h` */ #define ESP_PANEL_CONF_VERSION_MAJOR 0 diff --git a/src/ESP_Panel_Library.h b/src/ESP_Panel_Library.h index 33c0f090..a602f15b 100644 --- a/src/ESP_Panel_Library.h +++ b/src/ESP_Panel_Library.h @@ -24,6 +24,7 @@ /* LCD */ #include "lcd/ESP_PanelLcd.h" +#include "lcd/EK9716B.h" #include "lcd/GC9503.h" #include "lcd/GC9A01.h" #include "lcd/GC9B71.h" diff --git a/src/board/elecrow/CROWPANEL_7_0.h b/src/board/elecrow/CROWPANEL_7_0.h index c8ccc6a8..7556fe11 100644 --- a/src/board/elecrow/CROWPANEL_7_0.h +++ b/src/board/elecrow/CROWPANEL_7_0.h @@ -18,7 +18,7 @@ /** * LCD Controller Name. */ -#define ESP_PANEL_LCD_NAME EK9716BD3 +#define ESP_PANEL_LCD_NAME EK9716B // Fitipower EK9716B /* LCD resolution in pixels */ #define ESP_PANEL_LCD_WIDTH (800) @@ -217,7 +217,6 @@ // #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel ) // #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel ) #define ESP_PANEL_BEGIN_LCD_START_FUNCTION( panel ) \ - { \ /* Maintain the touch INT signal in a low state during the reset process to set its I2C address to `0x5D` */ \ gpio_set_direction((gpio_num_t)ESP_PANEL_TOUCH_IO_INT, GPIO_MODE_OUTPUT); \ diff --git a/src/lcd/EK9716B.cpp b/src/lcd/EK9716B.cpp new file mode 100644 index 00000000..0495c7b3 --- /dev/null +++ b/src/lcd/EK9716B.cpp @@ -0,0 +1,87 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/soc_caps.h" + +#if SOC_LCD_RGB_SUPPORTED +#include "driver/gpio.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_check.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_panel_rgb.h" +#include "esp_lcd_panel_vendor.h" +#include "esp_log.h" + +#include "ESP_PanelLog.h" +#include "bus/RGB.h" +#include "EK9716B.h" + +static const char *TAG = "EK9716B_CPP"; + +ESP_PanelLcd_EK9716B::ESP_PanelLcd_EK9716B(ESP_PanelBus *bus, uint8_t color_bits, int rst_io): + ESP_PanelLcd(bus, color_bits, rst_io) +{ +} + +ESP_PanelLcd_EK9716B::ESP_PanelLcd_EK9716B(ESP_PanelBus *bus, const esp_lcd_panel_dev_config_t &panel_config): + ESP_PanelLcd(bus, panel_config) +{ +} + +ESP_PanelLcd_EK9716B::~ESP_PanelLcd_EK9716B() +{ + 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_EK9716B::init(void) +{ + ESP_PANEL_ENABLE_TAG_DEBUG_LOG(); + + if (panel_config.reset_gpio_num >= 0) { + gpio_config_t gpio_conf = { + .pin_bit_mask = BIT64(panel_config.reset_gpio_num), + .mode = GPIO_MODE_OUTPUT, + .pull_up_en = GPIO_PULLUP_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE, + }; + ESP_PANEL_CHECK_ERR_RET(gpio_config(&gpio_conf), false, "`Config RST gpio failed"); + } + ESP_PANEL_CHECK_ERR_RET(esp_lcd_new_rgb_panel(vendor_config.rgb_config, &handle), false, "Create panel failed"); + + ESP_LOGD(TAG, "LCD panel @%p created", handle); + + return true; +} + +bool ESP_PanelLcd_EK9716B::reset(void) +{ + ESP_PANEL_CHECK_NULL_RET(handle, false, "Invalid handle"); + + if (panel_config.reset_gpio_num >= 0) { + gpio_set_level((gpio_num_t)panel_config.reset_gpio_num, panel_config.flags.reset_active_high); + vTaskDelay(pdMS_TO_TICKS(10)); + gpio_set_level((gpio_num_t)panel_config.reset_gpio_num, !panel_config.flags.reset_active_high); + vTaskDelay(pdMS_TO_TICKS(120)); + } + ESP_PANEL_CHECK_ERR_RET(esp_lcd_panel_reset(handle), false, "Reset panel failed"); + + return true; +} + +#endif /* SOC_LCD_RGB_SUPPORTED */ diff --git a/src/lcd/EK9716B.h b/src/lcd/EK9716B.h new file mode 100644 index 00000000..53cc4eb4 --- /dev/null +++ b/src/lcd/EK9716B.h @@ -0,0 +1,66 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "soc/soc_caps.h" + +#if SOC_LCD_RGB_SUPPORTED +#include "ESP_PanelLcd.h" + +/** + * @brief EK9716B LCD device object class + * + * @note This class is a derived class of `ESP_PanelLcd`, user can use it directly + */ +class ESP_PanelLcd_EK9716B: 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 + * + * @param bus Pointer of panel bus + * @param color_bits Bits per pixel (24) + * @param rst_io Reset pin, set to `-1` if no use + */ + ESP_PanelLcd_EK9716B(ESP_PanelBus *bus, uint8_t color_bits, int rst_io = -1); + + /** + * @brief Construct a new LCD device 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_EK9716B(ESP_PanelBus *bus, const esp_lcd_panel_dev_config_t &panel_config); + + /** + * @brief Destroy the LCD device + * + */ + ~ESP_PanelLcd_EK9716B() 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; + + /** + * @brief Reset the LCD. If the `rst_io` is not set, this function will do reset by software instead of hardware + * + * @note This function should be called after `init()` + * + * @return true if success, otherwise false + */ + bool reset(void); +}; + +#endif /* SOC_LCD_RGB_SUPPORTED */