forked from xiaozhi/xiaozhi-esp32
feat: add camera support for M5Stack Tab5 (#1442)
This commit is contained in:
@@ -10,22 +10,36 @@
|
|||||||
|
|
||||||
* idf version: v6.0-dev
|
* idf version: v6.0-dev
|
||||||
|
|
||||||
1. 设置编译目标为 esp32p4
|
1. 调整 idf_component.yml
|
||||||
|
|
||||||
```shell
|
将
|
||||||
idf.py set-target esp32p4
|
```yaml
|
||||||
|
espressif/esp_video:
|
||||||
|
version: ==1.3.1 # for compatibility. update version may need to modify this project code.
|
||||||
|
rules:
|
||||||
|
- if: target not in [esp32]
|
||||||
|
```
|
||||||
|
修改为
|
||||||
|
```yaml
|
||||||
|
espressif/esp_video:
|
||||||
|
version: '==0.7.0'
|
||||||
|
rules:
|
||||||
|
- if: target not in [esp32]
|
||||||
|
espressif/esp_ipa: '==0.1.0'
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 修改配置
|
2. 使用 release.py 编译
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cp main/boards/m5stack-tab5/sdkconfig.tab5 sdkconfig
|
python ./scripts/release.py m5stack-tab5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
如需手动编译,请参考 `m5stack-tab5/config.json` 修改 menuconfig 对应选项。
|
||||||
|
|
||||||
3. 编译烧录程序
|
3. 编译烧录程序
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
idf.py build flash monitor
|
idf.py flash monitor
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
|
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
|
||||||
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
|
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
// 摄像头相关参数配置
|
||||||
|
#define CAMERA_SCL GPIO_NUM_32
|
||||||
|
#define CAMERA_SDA GPIO_NUM_31
|
||||||
|
#define CAMERA_MCLK GPIO_NUM_36
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
// 显示屏相关参数配置
|
// 显示屏相关参数配置
|
||||||
#define DISPLAY_WIDTH 720
|
#define DISPLAY_WIDTH 720
|
||||||
|
|||||||
19
main/boards/m5stack-tab5/config.json
Normal file
19
main/boards/m5stack-tab5/config.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"target": "esp32p4",
|
||||||
|
"builds": [
|
||||||
|
{
|
||||||
|
"name": "m5stack-tab5",
|
||||||
|
"sdkconfig_append": [
|
||||||
|
"CONFIG_BOARD_TYPE_M5STACK_CORE_TAB5=y",
|
||||||
|
"CONFIG_CAMERA_SC202CS=y",
|
||||||
|
"CONFIG_XIAOZHI_ENABLE_ROTATE_CAMERA_IMAGE=y",
|
||||||
|
"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_CMD_SLOT_1=13",
|
||||||
|
"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_CLK_SLOT_1=12",
|
||||||
|
"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D0_SLOT_1=11",
|
||||||
|
"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D1_4BIT_BUS_SLOT_1=10",
|
||||||
|
"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D2_4BIT_BUS_SLOT_1=9",
|
||||||
|
"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D3_4BIT_BUS_SLOT_1=8"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -7,6 +7,9 @@
|
|||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "esp32_camera.h"
|
||||||
|
#include "esp_video_init.h"
|
||||||
|
#include "esp_cam_sensor_xclk.h"
|
||||||
|
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
@@ -87,6 +90,7 @@ private:
|
|||||||
i2c_master_bus_handle_t i2c_bus_;
|
i2c_master_bus_handle_t i2c_bus_;
|
||||||
Button boot_button_;
|
Button boot_button_;
|
||||||
LcdDisplay* display_;
|
LcdDisplay* display_;
|
||||||
|
Esp32Camera* camera_ = nullptr;
|
||||||
Pi4ioe1* pi4ioe1_;
|
Pi4ioe1* pi4ioe1_;
|
||||||
Pi4ioe2* pi4ioe2_;
|
Pi4ioe2* pi4ioe2_;
|
||||||
esp_lcd_touch_handle_t touch_ = nullptr;
|
esp_lcd_touch_handle_t touch_ = nullptr;
|
||||||
@@ -422,12 +426,53 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeCamera() {
|
||||||
|
esp_cam_sensor_xclk_handle_t xclk_handle = NULL;
|
||||||
|
esp_cam_sensor_xclk_config_t cam_xclk_config = {};
|
||||||
|
|
||||||
|
#if CONFIG_CAMERA_XCLK_USE_ESP_CLOCK_ROUTER
|
||||||
|
if (esp_cam_sensor_xclk_allocate(ESP_CAM_SENSOR_XCLK_ESP_CLOCK_ROUTER, &xclk_handle) == ESP_OK) {
|
||||||
|
cam_xclk_config.esp_clock_router_cfg.xclk_pin = CAMERA_MCLK;
|
||||||
|
cam_xclk_config.esp_clock_router_cfg.xclk_freq_hz = 12000000; // 12MHz
|
||||||
|
(void)esp_cam_sensor_xclk_start(xclk_handle, &cam_xclk_config);
|
||||||
|
}
|
||||||
|
#elif CONFIG_CAMERA_XCLK_USE_LEDC
|
||||||
|
if (esp_cam_sensor_xclk_allocate(ESP_CAM_SENSOR_XCLK_LEDC, &xclk_handle) == ESP_OK) {
|
||||||
|
cam_xclk_config.ledc_cfg.timer = LEDC_TIMER_0;
|
||||||
|
cam_xclk_config.ledc_cfg.clk_cfg = LEDC_AUTO_CLK;
|
||||||
|
cam_xclk_config.ledc_cfg.channel = LEDC_CHANNEL_0;
|
||||||
|
cam_xclk_config.ledc_cfg.xclk_freq_hz = 12000000; // 12MHz
|
||||||
|
cam_xclk_config.ledc_cfg.xclk_pin = CAMERA_MCLK;
|
||||||
|
(void)esp_cam_sensor_xclk_start(xclk_handle, &cam_xclk_config);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
esp_video_init_sccb_config_t sccb_config = {
|
||||||
|
.init_sccb = false,
|
||||||
|
.i2c_handle = i2c_bus_,
|
||||||
|
.freq = 400000,
|
||||||
|
};
|
||||||
|
|
||||||
|
esp_video_init_csi_config_t csi_config = {
|
||||||
|
.sccb_config = sccb_config,
|
||||||
|
.reset_pin = GPIO_NUM_NC,
|
||||||
|
.pwdn_pin = GPIO_NUM_NC,
|
||||||
|
};
|
||||||
|
|
||||||
|
esp_video_init_config_t video_config = {
|
||||||
|
.csi = &csi_config,
|
||||||
|
};
|
||||||
|
|
||||||
|
camera_ = new Esp32Camera(video_config);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
M5StackTab5Board() : boot_button_(BOOT_BUTTON_GPIO) {
|
M5StackTab5Board() : boot_button_(BOOT_BUTTON_GPIO) {
|
||||||
InitializeI2c();
|
InitializeI2c();
|
||||||
I2cDetect();
|
I2cDetect();
|
||||||
InitializePi4ioe();
|
InitializePi4ioe();
|
||||||
InitializeDisplay(); // Auto-detect and initialize display + touch
|
InitializeDisplay(); // Auto-detect and initialize display + touch
|
||||||
|
InitializeCamera();
|
||||||
InitializeButtons();
|
InitializeButtons();
|
||||||
SetChargeQcEn(true);
|
SetChargeQcEn(true);
|
||||||
SetChargeEn(true);
|
SetChargeEn(true);
|
||||||
@@ -456,6 +501,10 @@ public:
|
|||||||
return display_;
|
return display_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual Camera* GetCamera() override {
|
||||||
|
return camera_;
|
||||||
|
}
|
||||||
|
|
||||||
virtual Backlight* GetBacklight() override {
|
virtual Backlight* GetBacklight() override {
|
||||||
static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
|
static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
|
||||||
return &backlight;
|
return &backlight;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,10 @@ dependencies:
|
|||||||
espressif2022/esp_emote_gfx: ^1.1.2
|
espressif2022/esp_emote_gfx: ^1.1.2
|
||||||
espressif/adc_mic: ^0.2.1
|
espressif/adc_mic: ^0.2.1
|
||||||
espressif/esp_mmap_assets: '>=1.2'
|
espressif/esp_mmap_assets: '>=1.2'
|
||||||
txp666/otto-emoji-gif-component: ^1.0.3
|
txp666/otto-emoji-gif-component:
|
||||||
|
version: ^1.0.3
|
||||||
|
rules:
|
||||||
|
- if: target in [esp32s3]
|
||||||
espressif/adc_battery_estimation: ^0.2.0
|
espressif/adc_battery_estimation: ^0.2.0
|
||||||
espressif/esp_new_jpeg: ^0.6.1
|
espressif/esp_new_jpeg: ^0.6.1
|
||||||
|
|
||||||
|
|||||||
@@ -22,5 +22,9 @@ CONFIG_SR_WN_WN9_NIHAOXIAOZHI_TTS=y
|
|||||||
|
|
||||||
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
|
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
|
||||||
|
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||||
|
|
||||||
|
CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y
|
||||||
|
|
||||||
# LVGL Graphics
|
# LVGL Graphics
|
||||||
CONFIG_LV_USE_SNAPSHOT=y
|
CONFIG_LV_USE_SNAPSHOT=y
|
||||||
|
|||||||
Reference in New Issue
Block a user