forked from xiaozhi/xiaozhi-esp32
Refactor: Use esp_video component (#1245)
* refactor: migrate camera module to esp-video library * refactor: migrate boards to esp-video API (1/2) * refactor: migrate boards to esp-video API (2/2) * fix: use ESP-IDF 5.5 * refactor: migrate the JPEG encoder to `esp_new_jpeg` * feat: add YUV422 support * feat: improve pixelformat and device selection process * feat: use ESP32-P4 Hardware JPEG Encoder
This commit is contained in:
@@ -224,41 +224,56 @@ private:
|
||||
}
|
||||
|
||||
void InitializeCamera() {
|
||||
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 = Y2_GPIO_NUM;
|
||||
config.pin_d1 = Y3_GPIO_NUM;
|
||||
config.pin_d2 = Y4_GPIO_NUM;
|
||||
config.pin_d3 = Y5_GPIO_NUM;
|
||||
config.pin_d4 = Y6_GPIO_NUM;
|
||||
config.pin_d5 = Y7_GPIO_NUM;
|
||||
config.pin_d6 = Y8_GPIO_NUM;
|
||||
config.pin_d7 = Y9_GPIO_NUM;
|
||||
config.pin_xclk = XCLK_GPIO_NUM;
|
||||
config.pin_pclk = PCLK_GPIO_NUM;
|
||||
config.pin_vsync = VSYNC_GPIO_NUM;
|
||||
config.pin_href = HREF_GPIO_NUM;
|
||||
#ifdef CONFIG_BOARD_TYPE_LILYGO_T_CAMERAPLUS_S3_V1_0_V1_1
|
||||
config.pin_sccb_sda = -1; // 这里如果写-1 表示使用已经初始化的I2C接口
|
||||
config.pin_sccb_scl = SIOC_GPIO_NUM;
|
||||
config.sccb_i2c_port = 0; // 这里如果写0 默认使用I2C0
|
||||
#elif defined CONFIG_BOARD_TYPE_LILYGO_T_CAMERAPLUS_S3_V1_2
|
||||
config.pin_sccb_sda = SIOD_GPIO_NUM;
|
||||
config.pin_sccb_scl = SIOC_GPIO_NUM;
|
||||
config.sccb_i2c_port = 1;
|
||||
#endif
|
||||
config.pin_pwdn = PWDN_GPIO_NUM;
|
||||
config.pin_reset = RESET_GPIO_NUM;
|
||||
config.xclk_freq_hz = XCLK_FREQ_HZ;
|
||||
config.pixel_format = PIXFORMAT_RGB565;
|
||||
config.frame_size = FRAMESIZE_240X240;
|
||||
config.jpeg_quality = 12;
|
||||
config.fb_count = 1;
|
||||
config.fb_location = CAMERA_FB_IN_PSRAM;
|
||||
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
|
||||
static esp_cam_ctlr_dvp_pin_config_t dvp_pin_config = {
|
||||
.data_width = CAM_CTLR_DATA_WIDTH_8,
|
||||
.data_io = {
|
||||
[0] = Y2_GPIO_NUM,
|
||||
[1] = Y3_GPIO_NUM,
|
||||
[2] = Y4_GPIO_NUM,
|
||||
[3] = Y5_GPIO_NUM,
|
||||
[4] = Y6_GPIO_NUM,
|
||||
[5] = Y7_GPIO_NUM,
|
||||
[6] = Y8_GPIO_NUM,
|
||||
[7] = Y9_GPIO_NUM,
|
||||
},
|
||||
.vsync_io = VSYNC_GPIO_NUM,
|
||||
.de_io = HREF_GPIO_NUM,
|
||||
.pclk_io = PCLK_GPIO_NUM,
|
||||
.xclk_io = XCLK_GPIO_NUM,
|
||||
};
|
||||
|
||||
camera_ = new Esp32Camera(config);
|
||||
esp_video_init_sccb_config_t sccb_config = {
|
||||
#ifdef CONFIG_BOARD_TYPE_LILYGO_T_CAMERAPLUS_S3_V1_0_V1_1
|
||||
.init_sccb = true,
|
||||
.i2c_config = {
|
||||
.port = 0,
|
||||
.scl_pin = SIOC_GPIO_NUM,
|
||||
.sda_pin = GPIO_NUM_NC,
|
||||
},
|
||||
#elif defined CONFIG_BOARD_TYPE_LILYGO_T_CAMERAPLUS_S3_V1_2
|
||||
.init_sccb = true,
|
||||
.i2c_config = {
|
||||
.port = 1,
|
||||
.scl_pin = SIOC_GPIO_NUM,
|
||||
.sda_pin = SIOD_GPIO_NUM,
|
||||
},
|
||||
#endif
|
||||
.freq = 100000,
|
||||
};
|
||||
|
||||
esp_video_init_dvp_config_t dvp_config = {
|
||||
.sccb_config = sccb_config,
|
||||
.reset_pin = RESET_GPIO_NUM,
|
||||
.pwdn_pin = PWDN_GPIO_NUM,
|
||||
.dvp_pin = dvp_pin_config,
|
||||
.xclk_freq = XCLK_FREQ_HZ,
|
||||
};
|
||||
|
||||
esp_video_init_config_t video_config = {
|
||||
.dvp = &dvp_config,
|
||||
};
|
||||
|
||||
camera_ = new Esp32Camera(video_config);
|
||||
camera_->SetVFlip(1);
|
||||
camera_->SetHMirror(1);
|
||||
}
|
||||
|
||||
@@ -16,90 +16,90 @@
|
||||
#ifdef T_CameraPlus_S3_V1_0_V1_1
|
||||
|
||||
// SPI
|
||||
#define SPI_SCLK 36
|
||||
#define SPI_MOSI 35
|
||||
#define SPI_MISO 37
|
||||
#define SPI_SCLK GPIO_NUM_36
|
||||
#define SPI_MOSI GPIO_NUM_35
|
||||
#define SPI_MISO GPIO_NUM_37
|
||||
|
||||
// IIC
|
||||
#define IIC_SDA 1
|
||||
#define IIC_SCL 2
|
||||
#define IIC_SDA GPIO_NUM_1
|
||||
#define IIC_SCL GPIO_NUM_2
|
||||
|
||||
// MSM261
|
||||
#define MSM261_BCLK 18
|
||||
#define MSM261_WS 39
|
||||
#define MSM261_DATA 40
|
||||
#define MSM261_BCLK GPIO_NUM_18
|
||||
#define MSM261_WS GPIO_NUM_39
|
||||
#define MSM261_DATA GPIO_NUM_40
|
||||
|
||||
// MAX98357A
|
||||
#define MAX98357A_DATA 38
|
||||
#define MAX98357A_DATA GPIO_NUM_38
|
||||
|
||||
// FP-133H01D
|
||||
#define LCD_CS 34
|
||||
#define LCD_RST 33
|
||||
#define LCD_CS GPIO_NUM_34
|
||||
#define LCD_RST GPIO_NUM_33
|
||||
|
||||
// OV2640
|
||||
#define OV2640_PWDN -1
|
||||
#define OV2640_RESET 3
|
||||
#define OV2640_VSYNC 4
|
||||
#define OV2640_PWDN GPIO_NUM_NC
|
||||
#define OV2640_RESET GPIO_NUM_3
|
||||
#define OV2640_VSYNC GPIO_NUM_4
|
||||
|
||||
// CST816
|
||||
#define TP_RST 48
|
||||
#define TP_RST GPIO_NUM_48
|
||||
|
||||
// SY6970
|
||||
#define SY6970_INT 47
|
||||
#define SY6970_INT GPIO_NUM_47
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef T_CameraPlus_S3_V1_2
|
||||
|
||||
// SPI
|
||||
#define SPI_SCLK 35
|
||||
#define SPI_MOSI 34
|
||||
#define SPI_MISO 48
|
||||
#define SPI_SCLK GPIO_NUM_35
|
||||
#define SPI_MOSI GPIO_NUM_34
|
||||
#define SPI_MISO GPIO_NUM_48
|
||||
|
||||
// IIC
|
||||
#define IIC_SDA 33
|
||||
#define IIC_SCL 37
|
||||
#define IIC_SDA GPIO_NUM_33
|
||||
#define IIC_SCL GPIO_NUM_37
|
||||
|
||||
// MP34DT05TR
|
||||
#define MP34DT05TR_LRCLK 40
|
||||
#define MP34DT05TR_DATA 38
|
||||
#define MP34DT05TR_LRCLK GPIO_NUM_40
|
||||
#define MP34DT05TR_DATA GPIO_NUM_38
|
||||
|
||||
#define MP34DT05TR_MAX98357_EN 18
|
||||
#define MP34DT05TR_MAX98357_EN GPIO_NUM_18
|
||||
|
||||
// MAX98357A
|
||||
#define MAX98357A_DATA 39
|
||||
#define MAX98357A_DATA GPIO_NUM_39
|
||||
|
||||
// FP-133H01D
|
||||
#define LCD_CS 36
|
||||
#define LCD_RST -1
|
||||
#define LCD_CS GPIO_NUM_36
|
||||
#define LCD_RST GPIO_NUM_NC
|
||||
|
||||
// OV2640
|
||||
#define OV2640_PWDN 4
|
||||
#define OV2640_RESET -1
|
||||
#define OV2640_VSYNC 3
|
||||
#define OV2640_PWDN GPIO_NUM_4
|
||||
#define OV2640_RESET GPIO_NUM_NC
|
||||
#define OV2640_VSYNC GPIO_NUM_3
|
||||
|
||||
// CST816
|
||||
#define TP_RST -1
|
||||
#define TP_RST GPIO_NUM_NC
|
||||
|
||||
#endif
|
||||
|
||||
// SD
|
||||
#define SD_CS 21
|
||||
#define SD_CS GPIO_NUM_21
|
||||
#define SD_SCLK SPI_SCLK
|
||||
#define SD_MOSI SPI_MOSI
|
||||
#define SD_MISO SPI_MISO
|
||||
|
||||
// MAX98357A
|
||||
#define MAX98357A_BCLK 41
|
||||
#define MAX98357A_LRCLK 42
|
||||
#define MAX98357A_BCLK GPIO_NUM_41
|
||||
#define MAX98357A_LRCLK GPIO_NUM_42
|
||||
|
||||
// FP-133H01D
|
||||
#define LCD_WIDTH 240
|
||||
#define LCD_HEIGHT 240
|
||||
#define LCD_BL 46
|
||||
#define LCD_BL GPIO_NUM_46
|
||||
#define LCD_MOSI SPI_MOSI
|
||||
#define LCD_SCLK SPI_SCLK
|
||||
#define LCD_DC 45
|
||||
#define LCD_DC GPIO_NUM_45
|
||||
|
||||
// SY6970
|
||||
#define SY6970_SDA IIC_SDA
|
||||
@@ -107,19 +107,19 @@
|
||||
#define SY6970_ADDRESS 0x6A
|
||||
|
||||
// OV2640
|
||||
#define OV2640_XCLK 7
|
||||
#define OV2640_SDA 1
|
||||
#define OV2640_SCL 2
|
||||
#define OV2640_D9 6
|
||||
#define OV2640_D8 8
|
||||
#define OV2640_D7 9
|
||||
#define OV2640_D6 11
|
||||
#define OV2640_D5 13
|
||||
#define OV2640_D4 15
|
||||
#define OV2640_D3 14
|
||||
#define OV2640_D2 12
|
||||
#define OV2640_HREF 5
|
||||
#define OV2640_PCLK 10
|
||||
#define OV2640_XCLK GPIO_NUM_7
|
||||
#define OV2640_SDA GPIO_NUM_1
|
||||
#define OV2640_SCL GPIO_NUM_2
|
||||
#define OV2640_D9 GPIO_NUM_6
|
||||
#define OV2640_D8 GPIO_NUM_8
|
||||
#define OV2640_D7 GPIO_NUM_9
|
||||
#define OV2640_D6 GPIO_NUM_11
|
||||
#define OV2640_D5 GPIO_NUM_13
|
||||
#define OV2640_D4 GPIO_NUM_15
|
||||
#define OV2640_D3 GPIO_NUM_14
|
||||
#define OV2640_D2 GPIO_NUM_12
|
||||
#define OV2640_HREF GPIO_NUM_5
|
||||
#define OV2640_PCLK GPIO_NUM_10
|
||||
|
||||
#define PWDN_GPIO_NUM OV2640_PWDN
|
||||
#define RESET_GPIO_NUM OV2640_RESET
|
||||
@@ -145,10 +145,10 @@
|
||||
#define CST816_ADDRESS 0x15
|
||||
#define TP_SDA IIC_SDA
|
||||
#define TP_SCL IIC_SCL
|
||||
#define TP_INT 47
|
||||
#define TP_INT GPIO_NUM_47
|
||||
|
||||
// AP1511B
|
||||
#define AP1511B_FBC 16
|
||||
#define AP1511B_FBC GPIO_NUM_16
|
||||
|
||||
// KEY
|
||||
#define KEY1 17
|
||||
#define KEY1 GPIO_NUM_17
|
||||
|
||||
Reference in New Issue
Block a user