From d25dfeba7d9d350eda05408615172692df6e382f Mon Sep 17 00:00:00 2001 From: Lemin Date: Wed, 25 Jun 2025 18:37:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?usb=5Fwebcam=E9=80=82=E9=85=8DUnitCamS3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/usb_webcam/main/Kconfig.projbuild | 34 +++++++++---------- .../device/usb_webcam/main/usb_webcam_main.c | 20 +++++++++++ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/examples/usb/device/usb_webcam/main/Kconfig.projbuild b/examples/usb/device/usb_webcam/main/Kconfig.projbuild index b21bab8a3..0dc6c7382 100644 --- a/examples/usb/device/usb_webcam/main/Kconfig.projbuild +++ b/examples/usb/device/usb_webcam/main/Kconfig.projbuild @@ -29,7 +29,7 @@ menu "USB WebCam config" config CAMERA_PIN_PWDN depends on CAMERA_MODULE_CUSTOM int "Power Down pin" - range -1 33 + range -1 48 default -1 help Select Power Down pin or -1 for unmanaged. @@ -37,7 +37,7 @@ menu "USB WebCam config" config CAMERA_PIN_RESET depends on CAMERA_MODULE_CUSTOM int "Reset pin" - range -1 33 + range -1 48 default -1 help Select Camera Reset pin or -1 for software reset. @@ -45,7 +45,7 @@ menu "USB WebCam config" config CAMERA_PIN_XCLK depends on CAMERA_MODULE_CUSTOM int "XCLK pin" - range 0 33 + range 0 48 default 21 help Select Camera XCLK pin. @@ -53,7 +53,7 @@ menu "USB WebCam config" config CAMERA_PIN_SIOD depends on CAMERA_MODULE_CUSTOM int "SIOD pin" - range 0 33 + range 0 48 default 26 help Select Camera SIOD pin. @@ -61,7 +61,7 @@ menu "USB WebCam config" config CAMERA_PIN_SIOC depends on CAMERA_MODULE_CUSTOM int "SIOC pin" - range 0 33 + range 0 48 default 27 help Select Camera SIOC pin. @@ -69,7 +69,7 @@ menu "USB WebCam config" config CAMERA_PIN_VSYNC depends on CAMERA_MODULE_CUSTOM int "VSYNC pin" - range 0 39 + range 0 48 default 25 help Select Camera VSYNC pin. @@ -77,7 +77,7 @@ menu "USB WebCam config" config CAMERA_PIN_HREF depends on CAMERA_MODULE_CUSTOM int "HREF pin" - range 0 39 + range 0 48 default 23 help Select Camera HREF pin. @@ -85,7 +85,7 @@ menu "USB WebCam config" config CAMERA_PIN_PCLK depends on CAMERA_MODULE_CUSTOM int "PCLK pin" - range 0 39 + range 0 48 default 25 help Select Camera PCLK pin. @@ -93,7 +93,7 @@ menu "USB WebCam config" config CAMERA_PIN_Y2 depends on CAMERA_MODULE_CUSTOM int "Y2 pin" - range 0 39 + range 0 48 default 4 help Select Camera Y2 pin. @@ -101,7 +101,7 @@ menu "USB WebCam config" config CAMERA_PIN_Y3 depends on CAMERA_MODULE_CUSTOM int "Y3 pin" - range 0 39 + range 0 48 default 5 help Select Camera Y3 pin. @@ -109,7 +109,7 @@ menu "USB WebCam config" config CAMERA_PIN_Y4 depends on CAMERA_MODULE_CUSTOM int "Y4 pin" - range 0 39 + range 0 48 default 18 help Select Camera Y4 pin. @@ -117,7 +117,7 @@ menu "USB WebCam config" config CAMERA_PIN_Y5 depends on CAMERA_MODULE_CUSTOM int "Y5 pin" - range 0 39 + range 0 48 default 19 help Select Camera Y5 pin. @@ -125,7 +125,7 @@ menu "USB WebCam config" config CAMERA_PIN_Y6 depends on CAMERA_MODULE_CUSTOM int "Y6 pin" - range 0 39 + range 0 48 default 36 help Select Camera Y6 pin. @@ -133,15 +133,15 @@ menu "USB WebCam config" config CAMERA_PIN_Y7 depends on CAMERA_MODULE_CUSTOM int "Y7 pin" - range 0 39 - default 39 + range 0 48 + default 42 help Select Camera Y7 pin. config CAMERA_PIN_Y8 depends on CAMERA_MODULE_CUSTOM int "Y8 pin" - range 0 39 + range 0 48 default 34 help Select Camera Y8 pin. @@ -149,7 +149,7 @@ menu "USB WebCam config" config CAMERA_PIN_Y9 depends on CAMERA_MODULE_CUSTOM int "Y9 pin" - range 0 39 + range 0 48 default 35 help Select Camera Y9 pin. diff --git a/examples/usb/device/usb_webcam/main/usb_webcam_main.c b/examples/usb/device/usb_webcam/main/usb_webcam_main.c index 646e0e9bf..293c22e43 100644 --- a/examples/usb/device/usb_webcam/main/usb_webcam_main.c +++ b/examples/usb/device/usb_webcam/main/usb_webcam_main.c @@ -33,6 +33,8 @@ static const char *TAG = "usb_webcam"; #define CAMERA_XCLK_FREQ CONFIG_CAMERA_XCLK_FREQ #define CAMERA_FB_COUNT 2 +#define LED_GPIO 14 + #if CONFIG_IDF_TARGET_ESP32S3 #define UVC_MAX_FRAMESIZE_SIZE (75*1024) #else @@ -109,6 +111,7 @@ static esp_err_t camera_init(uint32_t xclk_freq_hz, pixformat_t pixel_format, fr // If you need to reset the appeal parameters, please reinitialize the sensor. sensor_t *s = esp_camera_sensor_get(); s->set_vflip(s, 1); // flip it back + s->set_hmirror(s, 1); // initial sensors are flipped vertically and colors are a bit saturated if (s->id.PID == OV3660_PID) { s->set_brightness(s, 1); // up the blightness just a bit @@ -117,6 +120,7 @@ static esp_err_t camera_init(uint32_t xclk_freq_hz, pixformat_t pixel_format, fr if (s->id.PID == OV3660_PID || s->id.PID == OV2640_PID) { s->set_vflip(s, 1); // flip it back + s->set_hmirror(s, 1); } else if (s->id.PID == GC0308_PID) { s->set_hmirror(s, 0); } else if (s->id.PID == GC032A_PID) { @@ -231,6 +235,15 @@ static void camera_fb_return_cb(uvc_fb_t *fb, void *cb_ctx) esp_camera_fb_return(s_fb.cam_fb_p); } +static void configure_led(void) +{ + ESP_LOGI(TAG, "Example configured to blink GPIO LED!"); + gpio_reset_pin(LED_GPIO); + /* Set the GPIO as a push/pull output */ + gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT); + gpio_set_level(LED_GPIO, 0); +} + void app_main(void) { // if using esp-s3-eye board, show the GUI @@ -271,9 +284,16 @@ void app_main(void) ESP_LOGI(TAG, "\tFrame(3) = %d * %d @%dfps", UVC_FRAMES_INFO[0][3].width, UVC_FRAMES_INFO[0][3].height, UVC_FRAMES_INFO[0][3].rate); #endif + //configure_led(); + gpio_reset_pin(18); + /* Set the GPIO as a push/pull output */ + gpio_set_direction(18, GPIO_MODE_OUTPUT); + gpio_set_level(18, 0); ESP_ERROR_CHECK(uvc_device_config(0, &config)); ESP_ERROR_CHECK(uvc_device_init()); + //gpio_set_level(LED_GPIO, 0); + //configure_led(); while (1) { #if CONFIG_CAMERA_MODULE_ESP_S3_EYE #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) From c427e9458b4ed075562d7aee092cfc9d9d333119 Mon Sep 17 00:00:00 2001 From: Lemin Date: Wed, 25 Jun 2025 19:03:38 +0800 Subject: [PATCH 2/3] update default camera module selection for ESP32S3 --- examples/usb/device/usb_webcam/main/Kconfig.projbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/usb/device/usb_webcam/main/Kconfig.projbuild b/examples/usb/device/usb_webcam/main/Kconfig.projbuild index 0dc6c7382..8ee9221f3 100644 --- a/examples/usb/device/usb_webcam/main/Kconfig.projbuild +++ b/examples/usb/device/usb_webcam/main/Kconfig.projbuild @@ -11,7 +11,7 @@ menu "USB WebCam config" choice CAMERA_MODULE bool "Select Camera Pinout" - default CAMERA_MODULE_ESP_S3_EYE if IDF_TARGET_ESP32S3 + default CAMERA_MODULE_CUSTOM if IDF_TARGET_ESP32S3 default CAMERA_MODULE_ESP_S2_KALUGA if IDF_TARGET_ESP32S2 help Select Camera Pinout. From 401e70d193e1d9eb705229f21d1cbea3b15ac259 Mon Sep 17 00:00:00 2001 From: Lemin2 <50171448+Lemin2@users.noreply.github.com> Date: Thu, 29 Oct 2026 13:43:12 +0000 Subject: [PATCH 3/3] ci: add USB camera build and release workflow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/usb_camera_release.yml | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/usb_camera_release.yml diff --git a/.github/workflows/usb_camera_release.yml b/.github/workflows/usb_camera_release.yml new file mode 100644 index 000000000..0691d487c --- /dev/null +++ b/.github/workflows/usb_camera_release.yml @@ -0,0 +1,66 @@ +name: Build and Release USB Camera Firmware + +on: + push: + tags: + - 'usb-camera-v*' + workflow_dispatch: + inputs: + tag: + description: 'Release tag (e.g. usb-camera-v1.0.0)' + required: true + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: + - examples/usb/host/usb_camera_lcd_display + - examples/usb/host/usb_hub_dual_camera + - examples/usb/host/usb_camera_mic_spk + target: [esp32s3] + steps: + - uses: actions/checkout@v4 + + - name: Build with ESP-IDF + uses: espressif/esp-idf-ci-action@v1 + with: + esp_idf_version: v5.3 + target: ${{ matrix.target }} + path: ${{ matrix.example }} + command: idf.py build && cd build && esptool.py --chip ${{ matrix.target }} merge_bin -o merged.bin @flash_args + + - name: Prepare artifacts + id: prep + run: | + name=$(basename "${{ matrix.example }}")-${{ matrix.target }} + mkdir -p out + cp "${{ matrix.example }}/build/merged.bin" "out/${name}.bin" + echo "name=${name}" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@v4 + with: + name: ${{ steps.prep.outputs.name }} + path: out/*.bin + + release: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + path: out + merge-multiple: true + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.inputs.tag || github.ref_name }} + name: USB Camera ${{ github.event.inputs.tag || github.ref_name }} + generate_release_notes: true + files: out/*.bin