两块 ESP32-S3-WROOM-1-N16R8 图传板(DVP 接口接 OV2640/OV3660/OV5640), 向队伍客户端与裁判终端推 UDP 图传。固件是跑在 ESP-IDF 上的 Rust,用官方 esp32-camera 组件采集;客户端是 Rust + Slint 桌面程序。 三个 crate 各自独立构建: . firmware,交叉编译到 Xtensa protocol/ 线路格式与帧重组,两端共用,无 ESP-IDF 依赖,有单元测试 client/ Slint 桌面客户端 视频走 UDP 而非 TCP:实测传感器产出 22 fps,TCP MJPEG 只送出 1.9 fps, 且只占用链路能力的 1%——链路是空的,帧堵在队头阻塞后面等一个实时画面 等不起的重传计时器。改为独立数据报、不重传、缺片丢整帧后达到 20.8 fps。 发现是双向的:板子每 2 秒广播 Hello,客户端广播 Subscribe,板子据此定向 推流。板子身份由 MAC 派生,重启不变,所以客户端可以把绑定存进配置。 裁判端同时收两块板子(每个发送方一个重组器),队伍端绑定其中一块并只显示 自己那一边的血量。装甲板接口已预留(ArmorSource trait + ARMOR_PORT), 当前无数据源,界面显示占位符。 vendor 了 esp32-camera 2.1.7:组件注册表的版本求解器找不到它,且需要打一处 补丁(见 components/esp32-camera/target/esp32s3/ll_cam.c)。 .gitignore 三条 target/ 都锚定在根目录,因为 protocol/ 与 client/ 各自也是 独立 crate;而 components/esp32-camera/target/ 是上游的按芯片分目录,里面是 源码,必须保留。
111 lines
2.5 KiB
CMake
111 lines
2.5 KiB
CMake
# get IDF version for comparison
|
|
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}")
|
|
|
|
set(priv_requires "")
|
|
|
|
# set conversion sources
|
|
set(srcs
|
|
conversions/yuv.c
|
|
conversions/to_jpg.cpp
|
|
conversions/to_bmp.c
|
|
conversions/jpge.cpp
|
|
)
|
|
|
|
set(priv_include_dirs
|
|
conversions/private_include
|
|
)
|
|
|
|
set(include_dirs
|
|
driver/include
|
|
conversions/include
|
|
)
|
|
|
|
# set driver sources only for supported platforms
|
|
if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3")
|
|
list(APPEND srcs
|
|
driver/esp_camera.c
|
|
driver/esp_camera_af.c
|
|
driver/cam_hal.c
|
|
driver/sensor.c
|
|
sensors/ov2640.c
|
|
sensors/ov3660.c
|
|
sensors/ov5640.c
|
|
sensors/ov5640_af.c
|
|
sensors/ov7725.c
|
|
sensors/ov7670.c
|
|
sensors/nt99141.c
|
|
sensors/gc0308.c
|
|
sensors/gc2145.c
|
|
sensors/gc032a.c
|
|
sensors/bf3005.c
|
|
sensors/bf20a6.c
|
|
sensors/sc101iot.c
|
|
sensors/sc030iot.c
|
|
sensors/sc031gs.c
|
|
sensors/mega_ccm.c
|
|
sensors/hm1055.c
|
|
sensors/hm0360.c
|
|
)
|
|
|
|
list(APPEND priv_include_dirs
|
|
driver/private_include
|
|
sensors/private_include
|
|
target/private_include
|
|
)
|
|
|
|
if(IDF_TARGET STREQUAL "esp32")
|
|
list(APPEND srcs
|
|
target/xclk.c
|
|
target/esp32/ll_cam.c
|
|
)
|
|
endif()
|
|
|
|
if(IDF_TARGET STREQUAL "esp32s2")
|
|
list(APPEND srcs
|
|
target/xclk.c
|
|
target/esp32s2/ll_cam.c
|
|
)
|
|
|
|
list(APPEND priv_include_dirs
|
|
target/esp32s2/private_include
|
|
)
|
|
endif()
|
|
|
|
if(IDF_TARGET STREQUAL "esp32s3")
|
|
list(APPEND srcs
|
|
target/esp32s3/ll_cam.c
|
|
)
|
|
endif()
|
|
|
|
list(APPEND priv_requires freertos nvs_flash esp_mm)
|
|
|
|
set(min_version_for_esp_timer "4.2")
|
|
if (idf_version VERSION_GREATER_EQUAL min_version_for_esp_timer)
|
|
list(APPEND priv_requires esp_timer)
|
|
endif()
|
|
|
|
# include the SCCB I2C driver
|
|
# this uses either the legacy I2C API or the newer version from IDF v5.4
|
|
# as this features a method to obtain the I2C driver from a port number
|
|
if (idf_version VERSION_GREATER_EQUAL "5.4" AND NOT CONFIG_SCCB_HARDWARE_I2C_DRIVER_LEGACY)
|
|
list(APPEND srcs driver/sccb-ng.c)
|
|
else()
|
|
list(APPEND srcs driver/sccb.c)
|
|
endif()
|
|
|
|
endif()
|
|
|
|
set(req driver)
|
|
if (idf_version VERSION_GREATER_EQUAL "6.0")
|
|
list(APPEND priv_requires esp_driver_gpio esp_driver_spi esp_driver_i2c)
|
|
list(APPEND req esp_driver_ledc esp_hal_clock)
|
|
endif()
|
|
|
|
idf_component_register(
|
|
SRCS ${srcs}
|
|
INCLUDE_DIRS ${include_dirs}
|
|
PRIV_INCLUDE_DIRS ${priv_include_dirs}
|
|
REQUIRES ${req}
|
|
PRIV_REQUIRES ${priv_requires}
|
|
)
|