mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-01-13 16:57:17 +08:00
ESP-P4-Function-EV-Board add SD card, camera, and font initialization (#1403)
* feat: add support for ESP32-P4-Function-EV-Board with configuration and display handling * detect wake word model from index.json * update wait time before entering wifi configure mode * feat: Enhance ESP32-P4 Function EV Board support with LCD and touch initialization * feat: Update ESP32-P4 Function EV Board configuration for improved touch and SD card support * feat: add touch I2C configuration and improve initialization structure * Remove ESP hosted configuration from defaults Removed ESP hosted configuration options. * chore: update documentation for improved clarity * refactor: remove obsolete files for ESP32-P4-Function-EV-Board and add updated configurations * refactor: reintroduce ESP32-P4-Function-EV-Board implementation with updated configurations * refactor: restore esp32_p4_function_ev_board dependency with updated version * Remove ESP-P4-Function-EV-Board configuration and update README with detailed features; add SD card, camera, and font initialization in esp-p4-function-ev-board.cc * Update main/boards/esp-p4-function-ev-board/esp-p4-function-ev-board.cc Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update main/boards/esp-p4-function-ev-board/esp-p4-function-ev-board.cc Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Enhance camera initialization in ESP-P4-Function-EV-Board; add fallback configuration for direct camera setup and update README for clarity * Update clock source for MIPI DSI configuration in ESP-P4-Function-EV-Board --------- Co-authored-by: n2flowjs-bot <n2flowjs@gmail.com> Co-authored-by: Terrence <terrence@tenclass.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
cdb025dd90
commit
06da25fd26
@ -5,7 +5,13 @@ Board support for ESP-P4-Function-EV-Board. Wi‑Fi uses ESP‑Hosted via the on
|
||||
## Features
|
||||
- Wi‑Fi: `esp_wifi_remote` + `esp_hosted` (SDIO) with ESP32‑C6 co‑processor
|
||||
- Display: 7" MIPI‑DSI LCD (1024×600) via adapter; can also run headless
|
||||
- Audio: Can run with dummy codec; board includes ES8311 + PA if needed
|
||||
- Audio: ES8311 codec with speaker and microphone support
|
||||
- Touch: GT911 capacitive touch controller
|
||||
- SD Card: MicroSD card support (MMC mode)
|
||||
- Camera: MIPI-CSI camera interface with fallback DVP configuration (OV5647, SC2336 sensors supported)
|
||||
- USB: USB host/device support
|
||||
- SPIFFS: Built-in flash filesystem support
|
||||
- Fonts: Custom font support with Unicode characters (Vietnamese, Chinese, etc.)
|
||||
|
||||
## Configure
|
||||
In `menuconfig`: Xiaozhi Assistant -> Board Type -> ESP-P4-Function-EV-Board
|
||||
|
||||
@ -3,18 +3,21 @@
|
||||
// Display
|
||||
#include "display/display.h"
|
||||
#include "display/lcd_display.h"
|
||||
#include "lvgl_theme.h"
|
||||
// Backlight
|
||||
// PwmBacklight is declared in backlight headers pulled by display/lcd_display includes via lvgl stack
|
||||
|
||||
#include "application.h"
|
||||
#include "button.h"
|
||||
#include "config.h"
|
||||
#include "esp32_camera.h"
|
||||
|
||||
#include <wifi_station.h>
|
||||
#include <esp_log.h>
|
||||
#include <inttypes.h>
|
||||
#include <driver/i2c_master.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
#include <soc/clk_tree_defs.h>
|
||||
// SD card
|
||||
#include <esp_vfs_fat.h>
|
||||
#include <sdmmc_cmd.h>
|
||||
@ -43,6 +46,7 @@ private:
|
||||
Button boot_button_;
|
||||
LcdDisplay *display_ = nullptr;
|
||||
esp_lcd_touch_handle_t tp_ = nullptr;
|
||||
Esp32Camera* camera_ = nullptr;
|
||||
|
||||
void InitializeI2cBuses()
|
||||
{
|
||||
@ -61,7 +65,7 @@ private:
|
||||
bsp_display_config_t config = {
|
||||
.hdmi_resolution = BSP_HDMI_RES_NONE,
|
||||
.dsi_bus = {
|
||||
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
|
||||
.phy_clk_src = (mipi_dsi_phy_clock_source_t)SOC_MOD_CLK_PLL_F20M,
|
||||
.lane_bit_rate_mbps = 1000,
|
||||
},
|
||||
};
|
||||
@ -88,6 +92,92 @@ private:
|
||||
ESP_ERROR_CHECK(bsp_touch_new(NULL, &tp_));
|
||||
}
|
||||
|
||||
void InitializeSdCard()
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing SD card");
|
||||
esp_err_t ret = bsp_sdcard_mount();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to mount SD card: %s", esp_err_to_name(ret));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "SD card mounted successfully");
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeCamera()
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing camera");
|
||||
|
||||
// Use BSP camera initialization for ESP-P4
|
||||
bsp_camera_cfg_t camera_cfg = {0};
|
||||
esp_err_t ret = bsp_camera_start(&camera_cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize BSP camera: %s", esp_err_to_name(ret));
|
||||
ESP_LOGI(TAG, "Attempting alternative camera initialization");
|
||||
|
||||
// Alternative: Direct Esp32Camera initialization if BSP fails
|
||||
// This provides more control over camera configuration
|
||||
static esp_cam_ctlr_dvp_pin_config_t dvp_pin_config = {
|
||||
.data_width = CAM_CTLR_DATA_WIDTH_8,
|
||||
.data_io = {
|
||||
[0] = BSP_I2C_SDA, // Reuse I2C pins if camera pins not defined
|
||||
[1] = BSP_I2C_SCL,
|
||||
[2] = GPIO_NUM_NC,
|
||||
[3] = GPIO_NUM_NC,
|
||||
[4] = GPIO_NUM_NC,
|
||||
[5] = GPIO_NUM_NC,
|
||||
[6] = GPIO_NUM_NC,
|
||||
[7] = GPIO_NUM_NC,
|
||||
},
|
||||
.vsync_io = GPIO_NUM_NC,
|
||||
.de_io = GPIO_NUM_NC,
|
||||
.pclk_io = GPIO_NUM_NC,
|
||||
.xclk_io = GPIO_NUM_NC,
|
||||
};
|
||||
|
||||
esp_video_init_sccb_config_t sccb_config = {
|
||||
.init_sccb = false, // Use existing I2C bus
|
||||
.i2c_handle = codec_i2c_bus_, // Reuse the existing I2C bus
|
||||
.freq = 100000,
|
||||
};
|
||||
|
||||
esp_video_init_dvp_config_t dvp_config = {
|
||||
.sccb_config = sccb_config,
|
||||
.reset_pin = GPIO_NUM_NC,
|
||||
.pwdn_pin = GPIO_NUM_NC,
|
||||
.dvp_pin = dvp_pin_config,
|
||||
.xclk_freq = 20000000, // 20MHz typical for cameras
|
||||
};
|
||||
|
||||
esp_video_init_config_t video_config = {
|
||||
.dvp = &dvp_config,
|
||||
};
|
||||
|
||||
// Try to create camera with direct configuration
|
||||
camera_ = new Esp32Camera(video_config);
|
||||
ESP_LOGI(TAG, "Camera initialized with direct configuration");
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Camera initialized successfully via BSP");
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeFonts()
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing font support");
|
||||
// Font initialization is handled by the Assets system
|
||||
// The board supports loading fonts from assets partition
|
||||
// Verify that fonts are properly loaded by checking theme
|
||||
auto& theme_manager = LvglThemeManager::GetInstance();
|
||||
auto current_theme = theme_manager.GetTheme("light");
|
||||
if (current_theme != nullptr) {
|
||||
auto text_font = current_theme->text_font();
|
||||
if (text_font != nullptr && text_font->font() != nullptr) {
|
||||
ESP_LOGI(TAG, "Custom font loaded successfully: line_height=%d", text_font->font()->line_height);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Custom font not loaded, using built-in font");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
ESP32P4FunctionEvBoard() : boot_button_(0)
|
||||
@ -97,6 +187,9 @@ public:
|
||||
InitializeLCD();
|
||||
InitializeButtons();
|
||||
InitializeTouch();
|
||||
InitializeSdCard();
|
||||
InitializeCamera();
|
||||
InitializeFonts();
|
||||
GetBacklight()->RestoreBrightness();
|
||||
}
|
||||
|
||||
@ -105,6 +198,11 @@ public:
|
||||
// Clean up display pointer
|
||||
delete display_;
|
||||
display_ = nullptr;
|
||||
// Unmount SD card
|
||||
esp_err_t ret = bsp_sdcard_unmount();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to unmount SD card: %s", esp_err_to_name(ret));
|
||||
}
|
||||
// If other resources need cleanup, add here
|
||||
}
|
||||
|
||||
@ -124,6 +222,11 @@ public:
|
||||
static PwmBacklight backlight(BSP_LCD_BACKLIGHT, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
|
||||
return &backlight;
|
||||
}
|
||||
|
||||
virtual Camera *GetCamera() override
|
||||
{
|
||||
return camera_;
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_BOARD(ESP32P4FunctionEvBoard);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user