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:
Kevincoooool
2025-05-26 18:28:51 +08:00
committed by GitHub
parent 8555b89692
commit 0e42bd2b18
9 changed files with 217 additions and 5 deletions

View File

@@ -41,5 +41,24 @@
#define ML307_RX_PIN GPIO_NUM_12
#define ML307_TX_PIN GPIO_NUM_13
/* Camera pins */
#define CAMERA_PIN_PWDN -1
#define CAMERA_PIN_RESET -1
#define CAMERA_PIN_XCLK 15
#define CAMERA_PIN_SIOD 4
#define CAMERA_PIN_SIOC 5
#define CAMERA_PIN_D7 16
#define CAMERA_PIN_D6 17
#define CAMERA_PIN_D5 18
#define CAMERA_PIN_D4 12
#define CAMERA_PIN_D3 10
#define CAMERA_PIN_D2 8
#define CAMERA_PIN_D1 9
#define CAMERA_PIN_D0 11
#define CAMERA_PIN_VSYNC 6
#define CAMERA_PIN_HREF 7
#define CAMERA_PIN_PCLK 13
#define XCLK_FREQ_HZ 20000000
#endif // _BOARD_CONFIG_H_

View File

@@ -14,6 +14,7 @@
#include <esp_lcd_panel_vendor.h>
#include <driver/i2c_master.h>
#include <wifi_station.h>
#include "esp32_camera.h"
#define TAG "kevin-sp-v3"
@@ -27,6 +28,7 @@ private:
i2c_master_bus_handle_t display_i2c_bus_;
Button boot_button_;
LcdDisplay* display_;
Esp32Camera* camera_;
void InitializeSpi() {
spi_bus_config_t buscfg = {};
@@ -91,6 +93,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 = CAMERA_PIN_SIOD; // 这里写-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();
@@ -100,14 +135,12 @@ private:
}
public:
KEVIN_SP_V3Board() :
// Ml307Board(ML307_TX_PIN, ML307_RX_PIN, 4096),
boot_button_(BOOT_BUTTON_GPIO) {
KEVIN_SP_V3Board() : boot_button_(BOOT_BUTTON_GPIO) {
ESP_LOGI(TAG, "Initializing KEVIN_SP_V3 Board");
InitializeSpi();
InitializeButtons();
InitializeSt7789Display();
InitializeCamera();
InitializeIot();
GetBacklight()->RestoreBrightness();
}
@@ -132,6 +165,10 @@ public:
static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
return &backlight;
}
virtual Camera* GetCamera() override {
return camera_;
}
};
DECLARE_BOARD(KEVIN_SP_V3Board);