mirror of
https://github.com/cottongin/cardputerzero-camera.git
synced 2026-11-20 14:24:48 -06:00
feat(app): add 320x170 shadcn Option A UI, keyboard controller, and device/SDL2 runtime
This commit is contained in:
@@ -10,9 +10,9 @@ option(CZ_TARGET_DEVICE "Build for CardputerZero Linux fbdev/evdev target" OFF)
|
||||
option(CZ_BUILD_TESTS "Build czcamera unit tests" ON)
|
||||
option(CZ_ENABLE_LVGL "Enable optional LVGL UI hook if available" OFF)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
find_package(JPEG QUIET)
|
||||
if(NOT JPEG_FOUND)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(LIBJPEG IMPORTED_TARGET libjpeg)
|
||||
endif()
|
||||
@@ -22,7 +22,17 @@ if(NOT JPEG_FOUND)
|
||||
find_package(JPEG REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CZ_FREETYPE_TARGET "")
|
||||
find_package(Freetype QUIET)
|
||||
if(TARGET Freetype::Freetype)
|
||||
set(CZ_FREETYPE_TARGET Freetype::Freetype)
|
||||
elseif(PkgConfig_FOUND)
|
||||
pkg_check_modules(FREETYPE QUIET IMPORTED_TARGET freetype2)
|
||||
if(TARGET PkgConfig::FREETYPE)
|
||||
set(CZ_FREETYPE_TARGET PkgConfig::FREETYPE)
|
||||
endif()
|
||||
endif()
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(CZ_ENABLE_LVGL)
|
||||
@@ -41,6 +51,8 @@ add_library(czcamera_core STATIC
|
||||
src/timelapse_engine.cpp
|
||||
src/gallery_model.cpp
|
||||
src/video_player.cpp
|
||||
src/ui_controller.cpp
|
||||
src/app_ui.cpp
|
||||
)
|
||||
|
||||
target_include_directories(czcamera_core
|
||||
@@ -61,9 +73,12 @@ target_link_libraries(czcamera_core
|
||||
JPEG::JPEG
|
||||
)
|
||||
|
||||
if(Freetype_FOUND)
|
||||
if(CZ_FREETYPE_TARGET)
|
||||
target_compile_definitions(czcamera_core PUBLIC CZ_HAS_FREETYPE=1)
|
||||
target_link_libraries(czcamera_core PUBLIC Freetype::Freetype)
|
||||
target_link_libraries(czcamera_core PUBLIC ${CZ_FREETYPE_TARGET})
|
||||
message(STATUS "FreeType2 enabled via ${CZ_FREETYPE_TARGET}")
|
||||
else()
|
||||
message(STATUS "FreeType2 not found: using built-in 5x7 bitmap fallback")
|
||||
endif()
|
||||
|
||||
if(CZ_ENABLE_LVGL AND lvgl_FOUND)
|
||||
@@ -82,10 +97,34 @@ if(CZ_BUILD_APP)
|
||||
add_executable(czcamera src/main.cpp)
|
||||
target_compile_options(czcamera PRIVATE -Wall -Wextra -Wpedantic)
|
||||
target_link_libraries(czcamera PRIVATE czcamera_core JPEG::JPEG)
|
||||
if(NOT CZ_TARGET_DEVICE)
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries(czcamera PRIVATE SDL2::SDL2)
|
||||
if(CZ_TARGET_DEVICE)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
message(FATAL_ERROR "CZ_TARGET_DEVICE=ON requires Linux (fbdev/evdev); got CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
message(STATUS "Target backend: Linux fbdev + evdev")
|
||||
else()
|
||||
set(CZ_SDL2_TARGET "")
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(SDL2 QUIET IMPORTED_TARGET sdl2)
|
||||
if(TARGET PkgConfig::SDL2)
|
||||
set(CZ_SDL2_TARGET PkgConfig::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT CZ_SDL2_TARGET)
|
||||
find_package(SDL2 REQUIRED)
|
||||
if(TARGET SDL2::SDL2)
|
||||
set(CZ_SDL2_TARGET SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
if(CZ_SDL2_TARGET)
|
||||
target_link_libraries(czcamera PRIVATE ${CZ_SDL2_TARGET})
|
||||
else()
|
||||
target_include_directories(czcamera PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(czcamera PRIVATE ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
message(STATUS "Target backend: SDL2 320x170 simulator")
|
||||
endif()
|
||||
install(TARGETS czcamera RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(CZ_BUILD_TESTS)
|
||||
@@ -112,4 +151,9 @@ if(CZ_BUILD_TESTS)
|
||||
target_compile_options(test_timelapse_and_gallery PRIVATE -Wall -Wextra -Wpedantic)
|
||||
target_link_libraries(test_timelapse_and_gallery PRIVATE czcamera_core)
|
||||
add_test(NAME test_timelapse_and_gallery COMMAND test_timelapse_and_gallery)
|
||||
|
||||
add_executable(test_ui_controller tests/test_ui_controller.cpp)
|
||||
target_compile_options(test_ui_controller PRIVATE -Wall -Wextra -Wpedantic)
|
||||
target_link_libraries(test_ui_controller PRIVATE czcamera_core)
|
||||
add_test(NAME test_ui_controller COMMAND test_ui_controller)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user