Skip to content

Commit

Permalink
add explicit convertion of enums
Browse files Browse the repository at this point in the history
  • Loading branch information
cnadler86 committed Dec 23, 2024
1 parent c979972 commit 061c2a6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 93 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/Create-Release.yml

This file was deleted.

38 changes: 24 additions & 14 deletions src/micropython.cmake
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
# `py.cmake` for `micropy_gather_target_properties` macro usage
# Include the py.cmake for additional macro micropy_gather_target_properties usage
include(${MICROPY_DIR}/py/py.cmake)

# Create an INTERFACE library for the camera module and sdd source files to the library
add_library(usermod_mp_camera INTERFACE)

target_sources(usermod_mp_camera INTERFACE
${CMAKE_CURRENT_LIST_DIR}/modcamera.c
${CMAKE_CURRENT_LIST_DIR}/modcamera_api.c
)

if(EXISTS "${IDF_PATH}/components/esp32-camera")
target_include_directories(usermod_mp_camera INTERFACE
${CMAKE_CURRENT_LIST_DIR}
${IDF_PATH}/components/esp32-camera/driver/include
${IDF_PATH}/components/esp32-camera/driver/private_include
${IDF_PATH}/components/esp32-camera/conversions/include
${IDF_PATH}/components/esp32-camera/conversions/private_include
${IDF_PATH}/components/esp32-camera/sensors/private_include
)
else()
target_include_directories(usermod_mp_camera INTERFACE
${CMAKE_CURRENT_LIST_DIR})
# Dynamically gather include directories for the esp32-camera component
idf_component_get_property(CAMERA_INCLUDES esp32-camera INCLUDE_DIRS)
idf_component_get_property(CAMERA_PRIV_INCLUDES esp32-camera PRIV_INCLUDE_DIRS)
idf_component_get_property(CAMERA_DIR esp32-camera COMPONENT_DIR)

# Create a list for include directories
set(MOD_INCLUDES ${CMAKE_CURRENT_LIST_DIR})

# Add dynamically discovered include paths
if (CAMERA_INCLUDES)
list(TRANSFORM CAMERA_INCLUDES PREPEND ${CAMERA_DIR}/)
list(APPEND MOD_INCLUDES ${CAMERA_INCLUDES})
endif()
if (CAMERA_PRIV_INCLUDES)
list(TRANSFORM CAMERA_PRIV_INCLUDES PREPEND ${CAMERA_DIR}/)
list(APPEND MOD_INCLUDES ${CAMERA_PRIV_INCLUDES})
endif()

# Add the include directories to the target
target_include_directories(usermod_mp_camera INTERFACE ${MOD_INCLUDES})

# Add compile definitions if MICROPY_CAMERA_MODEL is defined
if (MICROPY_CAMERA_MODEL)
target_compile_definitions(usermod_mp_camera INTERFACE MICROPY_CAMERA_MODEL_${MICROPY_CAMERA_MODEL}=1)
endif()

# Add compile definitions if MP_CAMERA_DRIVER_VERSION is defined
if (MP_CAMERA_DRIVER_VERSION)
target_compile_definitions(usermod_mp_camera INTERFACE MP_CAMERA_DRIVER_VERSION=\"${MP_CAMERA_DRIVER_VERSION}\")
endif()

# Link the usermod_mp_camera library to the main usermod target
target_link_libraries(usermod INTERFACE usermod_mp_camera)

micropy_gather_target_properties(usermod_mp_camera)
84 changes: 42 additions & 42 deletions src/modcamera.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,57 +316,57 @@ bool mp_camera_hal_initialized(mp_camera_obj_t *self){
}

const mp_rom_map_elem_t mp_camera_hal_pixel_format_table[] = {
{ MP_ROM_QSTR(MP_QSTR_JPEG), MP_ROM_INT(PIXFORMAT_JPEG) },
{ MP_ROM_QSTR(MP_QSTR_YUV422), MP_ROM_INT(PIXFORMAT_YUV422) },
{ MP_ROM_QSTR(MP_QSTR_YUV420), MP_ROM_INT(PIXFORMAT_YUV420) },
{ MP_ROM_QSTR(MP_QSTR_GRAYSCALE), MP_ROM_INT(PIXFORMAT_GRAYSCALE) },
{ MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_INT(PIXFORMAT_RGB565) },
{ MP_ROM_QSTR(MP_QSTR_RGB888), MP_ROM_INT(PIXFORMAT_RGB888) },
{ MP_ROM_QSTR(MP_QSTR_RAW), MP_ROM_INT(PIXFORMAT_RAW) },
{ MP_ROM_QSTR(MP_QSTR_RGB444), MP_ROM_INT(PIXFORMAT_RGB444) },
{ MP_ROM_QSTR(MP_QSTR_RGB555), MP_ROM_INT(PIXFORMAT_RGB555) },
{ MP_ROM_QSTR(MP_QSTR_JPEG), MP_ROM_INT((mp_uint_t)PIXFORMAT_JPEG) },
{ MP_ROM_QSTR(MP_QSTR_YUV422), MP_ROM_INT((mp_uint_t)PIXFORMAT_YUV422) },
{ MP_ROM_QSTR(MP_QSTR_YUV420), MP_ROM_INT((mp_uint_t)PIXFORMAT_YUV420) },
{ MP_ROM_QSTR(MP_QSTR_GRAYSCALE), MP_ROM_INT((mp_uint_t)PIXFORMAT_GRAYSCALE) },
{ MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_INT((mp_uint_t)PIXFORMAT_RGB565) },
{ MP_ROM_QSTR(MP_QSTR_RGB888), MP_ROM_INT((mp_uint_t)PIXFORMAT_RGB888) },
{ MP_ROM_QSTR(MP_QSTR_RAW), MP_ROM_INT((mp_uint_t)PIXFORMAT_RAW) },
{ MP_ROM_QSTR(MP_QSTR_RGB444), MP_ROM_INT((mp_uint_t)PIXFORMAT_RGB444) },
{ MP_ROM_QSTR(MP_QSTR_RGB555), MP_ROM_INT((mp_uint_t)PIXFORMAT_RGB555) },
};

const mp_rom_map_elem_t mp_camera_hal_frame_size_table[] = {
{ MP_ROM_QSTR(MP_QSTR_R96X96), MP_ROM_INT(FRAMESIZE_96X96) },
{ MP_ROM_QSTR(MP_QSTR_QQVGA), MP_ROM_INT(FRAMESIZE_QQVGA) },
{ MP_ROM_QSTR(MP_QSTR_R128x128), MP_ROM_INT(FRAMESIZE_128X128) },
{ MP_ROM_QSTR(MP_QSTR_QCIF), MP_ROM_INT(FRAMESIZE_QCIF) },
{ MP_ROM_QSTR(MP_QSTR_HQVGA), MP_ROM_INT(FRAMESIZE_HQVGA) },
{ MP_ROM_QSTR(MP_QSTR_R240X240), MP_ROM_INT(FRAMESIZE_240X240) },
{ MP_ROM_QSTR(MP_QSTR_QVGA), MP_ROM_INT(FRAMESIZE_QVGA) },
{ MP_ROM_QSTR(MP_QSTR_R320X320), MP_ROM_INT(FRAMESIZE_320X320) },
{ MP_ROM_QSTR(MP_QSTR_CIF), MP_ROM_INT(FRAMESIZE_CIF) },
{ MP_ROM_QSTR(MP_QSTR_HVGA), MP_ROM_INT(FRAMESIZE_HVGA) },
{ MP_ROM_QSTR(MP_QSTR_VGA), MP_ROM_INT(FRAMESIZE_VGA) },
{ MP_ROM_QSTR(MP_QSTR_SVGA), MP_ROM_INT(FRAMESIZE_SVGA) },
{ MP_ROM_QSTR(MP_QSTR_XGA), MP_ROM_INT(FRAMESIZE_XGA) },
{ MP_ROM_QSTR(MP_QSTR_HD), MP_ROM_INT(FRAMESIZE_HD) },
{ MP_ROM_QSTR(MP_QSTR_SXGA), MP_ROM_INT(FRAMESIZE_SXGA) },
{ MP_ROM_QSTR(MP_QSTR_UXGA), MP_ROM_INT(FRAMESIZE_UXGA) },
{ MP_ROM_QSTR(MP_QSTR_FHD), MP_ROM_INT(FRAMESIZE_FHD) },
{ MP_ROM_QSTR(MP_QSTR_P_HD), MP_ROM_INT(FRAMESIZE_P_HD) },
{ MP_ROM_QSTR(MP_QSTR_P_3MP), MP_ROM_INT(FRAMESIZE_P_3MP) },
{ MP_ROM_QSTR(MP_QSTR_QXGA), MP_ROM_INT(FRAMESIZE_QXGA) },
{ MP_ROM_QSTR(MP_QSTR_QHD), MP_ROM_INT(FRAMESIZE_QHD) },
{ MP_ROM_QSTR(MP_QSTR_WQXGA), MP_ROM_INT(FRAMESIZE_WQXGA) },
{ MP_ROM_QSTR(MP_QSTR_P_FHD), MP_ROM_INT(FRAMESIZE_P_FHD) },
{ MP_ROM_QSTR(MP_QSTR_QSXGA), MP_ROM_INT(FRAMESIZE_QSXGA) },
{ MP_ROM_QSTR(MP_QSTR_R96X96), MP_ROM_INT((mp_uint_t)FRAMESIZE_96X96) },
{ MP_ROM_QSTR(MP_QSTR_QQVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_QQVGA) },
{ MP_ROM_QSTR(MP_QSTR_R128x128), MP_ROM_INT((mp_uint_t)FRAMESIZE_128X128) },
{ MP_ROM_QSTR(MP_QSTR_QCIF), MP_ROM_INT((mp_uint_t)FRAMESIZE_QCIF) },
{ MP_ROM_QSTR(MP_QSTR_HQVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_HQVGA) },
{ MP_ROM_QSTR(MP_QSTR_R240X240), MP_ROM_INT((mp_uint_t)FRAMESIZE_240X240) },
{ MP_ROM_QSTR(MP_QSTR_QVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_QVGA) },
{ MP_ROM_QSTR(MP_QSTR_R320X320), MP_ROM_INT((mp_uint_t)FRAMESIZE_320X320) },
{ MP_ROM_QSTR(MP_QSTR_CIF), MP_ROM_INT((mp_uint_t)FRAMESIZE_CIF) },
{ MP_ROM_QSTR(MP_QSTR_HVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_HVGA) },
{ MP_ROM_QSTR(MP_QSTR_VGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_VGA) },
{ MP_ROM_QSTR(MP_QSTR_SVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_SVGA) },
{ MP_ROM_QSTR(MP_QSTR_XGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_XGA) },
{ MP_ROM_QSTR(MP_QSTR_HD), MP_ROM_INT((mp_uint_t)FRAMESIZE_HD) },
{ MP_ROM_QSTR(MP_QSTR_SXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_SXGA) },
{ MP_ROM_QSTR(MP_QSTR_UXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_UXGA) },
{ MP_ROM_QSTR(MP_QSTR_FHD), MP_ROM_INT((mp_uint_t)FRAMESIZE_FHD) },
{ MP_ROM_QSTR(MP_QSTR_P_HD), MP_ROM_INT((mp_uint_t)FRAMESIZE_P_HD) },
{ MP_ROM_QSTR(MP_QSTR_P_3MP), MP_ROM_INT((mp_uint_t)FRAMESIZE_P_3MP) },
{ MP_ROM_QSTR(MP_QSTR_QXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_QXGA) },
{ MP_ROM_QSTR(MP_QSTR_QHD), MP_ROM_INT((mp_uint_t)FRAMESIZE_QHD) },
{ MP_ROM_QSTR(MP_QSTR_WQXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_WQXGA) },
{ MP_ROM_QSTR(MP_QSTR_P_FHD), MP_ROM_INT((mp_uint_t)FRAMESIZE_P_FHD) },
{ MP_ROM_QSTR(MP_QSTR_QSXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_QSXGA) },
};

const mp_rom_map_elem_t mp_camera_hal_grab_mode_table[] = {
{ MP_ROM_QSTR(MP_QSTR_WHEN_EMPTY), MP_ROM_INT(CAMERA_GRAB_WHEN_EMPTY) },
{ MP_ROM_QSTR(MP_QSTR_LATEST), MP_ROM_INT(CAMERA_GRAB_LATEST) },
{ MP_ROM_QSTR(MP_QSTR_WHEN_EMPTY), MP_ROM_INT((mp_uint_t)CAMERA_GRAB_WHEN_EMPTY) },
{ MP_ROM_QSTR(MP_QSTR_LATEST), MP_ROM_INT((mp_uint_t)CAMERA_GRAB_LATEST) },
};

const mp_rom_map_elem_t mp_camera_hal_gainceiling_table[] = {
{ MP_ROM_QSTR(MP_QSTR_2X), MP_ROM_INT(GAINCEILING_2X) },
{ MP_ROM_QSTR(MP_QSTR_4X), MP_ROM_INT(GAINCEILING_4X) },
{ MP_ROM_QSTR(MP_QSTR_8X), MP_ROM_INT(GAINCEILING_8X) },
{ MP_ROM_QSTR(MP_QSTR_16X), MP_ROM_INT(GAINCEILING_16X) },
{ MP_ROM_QSTR(MP_QSTR_32X), MP_ROM_INT(GAINCEILING_32X) },
{ MP_ROM_QSTR(MP_QSTR_64X), MP_ROM_INT(GAINCEILING_64X) },
{ MP_ROM_QSTR(MP_QSTR_128X), MP_ROM_INT(GAINCEILING_128X) },
{ MP_ROM_QSTR(MP_QSTR_2X), MP_ROM_INT((mp_uint_t)GAINCEILING_2X) },
{ MP_ROM_QSTR(MP_QSTR_4X), MP_ROM_INT((mp_uint_t)GAINCEILING_4X) },
{ MP_ROM_QSTR(MP_QSTR_8X), MP_ROM_INT((mp_uint_t)GAINCEILING_8X) },
{ MP_ROM_QSTR(MP_QSTR_16X), MP_ROM_INT((mp_uint_t)GAINCEILING_16X) },
{ MP_ROM_QSTR(MP_QSTR_32X), MP_ROM_INT((mp_uint_t)GAINCEILING_32X) },
{ MP_ROM_QSTR(MP_QSTR_64X), MP_ROM_INT((mp_uint_t)GAINCEILING_64X) },
{ MP_ROM_QSTR(MP_QSTR_128X), MP_ROM_INT((mp_uint_t)GAINCEILING_128X) },
};

// Helper functions to get and set camera and sensor information
Expand Down

0 comments on commit 061c2a6

Please sign in to comment.