From 245be0ea1b7ccd298f4638f0f5451b92f4ff71c2 Mon Sep 17 00:00:00 2001 From: Y1hsiaochunnn <66012385+Y1hsiaochunnn@users.noreply.github.com> Date: Wed, 28 May 2025 23:20:14 +0800 Subject: [PATCH] Three new Waveshare ESP32-P4 development boards have been added (#691) * Added third-party hardware support Waveshare-ESP32-P4-WIFI6-Touch-LCD-3.4C, Waveshare-ESP32-P4-WIFI6-Touch-LCD-4C, Waveshare-ESP32-P4-WIFI6-Touch-LCD-4B * Remove the README * Merge ESP32-P4-WIFI6-Touch-LCD-3.4C and ESP32-P4-WIFI6-Touch-LCD-4C into one board * Add readme files --- main/CMakeLists.txt | 4 + main/Kconfig.projbuild | 12 +- .../waveshare-p4-wifi6-touch-lcd-4b/README.md | 12 + .../waveshare-p4-wifi6-touch-lcd-4b/config.h | 47 ++ .../esp32-p4-wifi6-touch-lcd-4b.cc | 211 ++++++++ .../waveshare-p4-wifi6-touch-lcd-xc/README.md | 22 + .../waveshare-p4-wifi6-touch-lcd-xc/config.h | 490 ++++++++++++++++++ .../esp32-p4-wifi6-touch-lcd-xc.cc | 213 ++++++++ main/idf_component.yml | 4 + 9 files changed, 1013 insertions(+), 2 deletions(-) create mode 100644 main/boards/waveshare-p4-wifi6-touch-lcd-4b/README.md create mode 100644 main/boards/waveshare-p4-wifi6-touch-lcd-4b/config.h create mode 100644 main/boards/waveshare-p4-wifi6-touch-lcd-4b/esp32-p4-wifi6-touch-lcd-4b.cc create mode 100644 main/boards/waveshare-p4-wifi6-touch-lcd-xc/README.md create mode 100644 main/boards/waveshare-p4-wifi6-touch-lcd-xc/config.h create mode 100644 main/boards/waveshare-p4-wifi6-touch-lcd-xc/esp32-p4-wifi6-touch-lcd-xc.cc diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 5428956b..824e2645 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -112,6 +112,10 @@ elseif(CONFIG_BOARD_TYPE_ESP32S3_Touch_LCD_3_5) set(BOARD_TYPE "esp32-s3-touch-lcd-3.5") elseif(CONFIG_BOARD_TYPE_ESP32P4_NANO) set(BOARD_TYPE "waveshare-p4-nano") +elseif(CONFIG_BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B) + set(BOARD_TYPE "waveshare-p4-wifi6-touch-lcd-4b") +elseif(CONFIG_BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC) + set(BOARD_TYPE "waveshare-p4-wifi6-touch-lcd-xc") elseif(CONFIG_BOARD_TYPE_BREAD_COMPACT_WIFI_LCD) set(BOARD_TYPE "bread-compact-wifi-lcd") elseif(CONFIG_BOARD_TYPE_TUDOUZI) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 2abc1c67..8c329753 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -108,6 +108,10 @@ choice BOARD_TYPE bool "Waveshare ESP32-S3-Touch-LCD-3.5" config BOARD_TYPE_ESP32P4_NANO bool "Waveshare ESP32-P4-NANO" + config BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B + bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-4B" + config BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC + bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-3.4C or ESP32-P4-WIFI6-Touch-LCD-4C" config BOARD_TYPE_TUDOUZI bool "土豆子" config BOARD_TYPE_LILYGO_T_CIRCLE_S3 @@ -197,7 +201,7 @@ choice DISPLAY_OLED_TYPE endchoice choice DISPLAY_LCD_TYPE - depends on BOARD_TYPE_BREAD_COMPACT_WIFI_LCD || BOARD_TYPE_BREAD_COMPACT_ESP32_LCD || BOARD_TYPE_ESP32_CGC || BOARD_TYPE_ESP32P4_NANO + depends on BOARD_TYPE_BREAD_COMPACT_WIFI_LCD || BOARD_TYPE_BREAD_COMPACT_ESP32_LCD || BOARD_TYPE_ESP32_CGC || BOARD_TYPE_ESP32P4_NANO || BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC prompt "LCD Type" default LCD_ST7789_240X320 help @@ -236,6 +240,10 @@ choice DISPLAY_LCD_TYPE bool "Waveshare 101M-8001280-IPS-CT-K Display" config LCD_TYPE_800_1280_10_1_INCH_A bool "Waveshare 10.1-DSI-TOUCH-A Display" + config LCD_TYPE_800_800_3_4_INCH + bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-3.4C with 800*800 3.4inch round display" + config LCD_TYPE_720_720_4_INCH + bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-4C with 720*720 4inch round display" config LCD_CUSTOM bool "自定义屏幕参数" endchoice @@ -275,7 +283,7 @@ config USE_AUDIO_PROCESSOR config USE_DEVICE_AEC bool "Enable Device-Side AEC" default n - depends on USE_AUDIO_PROCESSOR && (BOARD_TYPE_ESP_BOX_3 || BOARD_TYPE_ESP_BOX || BOARD_TYPE_ESP_BOX_LITE || BOARD_TYPE_LICHUANG_DEV || BOARD_TYPE_ESP32S3_KORVO2_V3 || BOARD_TYPE_ESP32S3_Touch_AMOLED_1_75) + depends on USE_AUDIO_PROCESSOR && (BOARD_TYPE_ESP_BOX_3 || BOARD_TYPE_ESP_BOX || BOARD_TYPE_ESP_BOX_LITE || BOARD_TYPE_LICHUANG_DEV || BOARD_TYPE_ESP32S3_KORVO2_V3 || BOARD_TYPE_ESP32S3_Touch_AMOLED_1_75 || BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B || BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC) help 因为性能不够,不建议和微信聊天界面风格同时开启 diff --git a/main/boards/waveshare-p4-wifi6-touch-lcd-4b/README.md b/main/boards/waveshare-p4-wifi6-touch-lcd-4b/README.md new file mode 100644 index 00000000..eb94e644 --- /dev/null +++ b/main/boards/waveshare-p4-wifi6-touch-lcd-4b/README.md @@ -0,0 +1,12 @@ +# Waveshare ESP32-P4-WIFI6-Touch-LCD-4B + + +[ESP32-P4-WIFI6-Touch-LCD-4B](https://www.waveshare.com/esp32-p4-wifi6-touch-lcd-4b.htm) is waveshare electronics designed an intelligent 86 box based on ESP32-P4 module equipped with a 720*720 IPS capacitive touch screen + + +## Configuration + +Configuration in `menuconfig`. + +Selection Board Type `Xiaozhi Assistant --> Board Type` +- Waveshare ESP32-P4-WIFI6-Touch-LCD-4B \ No newline at end of file diff --git a/main/boards/waveshare-p4-wifi6-touch-lcd-4b/config.h b/main/boards/waveshare-p4-wifi6-touch-lcd-4b/config.h new file mode 100644 index 00000000..027c215a --- /dev/null +++ b/main/boards/waveshare-p4-wifi6-touch-lcd-4b/config.h @@ -0,0 +1,47 @@ +#ifndef _BOARD_CONFIG_H_ +#define _BOARD_CONFIG_H_ + +#include + +#define AUDIO_INPUT_SAMPLE_RATE 24000 +#define AUDIO_OUTPUT_SAMPLE_RATE 24000 + +#define AUDIO_INPUT_REFERENCE true + +#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_13 +#define AUDIO_I2S_GPIO_WS GPIO_NUM_10 +#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_12 +#define AUDIO_I2S_GPIO_DIN GPIO_NUM_11 +#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_9 + +#define AUDIO_CODEC_PA_PIN GPIO_NUM_53 +#define AUDIO_CODEC_I2C_SDA_PIN GPIO_NUM_7 +#define AUDIO_CODEC_I2C_SCL_PIN GPIO_NUM_8 +#define AUDIO_CODEC_ES8311_ADDR ES8311_CODEC_DEFAULT_ADDR +#define AUDIO_CODEC_ES7210_ADDR ES7210_CODEC_DEFAULT_ADDR + +#define BOOT_BUTTON_GPIO GPIO_NUM_35 + +#define DISPLAY_WIDTH 720 +#define DISPLAY_HEIGHT 720 + +#define LCD_BIT_PER_PIXEL (16) +#define PIN_NUM_LCD_RST GPIO_NUM_27 + +#define DELAY_TIME_MS (3000) +#define LCD_MIPI_DSI_LANE_NUM (2) // 2 data lanes + +#define MIPI_DSI_PHY_PWR_LDO_CHAN (3) +#define MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV (2500) + +#define DISPLAY_SWAP_XY false +#define DISPLAY_MIRROR_X false +#define DISPLAY_MIRROR_Y false + +#define DISPLAY_OFFSET_X 0 +#define DISPLAY_OFFSET_Y 0 + +#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_26 +#define DISPLAY_BACKLIGHT_OUTPUT_INVERT true + +#endif // _BOARD_CONFIG_H_ diff --git a/main/boards/waveshare-p4-wifi6-touch-lcd-4b/esp32-p4-wifi6-touch-lcd-4b.cc b/main/boards/waveshare-p4-wifi6-touch-lcd-4b/esp32-p4-wifi6-touch-lcd-4b.cc new file mode 100644 index 00000000..3bf11cd1 --- /dev/null +++ b/main/boards/waveshare-p4-wifi6-touch-lcd-4b/esp32-p4-wifi6-touch-lcd-4b.cc @@ -0,0 +1,211 @@ +#include "wifi_board.h" +#include "audio_codecs/box_audio_codec.h" +#include "application.h" +#include "display/lcd_display.h" +// #include "display/no_display.h" +#include "button.h" +#include "config.h" +#include "iot/thing_manager.h" + +#include "esp_lcd_panel_ops.h" +#include "esp_lcd_mipi_dsi.h" +#include "esp_ldo_regulator.h" + +#include "esp_lcd_st7703.h" + +#include +#include +#include +#include +#include "esp_lcd_touch_gt911.h" +#define TAG "WaveshareEsp32p44b" + +LV_FONT_DECLARE(font_puhui_30_4); +LV_FONT_DECLARE(font_awesome_30_4); + +class WaveshareEsp32p44b : public WifiBoard { +private: + i2c_master_bus_handle_t i2c_bus_; + Button boot_button_; + LcdDisplay *display_; + + void InitializeCodecI2c() { + // Initialize I2C peripheral + i2c_master_bus_config_t i2c_bus_cfg = { + .i2c_port = I2C_NUM_1, + .sda_io_num = AUDIO_CODEC_I2C_SDA_PIN, + .scl_io_num = AUDIO_CODEC_I2C_SCL_PIN, + .clk_source = I2C_CLK_SRC_DEFAULT, + .glitch_ignore_cnt = 7, + .intr_priority = 0, + .trans_queue_depth = 0, + .flags = { + .enable_internal_pullup = 1, + }, + }; + ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_cfg, &i2c_bus_)); + } + + static esp_err_t bsp_enable_dsi_phy_power(void) { +#if MIPI_DSI_PHY_PWR_LDO_CHAN > 0 + // Turn on the power for MIPI DSI PHY, so it can go from "No Power" state to "Shutdown" state + static esp_ldo_channel_handle_t phy_pwr_chan = NULL; + esp_ldo_channel_config_t ldo_cfg = { + .chan_id = MIPI_DSI_PHY_PWR_LDO_CHAN, + .voltage_mv = MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV, + }; + esp_ldo_acquire_channel(&ldo_cfg, &phy_pwr_chan); + ESP_LOGI(TAG, "MIPI DSI PHY Powered on"); +#endif // BSP_MIPI_DSI_PHY_PWR_LDO_CHAN > 0 + + return ESP_OK; + } + + void InitializeLCD() { + bsp_enable_dsi_phy_power(); + esp_lcd_panel_io_handle_t io = NULL; + esp_lcd_panel_handle_t disp_panel = NULL; + + esp_lcd_dsi_bus_handle_t mipi_dsi_bus = NULL; + esp_lcd_dsi_bus_config_t bus_config = ST7703_PANEL_BUS_DSI_2CH_CONFIG(); + esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus); + + ESP_LOGI(TAG, "Install MIPI DSI LCD control panel"); + // we use DBI interface to send LCD commands and parameters + esp_lcd_dbi_io_config_t dbi_config = ST7703_PANEL_IO_DBI_CONFIG(); + esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io); + + esp_lcd_dpi_panel_config_t dpi_config = { + .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, + .dpi_clock_freq_mhz = 46, + .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565, + .num_fbs = 1, + .video_timing = { + .h_size = 720, + .v_size = 720, + .hsync_pulse_width = 20, + .hsync_back_porch = 80, + .hsync_front_porch = 80, + .vsync_pulse_width = 4, + .vsync_back_porch = 12, + .vsync_front_porch = 30, + }, + .flags = { + .use_dma2d = true, + }, + }; + st7703_vendor_config_t vendor_config = { + + .mipi_config = { + .dsi_bus = mipi_dsi_bus, + .dpi_config = &dpi_config, + }, + .flags = { + .use_mipi_interface = 1, + }, + }; + + const esp_lcd_panel_dev_config_t lcd_dev_config = { + .reset_gpio_num = PIN_NUM_LCD_RST, + .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, + .bits_per_pixel = 16, + .vendor_config = &vendor_config, + }; + esp_lcd_new_panel_st7703(io, &lcd_dev_config, &disp_panel); + esp_lcd_panel_reset(disp_panel); + esp_lcd_panel_init(disp_panel); + + display_ = new MipiLcdDisplay(io, disp_panel, DISPLAY_WIDTH, DISPLAY_HEIGHT, + DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, + { + .text_font = &font_puhui_30_4, + .icon_font = &font_awesome_30_4, + .emoji_font = font_emoji_64_init(), + }); + } + void InitializeTouch() + { + esp_lcd_touch_handle_t tp; + esp_lcd_touch_config_t tp_cfg = { + .x_max = DISPLAY_WIDTH, + .y_max = DISPLAY_HEIGHT, + .rst_gpio_num = GPIO_NUM_23, + .int_gpio_num = GPIO_NUM_NC, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 0, + .mirror_y = 0, + }, + }; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); + tp_io_config.scl_speed_hz = 400 * 1000; + ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus_, &tp_io_config, &tp_io_handle)); + ESP_LOGI(TAG, "Initialize touch controller"); + ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp)); + const lvgl_port_touch_cfg_t touch_cfg = { + .disp = lv_display_get_default(), + .handle = tp, + }; + lvgl_port_add_touch(&touch_cfg); + ESP_LOGI(TAG, "Touch panel initialized successfully"); + } + void InitializeButtons() { + boot_button_.OnClick([this]() { + auto& app = Application::GetInstance(); + if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) { + ResetWifiConfiguration(); + } + app.ToggleChatState(); }); + } + + // 物联网初始化,添加对 AI 可见设备 + void InitializeIot() { + auto &thing_manager = iot::ThingManager::GetInstance(); + thing_manager.AddThing(iot::CreateThing("Speaker")); + thing_manager.AddThing(iot::CreateThing("Screen")); + } + +public: + WaveshareEsp32p44b() : + boot_button_(BOOT_BUTTON_GPIO) { + InitializeCodecI2c(); + InitializeIot(); + InitializeLCD(); + InitializeTouch(); + InitializeButtons(); + GetBacklight()->RestoreBrightness(); + } + + virtual AudioCodec* GetAudioCodec() override { + static BoxAudioCodec audio_codec( + i2c_bus_, + AUDIO_INPUT_SAMPLE_RATE, + AUDIO_OUTPUT_SAMPLE_RATE, + AUDIO_I2S_GPIO_MCLK, + AUDIO_I2S_GPIO_BCLK, + AUDIO_I2S_GPIO_WS, + AUDIO_I2S_GPIO_DOUT, + AUDIO_I2S_GPIO_DIN, + AUDIO_CODEC_PA_PIN, + AUDIO_CODEC_ES8311_ADDR, + AUDIO_CODEC_ES7210_ADDR, + AUDIO_INPUT_REFERENCE); + return &audio_codec; + } + + virtual Display *GetDisplay() override { + return display_; + } + + virtual Backlight* GetBacklight() override { + static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT); + return &backlight; + } +}; + +DECLARE_BOARD(WaveshareEsp32p44b); diff --git a/main/boards/waveshare-p4-wifi6-touch-lcd-xc/README.md b/main/boards/waveshare-p4-wifi6-touch-lcd-xc/README.md new file mode 100644 index 00000000..09271dd7 --- /dev/null +++ b/main/boards/waveshare-p4-wifi6-touch-lcd-xc/README.md @@ -0,0 +1,22 @@ +# Waveshare ESP32-P4-WIFI6-Touch-LCD-XC + + +[ESP32-P4-WIFI6-Touch-LCD-XC](https://www.waveshare.com/esp32-p4-wifi6-touch-lcd-3.4c.htm) is waveshare electronics designed a 3.4-inch, 4-inch circular screen, highly integrated development board + + +## Configuration + +Configuration in `menuconfig`. + +Selection Board Type `Xiaozhi Assistant --> Board Type` +- Waveshare ESP32-P4-WIFI6-Touch-LCD-3.4C or ESP32-P4-WIFI6-Touch-LCD-4C + +Selection Display LCD Type `Xiaozhi Assistant --> LCD Type` +- Waveshare ESP32-P4-WIFI6-Touch-LCD-3.4C with 800*800 3.4inch round display +- Waveshare ESP32-P4-WIFI6-Touch-LCD-4C with 720*720 4inch round display + + + +| [ESP32-P4-WIFI6-Touch-LCD-3.4C](https://www.waveshare.com/esp32-p4-wifi6-touch-lcd-3.4c.htm) | [ESP32-P4-WIFI6-Touch-LCD-4C](https://www.waveshare.com/esp32-p4-wifi6-touch-lcd-4c.htm) | +|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------| +| | | diff --git a/main/boards/waveshare-p4-wifi6-touch-lcd-xc/config.h b/main/boards/waveshare-p4-wifi6-touch-lcd-xc/config.h new file mode 100644 index 00000000..30e73ae2 --- /dev/null +++ b/main/boards/waveshare-p4-wifi6-touch-lcd-xc/config.h @@ -0,0 +1,490 @@ +#ifndef _BOARD_CONFIG_H_ +#define _BOARD_CONFIG_H_ + +#include + +#define AUDIO_INPUT_SAMPLE_RATE 24000 +#define AUDIO_OUTPUT_SAMPLE_RATE 24000 + +#define AUDIO_INPUT_REFERENCE true + +#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_13 +#define AUDIO_I2S_GPIO_WS GPIO_NUM_10 +#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_12 +#define AUDIO_I2S_GPIO_DIN GPIO_NUM_11 +#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_9 + +#define AUDIO_CODEC_PA_PIN GPIO_NUM_53 +#define AUDIO_CODEC_I2C_SDA_PIN GPIO_NUM_7 +#define AUDIO_CODEC_I2C_SCL_PIN GPIO_NUM_8 +#define AUDIO_CODEC_ES8311_ADDR ES8311_CODEC_DEFAULT_ADDR +#define AUDIO_CODEC_ES7210_ADDR ES7210_CODEC_DEFAULT_ADDR + +#define BOOT_BUTTON_GPIO GPIO_NUM_35 + +#define LCD_BIT_PER_PIXEL (16) +#define PIN_NUM_LCD_RST GPIO_NUM_27 + +#define DELAY_TIME_MS (3000) +#define LCD_MIPI_DSI_LANE_NUM (2) // 2 data lanes + +#define MIPI_DSI_PHY_PWR_LDO_CHAN (3) +#define MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV (2500) + +#define DISPLAY_SWAP_XY false +#define DISPLAY_MIRROR_X false +#define DISPLAY_MIRROR_Y false + +#define DISPLAY_OFFSET_X 0 +#define DISPLAY_OFFSET_Y 0 + +#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_26 +#define DISPLAY_BACKLIGHT_OUTPUT_INVERT true + +#if CONFIG_LCD_TYPE_800_800_3_4_INCH +#define DISPLAY_WIDTH 800 +#define DISPLAY_HEIGHT 800 + +static const jd9365_lcd_init_cmd_t lcd_init_cmds[] = { + {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[]){0x41}, 1, 0}, + {0x03, (uint8_t[]){0x10}, 1, 0}, + {0x04, (uint8_t[]){0x44}, 1, 0}, + + {0x17, (uint8_t[]){0x00}, 1, 0}, + {0x18, (uint8_t[]){0xD0}, 1, 0}, + {0x19, (uint8_t[]){0x00}, 1, 0}, + {0x1A, (uint8_t[]){0x00}, 1, 0}, + {0x1B, (uint8_t[]){0xD0}, 1, 0}, + {0x1C, (uint8_t[]){0x00}, 1, 0}, + + {0x24, (uint8_t[]){0xFE}, 1, 0}, + {0x35, (uint8_t[]){0x26}, 1, 0}, + + {0x37, (uint8_t[]){0x09}, 1, 0}, + + {0x38, (uint8_t[]){0x04}, 1, 0}, + {0x39, (uint8_t[]){0x08}, 1, 0}, + {0x3A, (uint8_t[]){0x0A}, 1, 0}, + {0x3C, (uint8_t[]){0x78}, 1, 0}, + {0x3D, (uint8_t[]){0xFF}, 1, 0}, + {0x3E, (uint8_t[]){0xFF}, 1, 0}, + {0x3F, (uint8_t[]){0xFF}, 1, 0}, + + {0x40, (uint8_t[]){0x00}, 1, 0}, + {0x41, (uint8_t[]){0x64}, 1, 0}, + {0x42, (uint8_t[]){0xC7}, 1, 0}, + {0x43, (uint8_t[]){0x18}, 1, 0}, + {0x44, (uint8_t[]){0x0B}, 1, 0}, + {0x45, (uint8_t[]){0x14}, 1, 0}, + + {0x55, (uint8_t[]){0x02}, 1, 0}, + {0x57, (uint8_t[]){0x49}, 1, 0}, + {0x59, (uint8_t[]){0x0A}, 1, 0}, + {0x5A, (uint8_t[]){0x1B}, 1, 0}, + {0x5B, (uint8_t[]){0x19}, 1, 0}, + + {0x5D, (uint8_t[]){0x7F}, 1, 0}, + {0x5E, (uint8_t[]){0x56}, 1, 0}, + {0x5F, (uint8_t[]){0x43}, 1, 0}, + {0x60, (uint8_t[]){0x37}, 1, 0}, + {0x61, (uint8_t[]){0x33}, 1, 0}, + {0x62, (uint8_t[]){0x25}, 1, 0}, + {0x63, (uint8_t[]){0x2A}, 1, 0}, + {0x64, (uint8_t[]){0x16}, 1, 0}, + {0x65, (uint8_t[]){0x30}, 1, 0}, + {0x66, (uint8_t[]){0x2F}, 1, 0}, + {0x67, (uint8_t[]){0x32}, 1, 0}, + {0x68, (uint8_t[]){0x53}, 1, 0}, + {0x69, (uint8_t[]){0x43}, 1, 0}, + {0x6A, (uint8_t[]){0x4C}, 1, 0}, + {0x6B, (uint8_t[]){0x40}, 1, 0}, + {0x6C, (uint8_t[]){0x3D}, 1, 0}, + {0x6D, (uint8_t[]){0x31}, 1, 0}, + {0x6E, (uint8_t[]){0x20}, 1, 0}, + {0x6F, (uint8_t[]){0x0F}, 1, 0}, + + {0x70, (uint8_t[]){0x7F}, 1, 0}, + {0x71, (uint8_t[]){0x56}, 1, 0}, + {0x72, (uint8_t[]){0x43}, 1, 0}, + {0x73, (uint8_t[]){0x37}, 1, 0}, + {0x74, (uint8_t[]){0x33}, 1, 0}, + {0x75, (uint8_t[]){0x25}, 1, 0}, + {0x76, (uint8_t[]){0x2A}, 1, 0}, + {0x77, (uint8_t[]){0x16}, 1, 0}, + {0x78, (uint8_t[]){0x30}, 1, 0}, + {0x79, (uint8_t[]){0x2F}, 1, 0}, + {0x7A, (uint8_t[]){0x32}, 1, 0}, + {0x7B, (uint8_t[]){0x53}, 1, 0}, + {0x7C, (uint8_t[]){0x43}, 1, 0}, + {0x7D, (uint8_t[]){0x4C}, 1, 0}, + {0x7E, (uint8_t[]){0x40}, 1, 0}, + {0x7F, (uint8_t[]){0x3D}, 1, 0}, + {0x80, (uint8_t[]){0x31}, 1, 0}, + {0x81, (uint8_t[]){0x20}, 1, 0}, + {0x82, (uint8_t[]){0x0F}, 1, 0}, + + {0xE0, (uint8_t[]){0x02}, 1, 0}, + {0x00, (uint8_t[]){0x5F}, 1, 0}, + {0x01, (uint8_t[]){0x5F}, 1, 0}, + {0x02, (uint8_t[]){0x5E}, 1, 0}, + {0x03, (uint8_t[]){0x5E}, 1, 0}, + {0x04, (uint8_t[]){0x50}, 1, 0}, + {0x05, (uint8_t[]){0x48}, 1, 0}, + {0x06, (uint8_t[]){0x48}, 1, 0}, + {0x07, (uint8_t[]){0x4A}, 1, 0}, + {0x08, (uint8_t[]){0x4A}, 1, 0}, + {0x09, (uint8_t[]){0x44}, 1, 0}, + {0x0A, (uint8_t[]){0x44}, 1, 0}, + {0x0B, (uint8_t[]){0x46}, 1, 0}, + {0x0C, (uint8_t[]){0x46}, 1, 0}, + {0x0D, (uint8_t[]){0x5F}, 1, 0}, + {0x0E, (uint8_t[]){0x5F}, 1, 0}, + {0x0F, (uint8_t[]){0x57}, 1, 0}, + {0x10, (uint8_t[]){0x57}, 1, 0}, + {0x11, (uint8_t[]){0x77}, 1, 0}, + {0x12, (uint8_t[]){0x77}, 1, 0}, + {0x13, (uint8_t[]){0x40}, 1, 0}, + {0x14, (uint8_t[]){0x42}, 1, 0}, + {0x15, (uint8_t[]){0x5F}, 1, 0}, + + {0x16, (uint8_t[]){0x5F}, 1, 0}, + {0x17, (uint8_t[]){0x5F}, 1, 0}, + {0x18, (uint8_t[]){0x5E}, 1, 0}, + {0x19, (uint8_t[]){0x5E}, 1, 0}, + {0x1A, (uint8_t[]){0x50}, 1, 0}, + {0x1B, (uint8_t[]){0x49}, 1, 0}, + {0x1C, (uint8_t[]){0x49}, 1, 0}, + {0x1D, (uint8_t[]){0x4B}, 1, 0}, + {0x1E, (uint8_t[]){0x4B}, 1, 0}, + {0x1F, (uint8_t[]){0x45}, 1, 0}, + {0x20, (uint8_t[]){0x45}, 1, 0}, + {0x21, (uint8_t[]){0x47}, 1, 0}, + {0x22, (uint8_t[]){0x47}, 1, 0}, + {0x23, (uint8_t[]){0x5F}, 1, 0}, + {0x24, (uint8_t[]){0x5F}, 1, 0}, + {0x25, (uint8_t[]){0x57}, 1, 0}, + {0x26, (uint8_t[]){0x57}, 1, 0}, + {0x27, (uint8_t[]){0x77}, 1, 0}, + {0x28, (uint8_t[]){0x77}, 1, 0}, + {0x29, (uint8_t[]){0x41}, 1, 0}, + {0x2A, (uint8_t[]){0x43}, 1, 0}, + {0x2B, (uint8_t[]){0x5F}, 1, 0}, + + {0x2C, (uint8_t[]){0x1E}, 1, 0}, + {0x2D, (uint8_t[]){0x1E}, 1, 0}, + {0x2E, (uint8_t[]){0x1F}, 1, 0}, + {0x2F, (uint8_t[]){0x1F}, 1, 0}, + {0x30, (uint8_t[]){0x10}, 1, 0}, + {0x31, (uint8_t[]){0x07}, 1, 0}, + {0x32, (uint8_t[]){0x07}, 1, 0}, + {0x33, (uint8_t[]){0x05}, 1, 0}, + {0x34, (uint8_t[]){0x05}, 1, 0}, + {0x35, (uint8_t[]){0x0B}, 1, 0}, + {0x36, (uint8_t[]){0x0B}, 1, 0}, + {0x37, (uint8_t[]){0x09}, 1, 0}, + {0x38, (uint8_t[]){0x09}, 1, 0}, + {0x39, (uint8_t[]){0x1F}, 1, 0}, + {0x3A, (uint8_t[]){0x1F}, 1, 0}, + {0x3B, (uint8_t[]){0x17}, 1, 0}, + {0x3C, (uint8_t[]){0x17}, 1, 0}, + {0x3D, (uint8_t[]){0x17}, 1, 0}, + {0x3E, (uint8_t[]){0x17}, 1, 0}, + {0x3F, (uint8_t[]){0x03}, 1, 0}, + {0x40, (uint8_t[]){0x01}, 1, 0}, + {0x41, (uint8_t[]){0x1F}, 1, 0}, + + {0x42, (uint8_t[]){0x1E}, 1, 0}, + {0x43, (uint8_t[]){0x1E}, 1, 0}, + {0x44, (uint8_t[]){0x1F}, 1, 0}, + {0x45, (uint8_t[]){0x1F}, 1, 0}, + {0x46, (uint8_t[]){0x10}, 1, 0}, + {0x47, (uint8_t[]){0x06}, 1, 0}, + {0x48, (uint8_t[]){0x06}, 1, 0}, + {0x49, (uint8_t[]){0x04}, 1, 0}, + {0x4A, (uint8_t[]){0x04}, 1, 0}, + {0x4B, (uint8_t[]){0x0A}, 1, 0}, + {0x4C, (uint8_t[]){0x0A}, 1, 0}, + {0x4D, (uint8_t[]){0x08}, 1, 0}, + {0x4E, (uint8_t[]){0x08}, 1, 0}, + {0x4F, (uint8_t[]){0x1F}, 1, 0}, + {0x50, (uint8_t[]){0x1F}, 1, 0}, + {0x51, (uint8_t[]){0x17}, 1, 0}, + {0x52, (uint8_t[]){0x17}, 1, 0}, + {0x53, (uint8_t[]){0x17}, 1, 0}, + {0x54, (uint8_t[]){0x17}, 1, 0}, + {0x55, (uint8_t[]){0x02}, 1, 0}, + {0x56, (uint8_t[]){0x00}, 1, 0}, + {0x57, (uint8_t[]){0x1F}, 1, 0}, + + {0xE0, (uint8_t[]){0x02}, 1, 0}, + {0x58, (uint8_t[]){0x40}, 1, 0}, + {0x59, (uint8_t[]){0x00}, 1, 0}, + {0x5A, (uint8_t[]){0x00}, 1, 0}, + {0x5B, (uint8_t[]){0x30}, 1, 0}, + {0x5C, (uint8_t[]){0x01}, 1, 0}, + {0x5D, (uint8_t[]){0x30}, 1, 0}, + {0x5E, (uint8_t[]){0x01}, 1, 0}, + {0x5F, (uint8_t[]){0x02}, 1, 0}, + {0x60, (uint8_t[]){0x30}, 1, 0}, + {0x61, (uint8_t[]){0x03}, 1, 0}, + {0x62, (uint8_t[]){0x04}, 1, 0}, + {0x63, (uint8_t[]){0x04}, 1, 0}, + {0x64, (uint8_t[]){0xA6}, 1, 0}, + {0x65, (uint8_t[]){0x43}, 1, 0}, + {0x66, (uint8_t[]){0x30}, 1, 0}, + {0x67, (uint8_t[]){0x73}, 1, 0}, + {0x68, (uint8_t[]){0x05}, 1, 0}, + {0x69, (uint8_t[]){0x04}, 1, 0}, + {0x6A, (uint8_t[]){0x7F}, 1, 0}, + {0x6B, (uint8_t[]){0x08}, 1, 0}, + {0x6C, (uint8_t[]){0x00}, 1, 0}, + {0x6D, (uint8_t[]){0x04}, 1, 0}, + {0x6E, (uint8_t[]){0x04}, 1, 0}, + {0x6F, (uint8_t[]){0x88}, 1, 0}, + + {0x75, (uint8_t[]){0xD9}, 1, 0}, + {0x76, (uint8_t[]){0x00}, 1, 0}, + {0x77, (uint8_t[]){0x33}, 1, 0}, + {0x78, (uint8_t[]){0x43}, 1, 0}, + + {0xE0, (uint8_t[]){0x00}, 1, 0}, + + {0x11, (uint8_t[]){0x00}, 1, 120}, + + {0x29, (uint8_t[]){0x00}, 1, 20}, + {0x35, (uint8_t[]){0x00}, 1, 0}, +}; +#else +#define DISPLAY_WIDTH 720 +#define DISPLAY_HEIGHT 720 +static const jd9365_lcd_init_cmd_t lcd_init_cmds[] = { + {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[]){0x41}, 1, 0}, + {0x03, (uint8_t[]){0x10}, 1, 0}, + {0x04, (uint8_t[]){0x44}, 1, 0}, + + {0x17, (uint8_t[]){0x00}, 1, 0}, + {0x18, (uint8_t[]){0xD0}, 1, 0}, + {0x19, (uint8_t[]){0x00}, 1, 0}, + {0x1A, (uint8_t[]){0x00}, 1, 0}, + {0x1B, (uint8_t[]){0xD0}, 1, 0}, + {0x1C, (uint8_t[]){0x00}, 1, 0}, + + {0x24, (uint8_t[]){0xFE}, 1, 0}, + {0x35, (uint8_t[]){0x26}, 1, 0}, + + {0x37, (uint8_t[]){0x09}, 1, 0}, + + {0x38, (uint8_t[]){0x04}, 1, 0}, + {0x39, (uint8_t[]){0x08}, 1, 0}, + {0x3A, (uint8_t[]){0x0A}, 1, 0}, + {0x3C, (uint8_t[]){0x78}, 1, 0}, + {0x3D, (uint8_t[]){0xFF}, 1, 0}, + {0x3E, (uint8_t[]){0xFF}, 1, 0}, + {0x3F, (uint8_t[]){0xFF}, 1, 0}, + + {0x40, (uint8_t[]){0x04}, 1, 0}, + {0x41, (uint8_t[]){0x64}, 1, 0}, + {0x42, (uint8_t[]){0xC7}, 1, 0}, + {0x43, (uint8_t[]){0x18}, 1, 0}, + {0x44, (uint8_t[]){0x0B}, 1, 0}, + {0x45, (uint8_t[]){0x14}, 1, 0}, + + {0x55, (uint8_t[]){0x02}, 1, 0}, + {0x57, (uint8_t[]){0x49}, 1, 0}, + {0x59, (uint8_t[]){0x0A}, 1, 0}, + {0x5A, (uint8_t[]){0x1B}, 1, 0}, + {0x5B, (uint8_t[]){0x19}, 1, 0}, + + {0x5D, (uint8_t[]){0x7F}, 1, 0}, + {0x5E, (uint8_t[]){0x56}, 1, 0}, + {0x5F, (uint8_t[]){0x43}, 1, 0}, + {0x60, (uint8_t[]){0x37}, 1, 0}, + {0x61, (uint8_t[]){0x33}, 1, 0}, + {0x62, (uint8_t[]){0x25}, 1, 0}, + {0x63, (uint8_t[]){0x2A}, 1, 0}, + {0x64, (uint8_t[]){0x16}, 1, 0}, + {0x65, (uint8_t[]){0x30}, 1, 0}, + {0x66, (uint8_t[]){0x2F}, 1, 0}, + {0x67, (uint8_t[]){0x32}, 1, 0}, + {0x68, (uint8_t[]){0x53}, 1, 0}, + {0x69, (uint8_t[]){0x43}, 1, 0}, + {0x6A, (uint8_t[]){0x4C}, 1, 0}, + {0x6B, (uint8_t[]){0x40}, 1, 0}, + {0x6C, (uint8_t[]){0x3D}, 1, 0}, + {0x6D, (uint8_t[]){0x31}, 1, 0}, + {0x6E, (uint8_t[]){0x20}, 1, 0}, + {0x6F, (uint8_t[]){0x0F}, 1, 0}, + + {0x70, (uint8_t[]){0x7F}, 1, 0}, + {0x71, (uint8_t[]){0x56}, 1, 0}, + {0x72, (uint8_t[]){0x43}, 1, 0}, + {0x73, (uint8_t[]){0x37}, 1, 0}, + {0x74, (uint8_t[]){0x33}, 1, 0}, + {0x75, (uint8_t[]){0x25}, 1, 0}, + {0x76, (uint8_t[]){0x2A}, 1, 0}, + {0x77, (uint8_t[]){0x16}, 1, 0}, + {0x78, (uint8_t[]){0x30}, 1, 0}, + {0x79, (uint8_t[]){0x2F}, 1, 0}, + {0x7A, (uint8_t[]){0x32}, 1, 0}, + {0x7B, (uint8_t[]){0x53}, 1, 0}, + {0x7C, (uint8_t[]){0x43}, 1, 0}, + {0x7D, (uint8_t[]){0x4C}, 1, 0}, + {0x7E, (uint8_t[]){0x40}, 1, 0}, + {0x7F, (uint8_t[]){0x3D}, 1, 0}, + {0x80, (uint8_t[]){0x31}, 1, 0}, + {0x81, (uint8_t[]){0x20}, 1, 0}, + {0x82, (uint8_t[]){0x0F}, 1, 0}, + + {0xE0, (uint8_t[]){0x02}, 1, 0}, + {0x00, (uint8_t[]){0x5F}, 1, 0}, + {0x01, (uint8_t[]){0x5F}, 1, 0}, + {0x02, (uint8_t[]){0x5E}, 1, 0}, + {0x03, (uint8_t[]){0x5E}, 1, 0}, + {0x04, (uint8_t[]){0x50}, 1, 0}, + {0x05, (uint8_t[]){0x48}, 1, 0}, + {0x06, (uint8_t[]){0x48}, 1, 0}, + {0x07, (uint8_t[]){0x4A}, 1, 0}, + {0x08, (uint8_t[]){0x4A}, 1, 0}, + {0x09, (uint8_t[]){0x44}, 1, 0}, + {0x0A, (uint8_t[]){0x44}, 1, 0}, + {0x0B, (uint8_t[]){0x46}, 1, 0}, + {0x0C, (uint8_t[]){0x46}, 1, 0}, + {0x0D, (uint8_t[]){0x5F}, 1, 0}, + {0x0E, (uint8_t[]){0x5F}, 1, 0}, + {0x0F, (uint8_t[]){0x57}, 1, 0}, + {0x10, (uint8_t[]){0x57}, 1, 0}, + {0x11, (uint8_t[]){0x77}, 1, 0}, + {0x12, (uint8_t[]){0x77}, 1, 0}, + {0x13, (uint8_t[]){0x40}, 1, 0}, + {0x14, (uint8_t[]){0x42}, 1, 0}, + {0x15, (uint8_t[]){0x5F}, 1, 0}, + + {0x16, (uint8_t[]){0x5F}, 1, 0}, + {0x17, (uint8_t[]){0x5F}, 1, 0}, + {0x18, (uint8_t[]){0x5E}, 1, 0}, + {0x19, (uint8_t[]){0x5E}, 1, 0}, + {0x1A, (uint8_t[]){0x50}, 1, 0}, + {0x1B, (uint8_t[]){0x49}, 1, 0}, + {0x1C, (uint8_t[]){0x49}, 1, 0}, + {0x1D, (uint8_t[]){0x4B}, 1, 0}, + {0x1E, (uint8_t[]){0x4B}, 1, 0}, + {0x1F, (uint8_t[]){0x45}, 1, 0}, + {0x20, (uint8_t[]){0x45}, 1, 0}, + {0x21, (uint8_t[]){0x47}, 1, 0}, + {0x22, (uint8_t[]){0x47}, 1, 0}, + {0x23, (uint8_t[]){0x5F}, 1, 0}, + {0x24, (uint8_t[]){0x5F}, 1, 0}, + {0x25, (uint8_t[]){0x57}, 1, 0}, + {0x26, (uint8_t[]){0x57}, 1, 0}, + {0x27, (uint8_t[]){0x77}, 1, 0}, + {0x28, (uint8_t[]){0x77}, 1, 0}, + {0x29, (uint8_t[]){0x41}, 1, 0}, + {0x2A, (uint8_t[]){0x43}, 1, 0}, + {0x2B, (uint8_t[]){0x5F}, 1, 0}, + + {0x2C, (uint8_t[]){0x1E}, 1, 0}, + {0x2D, (uint8_t[]){0x1E}, 1, 0}, + {0x2E, (uint8_t[]){0x1F}, 1, 0}, + {0x2F, (uint8_t[]){0x1F}, 1, 0}, + {0x30, (uint8_t[]){0x10}, 1, 0}, + {0x31, (uint8_t[]){0x07}, 1, 0}, + {0x32, (uint8_t[]){0x07}, 1, 0}, + {0x33, (uint8_t[]){0x05}, 1, 0}, + {0x34, (uint8_t[]){0x05}, 1, 0}, + {0x35, (uint8_t[]){0x0B}, 1, 0}, + {0x36, (uint8_t[]){0x0B}, 1, 0}, + {0x37, (uint8_t[]){0x09}, 1, 0}, + {0x38, (uint8_t[]){0x09}, 1, 0}, + {0x39, (uint8_t[]){0x1F}, 1, 0}, + {0x3A, (uint8_t[]){0x1F}, 1, 0}, + {0x3B, (uint8_t[]){0x17}, 1, 0}, + {0x3C, (uint8_t[]){0x17}, 1, 0}, + {0x3D, (uint8_t[]){0x17}, 1, 0}, + {0x3E, (uint8_t[]){0x17}, 1, 0}, + {0x3F, (uint8_t[]){0x03}, 1, 0}, + {0x40, (uint8_t[]){0x01}, 1, 0}, + {0x41, (uint8_t[]){0x1F}, 1, 0}, + + {0x42, (uint8_t[]){0x1E}, 1, 0}, + {0x43, (uint8_t[]){0x1E}, 1, 0}, + {0x44, (uint8_t[]){0x1F}, 1, 0}, + {0x45, (uint8_t[]){0x1F}, 1, 0}, + {0x46, (uint8_t[]){0x10}, 1, 0}, + {0x47, (uint8_t[]){0x06}, 1, 0}, + {0x48, (uint8_t[]){0x06}, 1, 0}, + {0x49, (uint8_t[]){0x04}, 1, 0}, + {0x4A, (uint8_t[]){0x04}, 1, 0}, + {0x4B, (uint8_t[]){0x0A}, 1, 0}, + {0x4C, (uint8_t[]){0x0A}, 1, 0}, + {0x4D, (uint8_t[]){0x08}, 1, 0}, + {0x4E, (uint8_t[]){0x08}, 1, 0}, + {0x4F, (uint8_t[]){0x1F}, 1, 0}, + {0x50, (uint8_t[]){0x1F}, 1, 0}, + {0x51, (uint8_t[]){0x17}, 1, 0}, + {0x52, (uint8_t[]){0x17}, 1, 0}, + {0x53, (uint8_t[]){0x17}, 1, 0}, + {0x54, (uint8_t[]){0x17}, 1, 0}, + {0x55, (uint8_t[]){0x02}, 1, 0}, + {0x56, (uint8_t[]){0x00}, 1, 0}, + {0x57, (uint8_t[]){0x1F}, 1, 0}, + + {0xE0, (uint8_t[]){0x02}, 1, 0}, + {0x58, (uint8_t[]){0x40}, 1, 0}, + {0x59, (uint8_t[]){0x00}, 1, 0}, + {0x5A, (uint8_t[]){0x00}, 1, 0}, + {0x5B, (uint8_t[]){0x30}, 1, 0}, + {0x5C, (uint8_t[]){0x01}, 1, 0}, + {0x5D, (uint8_t[]){0x30}, 1, 0}, + {0x5E, (uint8_t[]){0x01}, 1, 0}, + {0x5F, (uint8_t[]){0x02}, 1, 0}, + {0x60, (uint8_t[]){0x30}, 1, 0}, + {0x61, (uint8_t[]){0x03}, 1, 0}, + {0x62, (uint8_t[]){0x04}, 1, 0}, + {0x63, (uint8_t[]){0x04}, 1, 0}, + {0x64, (uint8_t[]){0xA6}, 1, 0}, + {0x65, (uint8_t[]){0x43}, 1, 0}, + {0x66, (uint8_t[]){0x30}, 1, 0}, + {0x67, (uint8_t[]){0x73}, 1, 0}, + {0x68, (uint8_t[]){0x05}, 1, 0}, + {0x69, (uint8_t[]){0x04}, 1, 0}, + {0x6A, (uint8_t[]){0x7F}, 1, 0}, + {0x6B, (uint8_t[]){0x08}, 1, 0}, + {0x6C, (uint8_t[]){0x00}, 1, 0}, + {0x6D, (uint8_t[]){0x04}, 1, 0}, + {0x6E, (uint8_t[]){0x04}, 1, 0}, + {0x6F, (uint8_t[]){0x88}, 1, 0}, + + {0x75, (uint8_t[]){0xD9}, 1, 0}, + {0x76, (uint8_t[]){0x00}, 1, 0}, + {0x77, (uint8_t[]){0x33}, 1, 0}, + {0x78, (uint8_t[]){0x43}, 1, 0}, + + {0xE0, (uint8_t[]){0x00}, 1, 0}, + {0x11, (uint8_t[]){0x00}, 1, 120}, + + {0x29, (uint8_t[]){0x00}, 1, 20}, + {0x35, (uint8_t[]){0x00}, 1, 0}, +}; +#endif + +#endif // _BOARD_CONFIG_H_ diff --git a/main/boards/waveshare-p4-wifi6-touch-lcd-xc/esp32-p4-wifi6-touch-lcd-xc.cc b/main/boards/waveshare-p4-wifi6-touch-lcd-xc/esp32-p4-wifi6-touch-lcd-xc.cc new file mode 100644 index 00000000..5012bdb7 --- /dev/null +++ b/main/boards/waveshare-p4-wifi6-touch-lcd-xc/esp32-p4-wifi6-touch-lcd-xc.cc @@ -0,0 +1,213 @@ +#include "wifi_board.h" +#include "audio_codecs/box_audio_codec.h" +#include "application.h" +#include "display/lcd_display.h" +// #include "display/no_display.h" +#include "button.h" +#include "iot/thing_manager.h" + +#include "esp_lcd_panel_ops.h" +#include "esp_lcd_mipi_dsi.h" +#include "esp_ldo_regulator.h" + +#include "esp_lcd_jd9365_10_1.h" +#include "config.h" + +#include +#include +#include +#include +#include "esp_lcd_touch_gt911.h" +#define TAG "WaveshareEsp32p4xc" + +LV_FONT_DECLARE(font_puhui_30_4); +LV_FONT_DECLARE(font_awesome_30_4); + +class WaveshareEsp32p4xc : public WifiBoard { +private: + i2c_master_bus_handle_t i2c_bus_; + Button boot_button_; + LcdDisplay *display_; + + void InitializeCodecI2c() { + // Initialize I2C peripheral + i2c_master_bus_config_t i2c_bus_cfg = { + .i2c_port = I2C_NUM_1, + .sda_io_num = AUDIO_CODEC_I2C_SDA_PIN, + .scl_io_num = AUDIO_CODEC_I2C_SCL_PIN, + .clk_source = I2C_CLK_SRC_DEFAULT, + .glitch_ignore_cnt = 7, + .intr_priority = 0, + .trans_queue_depth = 0, + .flags = { + .enable_internal_pullup = 1, + }, + }; + ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_cfg, &i2c_bus_)); + } + + static esp_err_t bsp_enable_dsi_phy_power(void) { +#if MIPI_DSI_PHY_PWR_LDO_CHAN > 0 + // Turn on the power for MIPI DSI PHY, so it can go from "No Power" state to "Shutdown" state + static esp_ldo_channel_handle_t phy_pwr_chan = NULL; + esp_ldo_channel_config_t ldo_cfg = { + .chan_id = MIPI_DSI_PHY_PWR_LDO_CHAN, + .voltage_mv = MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV, + }; + esp_ldo_acquire_channel(&ldo_cfg, &phy_pwr_chan); + ESP_LOGI(TAG, "MIPI DSI PHY Powered on"); +#endif // BSP_MIPI_DSI_PHY_PWR_LDO_CHAN > 0 + + return ESP_OK; + } + + void InitializeLCD() { + bsp_enable_dsi_phy_power(); + esp_lcd_panel_io_handle_t io = NULL; + esp_lcd_panel_handle_t disp_panel = NULL; + + esp_lcd_dsi_bus_handle_t mipi_dsi_bus = NULL; + esp_lcd_dsi_bus_config_t bus_config = JD9365_PANEL_BUS_DSI_2CH_CONFIG(); + esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus); + + ESP_LOGI(TAG, "Install MIPI DSI LCD control panel"); + // we use DBI interface to send LCD commands and parameters + esp_lcd_dbi_io_config_t dbi_config = JD9365_PANEL_IO_DBI_CONFIG(); + esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io); + + esp_lcd_dpi_panel_config_t dpi_config = { + .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, + .dpi_clock_freq_mhz = 46, + .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565, + .num_fbs = 1, + .video_timing = { + .h_size = DISPLAY_WIDTH, + .v_size = DISPLAY_HEIGHT, + .hsync_pulse_width = 20, + .hsync_back_porch = 20, + .hsync_front_porch = 40, + .vsync_pulse_width = 4, + .vsync_back_porch = 12, + .vsync_front_porch = 24, + }, + .flags = { + .use_dma2d = true, + }, + }; + jd9365_vendor_config_t vendor_config = { + .init_cmds = lcd_init_cmds, + .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(lcd_init_cmds[0]), + .mipi_config = { + .dsi_bus = mipi_dsi_bus, + .dpi_config = &dpi_config, + .lane_num = 2, + }, + .flags = { + .use_mipi_interface = 1, + }, + }; + + const esp_lcd_panel_dev_config_t lcd_dev_config = { + .reset_gpio_num = PIN_NUM_LCD_RST, + .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, + .bits_per_pixel = 16, + .vendor_config = &vendor_config, + }; + esp_lcd_new_panel_jd9365(io, &lcd_dev_config, &disp_panel); + esp_lcd_panel_reset(disp_panel); + esp_lcd_panel_init(disp_panel); + + display_ = new MipiLcdDisplay(io, disp_panel, DISPLAY_WIDTH, DISPLAY_HEIGHT, + DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, + { + .text_font = &font_puhui_30_4, + .icon_font = &font_awesome_30_4, + .emoji_font = font_emoji_64_init(), + }); + } + void InitializeTouch() + { + esp_lcd_touch_handle_t tp; + esp_lcd_touch_config_t tp_cfg = { + .x_max = DISPLAY_WIDTH, + .y_max = DISPLAY_HEIGHT, + .rst_gpio_num = GPIO_NUM_23, + .int_gpio_num = GPIO_NUM_NC, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 0, + .mirror_y = 0, + }, + }; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); + tp_io_config.scl_speed_hz = 400 * 1000; + ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus_, &tp_io_config, &tp_io_handle)); + ESP_LOGI(TAG, "Initialize touch controller"); + ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp)); + const lvgl_port_touch_cfg_t touch_cfg = { + .disp = lv_display_get_default(), + .handle = tp, + }; + lvgl_port_add_touch(&touch_cfg); + ESP_LOGI(TAG, "Touch panel initialized successfully"); + } + void InitializeButtons() { + boot_button_.OnClick([this]() { + auto& app = Application::GetInstance(); + if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) { + ResetWifiConfiguration(); + } + app.ToggleChatState(); }); + } + + // 物联网初始化,添加对 AI 可见设备 + void InitializeIot() { + auto &thing_manager = iot::ThingManager::GetInstance(); + thing_manager.AddThing(iot::CreateThing("Speaker")); + thing_manager.AddThing(iot::CreateThing("Screen")); + } + +public: + WaveshareEsp32p4xc() : + boot_button_(BOOT_BUTTON_GPIO) { + InitializeCodecI2c(); + InitializeIot(); + InitializeLCD(); + InitializeTouch(); + InitializeButtons(); + GetBacklight()->RestoreBrightness(); + } + + virtual AudioCodec* GetAudioCodec() override { + static BoxAudioCodec audio_codec( + i2c_bus_, + AUDIO_INPUT_SAMPLE_RATE, + AUDIO_OUTPUT_SAMPLE_RATE, + AUDIO_I2S_GPIO_MCLK, + AUDIO_I2S_GPIO_BCLK, + AUDIO_I2S_GPIO_WS, + AUDIO_I2S_GPIO_DOUT, + AUDIO_I2S_GPIO_DIN, + AUDIO_CODEC_PA_PIN, + AUDIO_CODEC_ES8311_ADDR, + AUDIO_CODEC_ES7210_ADDR, + AUDIO_INPUT_REFERENCE); + return &audio_codec; + } + + virtual Display *GetDisplay() override { + return display_; + } + + virtual Backlight* GetBacklight() override { + static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT); + return &backlight; + } +}; + +DECLARE_BOARD(WaveshareEsp32p4xc); diff --git a/main/idf_component.yml b/main/idf_component.yml index 22f3172f..212eacb1 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -34,6 +34,10 @@ dependencies: version: '*' rules: - if: target in [esp32p4] + waveshare/esp_lcd_st7703: + version: '*' + rules: + - if: target in [esp32p4] espressif/esp_lcd_ili9881c: version: ^1.0.1 rules: