mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-18 05:53:44 +02:00
Fix UVC not starting on Babble and Xiao boards due to a miss-configuration
This commit is contained in:
@@ -79,10 +79,10 @@ void CameraManager::setupCameraPinout()
|
||||
.pixel_format = PIXFORMAT_JPEG, // YUV422,GRAYSCALE,RGB565,JPEG
|
||||
.frame_size = FRAMESIZE_240X240, // QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.
|
||||
|
||||
.jpeg_quality = 7, // 0-63, for OV series camera sensors, lower number means higher quality // Below 6 stability problems
|
||||
.fb_count = 2, // When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
|
||||
.jpeg_quality = 7, // 0-63, for OV series camera sensors, lower number means higher quality // Below 6 stability problems
|
||||
.fb_count = 2, // When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
|
||||
.fb_location = CAMERA_FB_IN_DRAM,
|
||||
.grab_mode = CAMERA_GRAB_LATEST, //CAMERA_GRAB_WHEN_EMPTY
|
||||
.grab_mode = CAMERA_GRAB_LATEST, // CAMERA_GRAB_WHEN_EMPTY
|
||||
};
|
||||
}
|
||||
|
||||
@@ -202,7 +202,8 @@ bool CameraManager::setupCamera()
|
||||
// Thanks to lick_it, we discovered that OV5640 likes to overheat when
|
||||
// running at higher than usual xclk frequencies.
|
||||
// Hence, why we're limiting the faster ones for OV2640
|
||||
if (const auto camera_id = temp_sensor->id.PID; camera_id == OV5640_PID) {
|
||||
if (const auto camera_id = temp_sensor->id.PID; camera_id == OV5640_PID)
|
||||
{
|
||||
config.xclk_freq_hz = OV5640_XCLK_FREQ_HZ;
|
||||
esp_camera_deinit();
|
||||
esp_camera_init(&config);
|
||||
|
||||
@@ -36,13 +36,13 @@ struct DeviceMode_t : BaseConfigModel
|
||||
void load()
|
||||
{
|
||||
// Default mode can be controlled via sdkconfig:
|
||||
// - If CONFIG_GENERAL_DEFAULT_WIRED_MODE is enabled, default to UVC
|
||||
// - If CONFIG_START_IN_UVC_MODE is enabled, default to UVC
|
||||
// - Otherwise default to AUTO
|
||||
int default_mode =
|
||||
#if CONFIG_GENERAL_DEFAULT_WIRED_MODE
|
||||
static_cast<int>(StreamingMode::UVC);
|
||||
#if CONFIG_START_IN_UVC_MODE
|
||||
static_cast<int>(StreamingMode::UVC);
|
||||
#else
|
||||
static_cast<int>(StreamingMode::AUTO);
|
||||
static_cast<int>(StreamingMode::AUTO);
|
||||
#endif
|
||||
|
||||
int stored_mode = this->pref->getInt("mode", default_mode);
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
static const char *UVC_STREAM_TAG = "[UVC DEVICE]";
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
static char serial_number_str[13];
|
||||
|
||||
const char *get_uvc_device_name()
|
||||
@@ -26,9 +27,9 @@ extern "C" {
|
||||
return CONFIG_TUSB_SERIAL_NUM;
|
||||
}
|
||||
|
||||
// 12 hex chars without separators
|
||||
snprintf(serial_number_str, sizeof(serial_number_str), "%02X%02X%02X%02X%02X%02X",
|
||||
mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5]);
|
||||
// 12 hex chars without separators
|
||||
snprintf(serial_number_str, sizeof(serial_number_str), "%02X%02X%02X%02X%02X%02X",
|
||||
mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5]);
|
||||
}
|
||||
return serial_number_str;
|
||||
}
|
||||
@@ -91,7 +92,7 @@ static uvc_fb_t *UVCStreamHelpers::camera_fb_get_cb(void *cb_ctx)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Pace frames to exactly 60 fps (drop extras). Uses fixed-point accumulator
|
||||
// to achieve an exact average of 60.000 fps without drifting.
|
||||
static int64_t next_deadline_us = 0;
|
||||
@@ -99,7 +100,7 @@ static uvc_fb_t *UVCStreamHelpers::camera_fb_get_cb(void *cb_ctx)
|
||||
constexpr int target_fps = 60;
|
||||
constexpr int64_t us_per_sec = 1000000LL;
|
||||
constexpr int base_interval_us = us_per_sec / target_fps; // 16666
|
||||
constexpr int rem_us = us_per_sec % target_fps; // 40
|
||||
constexpr int rem_us = us_per_sec % target_fps; // 40
|
||||
|
||||
const int64_t now_us = esp_timer_get_time();
|
||||
if (next_deadline_us == 0)
|
||||
@@ -114,7 +115,7 @@ static uvc_fb_t *UVCStreamHelpers::camera_fb_get_cb(void *cb_ctx)
|
||||
s_fb.cam_fb_p = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
s_fb.uvc_fb.buf = s_fb.cam_fb_p->buf;
|
||||
s_fb.uvc_fb.len = s_fb.cam_fb_p->len;
|
||||
@@ -130,8 +131,8 @@ static uvc_fb_t *UVCStreamHelpers::camera_fb_get_cb(void *cb_ctx)
|
||||
esp_camera_fb_return(s_fb.cam_fb_p);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Schedule the next allowed frame time: base interval plus distributed remainder
|
||||
rem_acc += rem_us;
|
||||
int extra_us = 0;
|
||||
@@ -143,7 +144,7 @@ static uvc_fb_t *UVCStreamHelpers::camera_fb_get_cb(void *cb_ctx)
|
||||
// Accumulate from the previous deadline to avoid drift; if we are badly late, catch up from now
|
||||
const int64_t base_next = next_deadline_us + base_interval_us + extra_us;
|
||||
next_deadline_us = (base_next < now_us) ? now_us : base_next;
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
return &s_fb.uvc_fb;
|
||||
}
|
||||
@@ -175,7 +176,7 @@ esp_err_t UVCStreamManager::setup()
|
||||
|
||||
uvc_device_config_t config = {
|
||||
.uvc_buffer = uvc_buffer,
|
||||
.uvc_buffer_size = UVCStreamManager::UVC_MAX_FRAMESIZE_SIZE,
|
||||
.uvc_buffer_size = UVCStreamManager::UVC_MAX_FRAMESIZE_SIZE,
|
||||
.start_cb = UVCStreamHelpers::camera_start_cb,
|
||||
.fb_get_cb = UVCStreamHelpers::camera_fb_get_cb,
|
||||
.fb_return_cb = UVCStreamHelpers::camera_fb_return_cb,
|
||||
|
||||
@@ -6,6 +6,15 @@ endmenu
|
||||
|
||||
menu "OpenIris: General Configuration"
|
||||
|
||||
config START_IN_UVC_MODE
|
||||
bool "Start in UVC Mode"
|
||||
default false
|
||||
help
|
||||
Enables UVC (wired) support in the firmware by default.
|
||||
To be used when a board is designed to be used primarily with wired headsets.
|
||||
When enabled, the default device streaming mode will be UVC unless overridden by a
|
||||
saved preference. When disabled, the default mode is AUTO.
|
||||
|
||||
config GENERAL_DEFAULT_WIRED_MODE
|
||||
bool "Wired mode"
|
||||
default false
|
||||
|
||||
@@ -570,7 +570,8 @@ CONFIG_ENV_GPIO_OUT_RANGE_MAX=48
|
||||
#
|
||||
# OpenIris: General Configuration
|
||||
#
|
||||
# CONFIG_GENERAL_DEFAULT_WIRED_MODE is not set
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
CONFIG_GENERAL_UVC_DELAY=30
|
||||
# end of OpenIris: General Configuration
|
||||
|
||||
|
||||
@@ -571,6 +571,7 @@ CONFIG_ENV_GPIO_OUT_RANGE_MAX=48
|
||||
# OpenIris: General Configuration
|
||||
#
|
||||
# CONFIG_GENERAL_DEFAULT_WIRED_MODE is not set
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
# CONFIG_GENERAL_UVC_DELAY is not set
|
||||
# end of OpenIris: General Configuration
|
||||
|
||||
|
||||
@@ -59,4 +59,5 @@ CONFIG_LED_EXTERNAL_GPIO=9
|
||||
CONFIG_LED_EXTERNAL_PWM_FREQ=20000
|
||||
CONFIG_LED_EXTERNAL_PWM_DUTY_CYCLE=50
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
CONFIG_START_IN_UVC_MODE=y
|
||||
@@ -59,4 +59,5 @@ CONFIG_LED_EXTERNAL_GPIO=9
|
||||
CONFIG_LED_EXTERNAL_PWM_FREQ=20000
|
||||
CONFIG_LED_EXTERNAL_PWM_DUTY_CYCLE=100
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
CONFIG_START_IN_UVC_MODE=y
|
||||
@@ -51,4 +51,5 @@ CONFIG_LED_EXTERNAL_PWM_FREQ=5000
|
||||
CONFIG_LED_EXTERNAL_PWM_DUTY_CYCLE=100
|
||||
CONFIG_LED_EXTERNAL_GPIO=1
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
# CONFIG_GENERAL_DEFAULT_WIRED_MODE is not set
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
@@ -56,4 +56,5 @@ CONFIG_SPIRAM_SPEED=80
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_LED_EXTERNAL_CONTROL is not set
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
# CONFIG_GENERAL_DEFAULT_WIRED_MODE is not set
|
||||
CONFIG_GENERAL_DEFAULT_WIRED_MODE=y
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
Reference in New Issue
Block a user