forked from xiaozhi/xiaozhi-esp32
main/boards: Add camera support for M5Stack CoreS3. (#686)
This commit is contained in:
@@ -1,31 +1,26 @@
|
||||
# 编译配置命令
|
||||
# 使用说明
|
||||
|
||||
**配置编译目标为 ESP32S3:**
|
||||
|
||||
```bash
|
||||
1. 设置编译目标为 esp32s3
|
||||
|
||||
```shell
|
||||
idf.py set-target esp32s3
|
||||
```
|
||||
|
||||
**打开 menuconfig:**
|
||||
2. 修改配置
|
||||
|
||||
```bash
|
||||
idf.py menuconfig
|
||||
```shell
|
||||
cp main/boards/m5stack-core-s3/sdkconfig.cores3 sdkconfig
|
||||
```
|
||||
|
||||
**选择板子:**
|
||||
3. 编译烧录程序
|
||||
|
||||
```
|
||||
Xiaozhi Assistant -> Board Type -> M5Stack CoreS3
|
||||
```shell
|
||||
idf.py build flash monitor
|
||||
```
|
||||
|
||||
**修改 psram 配置:**
|
||||
> [!NOTE]
|
||||
> 进入下载模式:长按复位按键(约3秒),直至内部指示灯亮绿色,松开按键。
|
||||
|
||||
```
|
||||
Component config -> ESP PSRAM -> SPI RAM config -> Mode (QUAD/OCT) -> Quad Mode PSRAM
|
||||
```
|
||||
|
||||
**编译:**
|
||||
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
|
||||
|
||||
@@ -40,4 +40,27 @@
|
||||
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT true
|
||||
|
||||
|
||||
|
||||
/* Camera pins */
|
||||
#define CAMERA_PIN_PWDN GPIO_NUM_NC
|
||||
#define CAMERA_PIN_RESET GPIO_NUM_NC
|
||||
#define CAMERA_PIN_XCLK GPIO_NUM_NC // 像素时钟 (固定由 20MHz 外部晶振输入)
|
||||
#define CAMERA_PIN_SIOD GPIO_NUM_NC // 串行时钟 Using existing I2C port
|
||||
#define CAMERA_PIN_SIOC GPIO_NUM_NC // 串行时钟 Using existing I2C port
|
||||
#define CAMERA_PIN_D0 GPIO_NUM_39
|
||||
#define CAMERA_PIN_D1 GPIO_NUM_40
|
||||
#define CAMERA_PIN_D2 GPIO_NUM_41
|
||||
#define CAMERA_PIN_D3 GPIO_NUM_42
|
||||
#define CAMERA_PIN_D4 GPIO_NUM_15
|
||||
#define CAMERA_PIN_D5 GPIO_NUM_16
|
||||
#define CAMERA_PIN_D6 GPIO_NUM_48
|
||||
#define CAMERA_PIN_D7 GPIO_NUM_47
|
||||
#define CAMERA_PIN_VSYNC GPIO_NUM_46
|
||||
#define CAMERA_PIN_HREF GPIO_NUM_38
|
||||
#define CAMERA_PIN_PCLK GPIO_NUM_45
|
||||
|
||||
#define XCLK_FREQ_HZ 20000000
|
||||
|
||||
|
||||
|
||||
#endif // _BOARD_CONFIG_H_
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include <esp_lcd_ili9341.h>
|
||||
#include <esp_timer.h>
|
||||
#include "esp32_camera.h"
|
||||
|
||||
|
||||
#define TAG "M5StackCoreS3Board"
|
||||
|
||||
@@ -130,6 +132,7 @@ private:
|
||||
Aw9523* aw9523_;
|
||||
Ft6336* ft6336_;
|
||||
LcdDisplay* display_;
|
||||
Esp32Camera* camera_;
|
||||
esp_timer_handle_t touchpad_timer_;
|
||||
PowerSaveTimer* power_save_timer_;
|
||||
|
||||
@@ -309,6 +312,36 @@ private:
|
||||
});
|
||||
}
|
||||
|
||||
void InitializeCamera() {
|
||||
// Open camera power
|
||||
camera_config_t config = {};
|
||||
config.pin_d0 = CAMERA_PIN_D0;
|
||||
config.pin_d1 = CAMERA_PIN_D1;
|
||||
config.pin_d2 = CAMERA_PIN_D2;
|
||||
config.pin_d3 = CAMERA_PIN_D3;
|
||||
config.pin_d4 = CAMERA_PIN_D4;
|
||||
config.pin_d5 = CAMERA_PIN_D5;
|
||||
config.pin_d6 = CAMERA_PIN_D6;
|
||||
config.pin_d7 = CAMERA_PIN_D7;
|
||||
config.pin_xclk = CAMERA_PIN_XCLK;
|
||||
config.pin_pclk = CAMERA_PIN_PCLK;
|
||||
config.pin_vsync = CAMERA_PIN_VSYNC;
|
||||
config.pin_href = CAMERA_PIN_HREF;
|
||||
config.pin_sccb_sda = CAMERA_PIN_SIOD;
|
||||
config.pin_sccb_scl = CAMERA_PIN_SIOC;
|
||||
config.sccb_i2c_port = 1;
|
||||
config.pin_pwdn = CAMERA_PIN_PWDN;
|
||||
config.pin_reset = CAMERA_PIN_RESET;
|
||||
config.xclk_freq_hz = XCLK_FREQ_HZ;
|
||||
config.pixel_format = PIXFORMAT_RGB565;
|
||||
config.frame_size = FRAMESIZE_QVGA;
|
||||
config.jpeg_quality = 12;
|
||||
config.fb_count = 1;
|
||||
config.fb_location = CAMERA_FB_IN_PSRAM;
|
||||
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
|
||||
camera_ = new Esp32Camera(config);
|
||||
}
|
||||
|
||||
// 物联网初始化,添加对 AI 可见设备
|
||||
void InitializeIot() {
|
||||
auto& thing_manager = iot::ThingManager::GetInstance();
|
||||
@@ -326,6 +359,7 @@ public:
|
||||
I2cDetect();
|
||||
InitializeSpi();
|
||||
InitializeIli9342Display();
|
||||
InitializeCamera();
|
||||
InitializeIot();
|
||||
InitializeFt6336TouchPad();
|
||||
GetBacklight()->RestoreBrightness();
|
||||
@@ -350,6 +384,10 @@ public:
|
||||
return display_;
|
||||
}
|
||||
|
||||
virtual Camera* GetCamera() override {
|
||||
return camera_;
|
||||
}
|
||||
|
||||
virtual bool GetBatteryLevel(int &level, bool& charging, bool& discharging) override {
|
||||
static bool last_discharging = false;
|
||||
charging = pmic_->IsCharging();
|
||||
|
||||
2952
main/boards/m5stack-core-s3/sdkconfig.cores3
Normal file
2952
main/boards/m5stack-core-s3/sdkconfig.cores3
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user