forked from xiaozhi/xiaozhi-esp32
Add camera support board(sp v3/v4 korvo) (#682)
* Add camera support board * Update esp32_camera.cc --------- Co-authored-by: Xiaoxia <terrence@tenclass.com>
This commit is contained in:
@@ -58,5 +58,24 @@
|
||||
|
||||
#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_NC
|
||||
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
|
||||
/* Camera pins */
|
||||
#define CAMERA_PIN_PWDN -1
|
||||
#define CAMERA_PIN_RESET -1
|
||||
#define CAMERA_PIN_XCLK 40
|
||||
#define CAMERA_PIN_SIOD 17
|
||||
#define CAMERA_PIN_SIOC 18
|
||||
|
||||
#define CAMERA_PIN_D7 39
|
||||
#define CAMERA_PIN_D6 41
|
||||
#define CAMERA_PIN_D5 42
|
||||
#define CAMERA_PIN_D4 12
|
||||
#define CAMERA_PIN_D3 3
|
||||
#define CAMERA_PIN_D2 14
|
||||
#define CAMERA_PIN_D1 47
|
||||
#define CAMERA_PIN_D0 13
|
||||
#define CAMERA_PIN_VSYNC 21
|
||||
#define CAMERA_PIN_HREF 38
|
||||
#define CAMERA_PIN_PCLK 11
|
||||
|
||||
#define XCLK_FREQ_HZ 20000000
|
||||
#endif // _BOARD_CONFIG_H_
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <driver/i2c_master.h>
|
||||
#include <driver/spi_common.h>
|
||||
#include <wifi_station.h>
|
||||
#include "esp32_camera.h"
|
||||
|
||||
#define TAG "esp32s3_korvo2_v3"
|
||||
|
||||
@@ -48,6 +49,7 @@ private:
|
||||
i2c_master_bus_handle_t i2c_bus_;
|
||||
LcdDisplay* display_;
|
||||
esp_io_expander_handle_t io_expander_ = NULL;
|
||||
Esp32Camera* camera_;
|
||||
|
||||
void InitializeI2c() {
|
||||
// Initialize I2C peripheral
|
||||
@@ -225,6 +227,39 @@ private:
|
||||
});
|
||||
}
|
||||
|
||||
void InitializeCamera() {
|
||||
// Open camera power
|
||||
|
||||
camera_config_t config = {};
|
||||
config.ledc_channel = LEDC_CHANNEL_2; // LEDC通道选择 用于生成XCLK时钟 但是S3不用
|
||||
config.ledc_timer = LEDC_TIMER_2; // LEDC timer选择 用于生成XCLK时钟 但是S3不用
|
||||
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 = -1; // 这里写-1 表示使用已经初始化的I2C接口
|
||||
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_VGA;
|
||||
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();
|
||||
@@ -238,6 +273,7 @@ public:
|
||||
InitializeI2c();
|
||||
I2cDetect();
|
||||
InitializeTca9554();
|
||||
InitializeCamera();
|
||||
InitializeSpi();
|
||||
InitializeButtons();
|
||||
#ifdef LCD_TYPE_ILI9341_SERIAL
|
||||
@@ -268,6 +304,9 @@ public:
|
||||
virtual Display *GetDisplay() override {
|
||||
return display_;
|
||||
}
|
||||
virtual Camera* GetCamera() override {
|
||||
return camera_;
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_BOARD(Esp32S3Korvo2V3Board);
|
||||
|
||||
Reference in New Issue
Block a user