feat: support USB Camera (#1519)

This commit is contained in:
laride
2025-12-11 07:10:12 +08:00
committed by GitHub
parent 1f0d2e993b
commit 4b582f8074
4 changed files with 113 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
#include "button.h"
#include "config.h"
#include "backlight.h"
#include "esp32_camera.h"
#include <esp_log.h>
@@ -379,7 +380,7 @@ private:
SemaphoreHandle_t touch_isr_mux_;
};
class EspS3Cat : public WifiBoard {
class EchoEar : public WifiBoard {
private:
i2c_master_bus_handle_t i2c_bus_;
Cst816s* cst816s_;
@@ -389,6 +390,7 @@ private:
PwmBacklight* backlight_ = nullptr;
esp_timer_handle_t touchpad_timer_;
esp_lcd_touch_handle_t tp; // LCD touch handle
Esp32Camera* camera_ = nullptr;
void InitializeI2c()
{
@@ -467,7 +469,7 @@ private:
while (true) {
if (touchpad->WaitForTouchEvent()) {
auto &app = Application::GetInstance();
auto &board = (EspS3Cat &)Board::GetInstance();
auto &board = (EchoEar &)Board::GetInstance();
ESP_LOGI(TAG, "Touch event, TP_PIN_NUM_INT: %d", gpio_get_level(TP_PIN_NUM_INT));
touchpad->UpdateTouchPoint();
@@ -505,7 +507,7 @@ private:
gpio_config(&int_gpio_config);
gpio_install_isr_service(0);
gpio_intr_enable(TP_PIN_NUM_INT);
gpio_isr_handler_add(TP_PIN_NUM_INT, EspS3Cat::touch_isr_callback, cst816s_);
gpio_isr_handler_add(TP_PIN_NUM_INT, EchoEar::touch_isr_callback, cst816s_);
}
void InitializeSpi()
@@ -582,8 +584,33 @@ private:
gpio_set_level(POWER_CTRL, 0);
}
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
void InitializeCamera() {
esp_video_init_usb_uvc_config_t usb_uvc_config = {
.uvc = {
.uvc_dev_num = 1,
.task_stack = 4096,
.task_priority = 5,
.task_affinity = -1,
},
.usb = {
.init_usb_host_lib = true,
.task_stack = 4096,
.task_priority = 5,
.task_affinity = -1,
},
};
esp_video_init_config_t video_config = {
.usb_uvc = &usb_uvc_config,
};
camera_ = new Esp32Camera(video_config);
}
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
public:
EspS3Cat() : boot_button_(BOOT_BUTTON_GPIO)
EchoEar() : boot_button_(BOOT_BUTTON_GPIO)
{
InitializeI2c();
uint8_t pcb_verison = DetectPcbVersion();
@@ -593,6 +620,9 @@ public:
InitializeSpi();
Initializest77916Display(pcb_verison);
InitializeButtons();
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
InitializeCamera();
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
}
virtual AudioCodec* GetAudioCodec() override
@@ -627,6 +657,10 @@ public:
{
return backlight_;
}
virtual Camera* GetCamera() override {
return camera_;
}
};
DECLARE_BOARD(EspS3Cat);
DECLARE_BOARD(EchoEar);

View File

@@ -5,6 +5,7 @@
#include "button.h"
#include "led/single_led.h"
#include "pin_config.h"
#include "esp32_camera.h"
#include "config.h"
@@ -26,6 +27,8 @@ private:
i2c_master_bus_handle_t i2c_bus_;
Button boot_button_;
LcdDisplay* display_;
Esp32Camera* camera_;
//add support ev board lcd
esp_io_expander_handle_t expander = NULL;
@@ -195,12 +198,39 @@ private:
lvgl_port_add_touch(&touch_cfg);
}
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
void InitializeCamera() {
esp_video_init_usb_uvc_config_t usb_uvc_config = {
.uvc = {
.uvc_dev_num = 1,
.task_stack = 4096,
.task_priority = 5,
.task_affinity = -1,
},
.usb = {
.init_usb_host_lib = true,
.task_stack = 4096,
.task_priority = 5,
.task_affinity = -1,
},
};
}
esp_video_init_config_t video_config = {
.usb_uvc = &usb_uvc_config,
};
camera_ = new Esp32Camera(video_config);
}
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
public:
ESP_S3_LCD_EV_Board_2() : boot_button_(BOOT_BUTTON_GPIO) {
InitializeCodecI2c();
InitializeButtons();
InitializeRGB_GC9503V_Display();
InitializeTouch();
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
InitializeCamera();
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
}
virtual AudioCodec* GetAudioCodec() override {
@@ -230,6 +260,12 @@ public:
return &led;
}
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
virtual Camera* GetCamera() override {
return camera_;
}
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
};
DECLARE_BOARD(ESP_S3_LCD_EV_Board_2);

View File

@@ -5,6 +5,7 @@
#include "button.h"
#include "led/single_led.h"
#include "pin_config.h"
#include "esp32_camera.h"
#include "config.h"
@@ -24,6 +25,7 @@ private:
i2c_master_bus_handle_t codec_i2c_bus_;
Button boot_button_;
LcdDisplay* display_;
Esp32Camera* camera_;
//add support ev board lcd
esp_io_expander_handle_t expander = NULL;
@@ -165,11 +167,39 @@ private:
});
}
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
void InitializeCamera() {
esp_video_init_usb_uvc_config_t usb_uvc_config = {
.uvc = {
.uvc_dev_num = 1,
.task_stack = 4096,
.task_priority = 5,
.task_affinity = -1,
},
.usb = {
.init_usb_host_lib = true,
.task_stack = 4096,
.task_priority = 5,
.task_affinity = -1,
},
};
esp_video_init_config_t video_config = {
.usb_uvc = &usb_uvc_config,
};
camera_ = new Esp32Camera(video_config);
}
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
public:
ESP_S3_LCD_EV_Board() : boot_button_(BOOT_BUTTON_GPIO) {
InitializeCodecI2c();
InitializeButtons();
InitializeRGB_GC9503V_Display();
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
InitializeCamera();
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
}
virtual AudioCodec* GetAudioCodec() override {
@@ -199,6 +229,12 @@ public:
return &led;
}
#ifdef CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
virtual Camera* GetCamera() override {
return camera_;
}
#endif // CONFIG_ESP_VIDEO_ENABLE_USB_UVC_VIDEO_DEVICE
};
DECLARE_BOARD(ESP_S3_LCD_EV_Board);