### Makefile Install, Uninstall, and Clean Rules Source: https://github.com/libdriver/ov2640/blob/main/CONTRIBUTING.md Provides commands for installing, uninstalling, and cleaning the project artifacts. Use 'make install' to deploy, 'make uninstall' to remove, and 'make clean' to remove build outputs. ```makefile # set install .PHONY .PHONY: install # install files install : $(shell if [ ! -d $(INC_INSTL_DIRS) ]; then mkdir $(INC_INSTL_DIRS); fi;) cp -rv $(INSTL_INCS) $(INC_INSTL_DIRS) cp -rv $(SHARED_LIB_NAME).$(VERSION) $(LIB_INSTL_DIRS) ln -sf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME).$(VERSION) $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME) cp -rv $(STATIC_LIB_NAME) $(LIB_INSTL_DIRS) cp -rv $(APP_NAME) $(BIN_INSTL_DIRS) # set install .PHONY .PHONY: uninstall # uninstall files uninstall : rm -rf $(INC_INSTL_DIRS) rm -rf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME).$(VERSION) rm -rf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME) rm -rf $(LIB_INSTL_DIRS)/$(STATIC_LIB_NAME) rm -rf $(BIN_INSTL_DIRS)/$(APP_NAME) # set clean .PHONY .PHONY: clean # clean the project clean : rm -rf $(APP_NAME) $(SHARED_LIB_NAME).$(VERSION) $(STATIC_LIB_NAME) ``` -------------------------------- ### Install Build Targets Source: https://github.com/libdriver/ov2640/blob/main/CONTRIBUTING.md Configures installation rules for runtime binaries, static libraries, and dynamic libraries with header files. ```cmake install(TARGETS ${CMAKE_PROJECT_NAME}_exe RUNTIME DESTINATION bin ) # install the static library install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION lib ) # install the dynamic library install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/${CMAKE_PROJECT_NAME} ) ``` -------------------------------- ### OV2640 Display Example Source: https://github.com/libdriver/ov2640/blob/main/project/stm32f407/README.md This example attempts to run the display functionality of the OV2640 camera. Note that the STM32F407 platform does not support this feature. ```shell ov2640 -e display --time=10 ov2640: STM32F407 doesn't support display. ``` -------------------------------- ### OV2640 Register Command Example Source: https://github.com/libdriver/ov2640/blob/main/project/stm32f407/README.md This example demonstrates setting and checking various registers for the OV2640 camera. It covers image dimensions, color settings, and special effects. Use this to verify individual register configurations. ```shell ov2640: set sde indirect register address 0. ov2640: check sde indirect register address ok. ov2640: ov2640_set_sde_indirect_register_data/ov2640_get_sde_indirect_register_data test. ov2640: set sde indirect register data 201. ov2640: check sde indirect register data ok. ov2640: ov2640_set_image_horizontal/ov2640_get_image_horizontal test. ov2640: set image horizontal 1423. ov2640: check image horizontal ok. ov2640: ov2640_set_image_vertical/ov2640_get_image_vertical test. ov2640: set image vertical 220. ov2640: check image vertical ok. ov2640: ov2640_set_quantization_scale_factor/ov2640_get_quantization_scale_factor test. ov2640: set quantization scale factor 15. ov2640: check quantization scale factor ok. ov2640: ov2640_set_lp_dp/ov2640_get_lp_dp test. ov2640: enable lp dp. ov2640: check lp dp ok. ov2640: disable lp dp. ov2640: check lp dp ok. ov2640: ov2640_set_round/ov2640_get_round test. ov2640: enable round. ov2640: check round ok. ov2640: disable round. ov2640: check round ok. ov2640: ov2640_set_vertical_divider/ov2640_get_vertical_divider test. ov2640: set vertical divider 0. ov2640: check vertical divider ok. ov2640: ov2640_set_horizontal_divider/ov2640_get_horizontal_divider test. ov2640: set horizontal divider 1. ov2640: check horizontal divider ok. ov2640: ov2640_set_horizontal_size/ov2640_get_horizontal_size test. ov2640: set horizontal size 139. ov2640: check horizontal size ok. ov2640: ov2640_set_vertical_size/ov2640_get_vertical_size test. ov2640: set vertical size 125. ov2640: check vertical size ok. ov2640: ov2640_set_offset_x/oov2640_get_offset_x test. ov2640: set offset x 1294. ov2640: check offset x ok. ov2640: ov2640_set_offset_y/oov2640_get_offset_y test. ov2640: set offset y 1421. ov2640: check offset y ok. ov2640: ov2640_set_dp_selx/ov2640_get_dp_selx test. ov2640: set dp selx 9. ov2640: check dp selx ok. ov2640: ov2640_set_dp_sely/ov2640_get_dp_sely test. ov2640: set dp sely 13. ov2640: check dp sely ok. ov2640: ov2640_set_output_width/ov2640_get_output_wide test. ov2640: set output width 198. ov2640: check output width ok. ov2640: ov2640_set_output_height/ov2640_get_output_height test. ov2640: set output height 340. ov2640: check output height ok. ov2640: ov2640_set_zoom_speed/ov2640_get_zoom_speed test. ov2640: set zoom speed 0. ov2640: check zoom speed ok. ov2640: ov2640_set_light_mode test. ov2640: check light mode auto ok. ov2640: check light mode sunny ok. ov2640: check light mode cloudy ok. ov2640: check light mode office ok. ov2640: check light mode home ok. ov2640: ov2640_set_color_saturation test. ov2640: check color saturation +2 ok. ov2640: check color saturation +1 ok. ov2640: check color saturation 0 ok. ov2640: check color saturation -1 ok. ov2640: check color saturation -2 ok. ov2640: ov2640_set_brightness test. ov2640: check brightness +2 ok. ov2640: check brightness +1 ok. ov2640: check brightness 0 ok. ov2640: check brightness -1 ok. ov2640: check brightness -2 ok. ov2640: ov2640_set_contrast test. ov2640: check contrast +2 ok. ov2640: check contrast +1 ok. ov2640: check contrast 0 ok. ov2640: check contrast -1 ok. ov2640: check contrast -2 ok. ov2640: ov2640_set_special_effect test. ov2640: check special effect antique ok. ov2640: check special effect bluish ok. ov2640: check special effect greenish ok. ov2640: check special effect reddish ok. ov2640: check special effect b&w ok. ov2640: check special effect negative ok. ov2640: check special effect b&w negative ok. ov2640: check special effect normal ok. ov2640: finish register test. ``` -------------------------------- ### OV2640 HSync Position and Width Start Point Configuration Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8h.html Functions to set and get the HSync position and width start point. ```APIDOC ## ov2640_set_hsync_position_and_width_start_point ### Description Sets the HSync position and width start point. ### Parameters - **handle** (*ov2640_handle_t*) - **position** (*uint16_t*) - The position value. ### Return Value *uint8_t* ``` ```APIDOC ## ov2640_get_hsync_position_and_width_start_point ### Description Gets the HSync position and width start point. ### Parameters - **handle** (*ov2640_handle_t*) - **position** (*uint16_t* *) - Pointer to store the position value. ### Return Value *uint8_t* ``` -------------------------------- ### OV2640 Photo Capture Example Source: https://github.com/libdriver/ov2640/blob/main/project/stm32f407/README.md This example demonstrates capturing a photo using the OV2640 camera and saving it to a specified path. It shows the DMA size, JPEG markers, and save confirmation. ```shell ov2640 -e photo --path=0:test.jpeg ov2640: dma size is 47360bytes. ov2640: found jpeg 0xFF 0xD8. ov2640: found jpeg 0xFF 0xD9. ov2640: save file(7115) 0:test.jpeg. ``` -------------------------------- ### OV2640 Horizontal Window Start Configuration Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8h.html Function to set the horizontal window start. ```APIDOC ## ov2640_set_horizontal_window_start ### Description Sets the horizontal window start. ### Parameters - **handle** (*ov2640_handle_t*) - **start** (*uint16_t*) - The start value. ### Return Value *uint8_t* ``` -------------------------------- ### ov2640_set_hsync_position_and_width_start_point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/globals_func.html Sets the start point for the HSYNC position and width. ```APIDOC ## ov2640_set_hsync_position_and_width_start_point ### Description Sets the start point for the HSYNC position and width. ### Function Signature ```c void ov2640_set_hsync_position_and_width_start_point(void); ``` ``` -------------------------------- ### ov2640_get_vertical_window_line_start Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8c.html Retrieves the starting line of the vertical window from the OV2640 sensor. ```APIDOC ## ov2640_get_vertical_window_line_start ### Description Retrieves the starting line of the vertical window from the OV2640 sensor. ### Parameters * **handle** ([ov2640_handle_t](group__ov2640__sensor__driver.html#ga87a35a65c2fa8e9e5784d1a28bbeb796) *) - Pointer to the OV2640 device handle. * **start** (uint16_t *) - Pointer to a variable where the starting line number will be stored. ### Returns * uint8_t - Status code indicating success or failure. ``` -------------------------------- ### ov2640_set_vertical_window_line_start Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8c.html Sets the starting line for the vertical window in the OV2640 sensor. ```APIDOC ## ov2640_set_vertical_window_line_start ### Description Sets the starting line for the vertical window in the OV2640 sensor. ### Parameters * **handle** ([ov2640_handle_t](group__ov2640__sensor__driver.html#ga87a35a65c2fa8e9e5784d1a28bbeb796) *) - Pointer to the OV2640 device handle. * **start** (uint16_t) - The starting line number for the vertical window. ### Returns * uint8_t - Status code indicating success or failure. ``` -------------------------------- ### Zoom Window Horizontal Start Point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8h.html Functions to enable/disable and get the status of the zoom window horizontal start point. ```APIDOC ## ov2640_set_zoom_window_horizontal_start_point ### Description Enables or disables the zoom window horizontal start point. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **enable** (*ov2640_bool_t*) - Set to enable or disable the feature. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` ```APIDOC ## ov2640_get_zoom_window_horizontal_start_point ### Description Gets the status of the zoom window horizontal start point (enabled or disabled). ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **enable** (*ov2640_bool_t*) - Pointer to store the status. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` -------------------------------- ### Zoom Mode Vertical Window Start Point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8h.html Functions to set and get the zoom mode vertical window start point. ```APIDOC ## ov2640_set_zoom_mode_vertical_window_start_point ### Description Sets the start point for the zoom mode vertical window. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **point** (*uint16_t*) - The start point value. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` ```APIDOC ## ov2640_get_zoom_mode_vertical_window_start_point ### Description Gets the start point for the zoom mode vertical window. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **point** (*uint16_t*) - Pointer to store the start point value. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` -------------------------------- ### get zoom mode vertical window start point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__sensor__driver.html Retrieves the starting point of the vertical window for zoom mode in the OV2640 sensor. ```APIDOC ## get zoom mode vertical window start point() ### Description Gets the zoom mode vertical window start point. ### Parameters #### Input Parameters * **handle** (*ov2640_handle_t* *) - Pointer to an ov2640 handle structure. #### Output Parameters * **point** (*point* *) - Pointer to a point buffer. ### Returns * **status code** - * 0: Success * 1: Get zoom mode vertical window start point failed * 2: Handle is NULL * 3: Handle is not initialized ``` -------------------------------- ### Initialize and Display Image with OV2640 Source: https://github.com/libdriver/ov2640/blob/main/README.md Initializes the OV2640 driver, sets it to RGB565 mode, configures image resolution to QQVGA, and includes a delay before proceeding with display operations. Ensure platform-specific SCCB and DVP drivers are implemented. ```C #include "driver_ov2640_basic.h" uint8_t res; /* basic init */ res = ov2640_basic_init(); if (res != 0) { return 1; } /* set to rgb565 mode */ res = ov2640_basic_set_rgb565_mode(); if (res != 0) { (void)ov2640_basic_deinit(); return 1; } /* set image resolution */ res = ov2640_basic_set_image_resolution(OV2640_IMAGE_RESOLUTION_QQVGA); if (res != 0) { (void)ov2640_basic_deinit(); return 1; } /* delay 500ms */ ov2640_interface_delay_ms(500); ... /* finish your display progress */ ... /* ov2640 deinit */ (void)ov2640_basic_deinit(); return 0; ``` -------------------------------- ### Zoom Window Horizontal Start Point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__sensor__driver.html Functions to enable/disable and get the status of the zoom window horizontal start point for the OV2640 sensor. ```APIDOC ## ov2640_set_zoom_window_horizontal_start_point ### Description Enables or disables the zoom window horizontal start point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **enable** (*ov2640_bool_t*) - Set to enable or disable the zoom window horizontal start point. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` ```APIDOC ## ov2640_get_zoom_window_horizontal_start_point ### Description Gets the status of the zoom window horizontal start point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **enable** (*ov2640_bool_t* *) - Pointer to store the status (enabled/disabled). ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` -------------------------------- ### ov2640_init Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640__basic_8c_source.html Initializes the OV2640 camera chip. ```APIDOC ## ov2640_init ### Description Initializes the chip. ### Function Signature ```c uint8_t ov2640_init(ov2640_handle_t *handle) ``` ### Parameters * **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 handle structure. ``` -------------------------------- ### Zoom Mode Vertical Window Start Point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__sensor__driver.html Functions to set and get the zoom mode vertical window start point for the OV2640 sensor. ```APIDOC ## ov2640_set_zoom_mode_vertical_window_start_point ### Description Sets the zoom mode vertical window start point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **point** (*uint16_t*) - The zoom mode vertical window start point value. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` ```APIDOC ## ov2640_get_zoom_mode_vertical_window_start_point ### Description Gets the zoom mode vertical window start point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **point** (*uint16_t* *) - Pointer to store the zoom mode vertical window start point value. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` -------------------------------- ### ov2640_table_init / ov2640_table_jpeg_init / ov2640_table_rgb565_init Source: https://context7.com/libdriver/ov2640/llms.txt Initializes the OV2640 sensor with pre-defined register tables. Use `ov2640_table_init` for general setup, `ov2640_table_jpeg_init` for JPEG output, and `ov2640_table_rgb565_init` for RGB565 output. These functions must be called after `ov2640_init`. ```APIDOC ## ov2640_table_init / ov2640_table_jpeg_init / ov2640_table_rgb565_init ### Description Writes pre-defined register tables to the sensor for general initialization, JPEG output mode, or RGB565 output mode respectively. Must be called after `ov2640_init`. ### Usage ```c #include "driver_ov2640.h" // General initialization (call first) if (ov2640_table_init(&gs_handle) != 0) { printf("table_init failed\n"); } // Switch to JPEG capture mode if (ov2640_table_jpeg_init(&gs_handle) != 0) { printf("jpeg_init failed\n"); } // Switch to RGB565 display mode if (ov2640_table_rgb565_init(&gs_handle) != 0) { printf("rgb565_init failed\n"); } ``` ``` -------------------------------- ### ov2640_get_zoom_mode_vertical_window_start_point Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__sensor__driver.html Gets the start point of the vertical window in zoom mode for the OV2640 sensor. ```APIDOC ## ov2640_get_zoom_mode_vertical_window_start_point ### Description Gets the start point of the vertical window in zoom mode for the OV2640 sensor. ### Parameters * **handle** (*ov2640_handle_t*) - Input - Pointer to an OV2640 handle structure. * **point** (*uint16_t*) - Output - Pointer to a point buffer. ### Returns * 0 success * 1 get zoom mode vertical window start point failed * 2 handle is NULL * 3 handle is not initialized ``` -------------------------------- ### ov2640_basic_init Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640__basic_8h.html Initializes the OV2640 camera in basic mode. ```APIDOC ## ov2640_basic_init ### Description Initializes the OV2640 camera in basic mode. ### Function Signature ```c uint8_t ov2640_basic_init(void); ``` ### Return Value Returns a status code indicating success or failure. ``` -------------------------------- ### Horizontal Window Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__sensor__driver.html Functions to set and get the horizontal window start and end points for the OV2640 sensor. ```APIDOC ## ov2640_set_horizontal_window_start ### Description Sets the horizontal window start point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **start** (*uint16_t*) - The horizontal window start point value. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` ```APIDOC ## ov2640_get_horizontal_window_start ### Description Gets the horizontal window start point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **start** (*uint16_t* *) - Pointer to store the horizontal window start point value. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` ```APIDOC ## ov2640_set_horizontal_window_end ### Description Sets the horizontal window end point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **end** (*uint16_t*) - The horizontal window end point value. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` ```APIDOC ## ov2640_get_horizontal_window_end ### Description Gets the horizontal window end point. ### Parameters - **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. - **end** (*uint16_t* *) - Pointer to store the horizontal window end point value. ### Returns *uint8_t* - Returns 0 if successful, an error code otherwise. ``` -------------------------------- ### Horizontal Window Configuration Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8h.html Functions to get and set the horizontal window start and end points for image capture. ```APIDOC ## ov2640_get_horizontal_window_start ### Description Gets the horizontal window start position. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **start** (*uint16_t*) - Pointer to store the horizontal window start value. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` ```APIDOC ## ov2640_set_horizontal_window_end ### Description Sets the horizontal window end position. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **end** (*uint16_t*) - The horizontal window end value. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` ```APIDOC ## ov2640_get_horizontal_window_end ### Description Gets the horizontal window end position. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 handle. - **end** (*uint16_t*) - Pointer to store the horizontal window end value. ### Returns - uint8_t - 0 if successful, error code otherwise. ``` -------------------------------- ### Initialize and Configure OV2640 Camera Source: https://context7.com/libdriver/ov2640/llms.txt Initializes the OV2640 camera with default settings, sets capture modes, configures image parameters, and deinitializes the camera. Ensure the platform interface layer is implemented. ```c #include "driver_ov2640_basic.h" int main(void) { /* initialize camera with all defaults (UXGA, RGB565, 50Hz band) */ if (ov2640_basic_init() != 0) { printf("basic init failed\n"); return 1; } /* switch to JPEG capture mode */ if (ov2640_basic_set_jpeg_mode() != 0) { printf("set jpeg mode failed\n"); } /* or switch to RGB565 display mode */ if (ov2640_basic_set_rgb565_mode() != 0) { printf("set rgb565 mode failed\n"); } /* set image parameters */ ov2640_basic_set_light_mode(OV2640_LIGHT_MODE_AUTO); ov2640_basic_set_brightness(OV2640_BRIGHTNESS_0); ov2640_basic_set_contrast(OV2640_CONTRAST_0); ov2640_basic_set_color_saturation(OV2640_COLOR_SATURATION_0); ov2640_basic_set_special_effect(OV2640_SPECIAL_EFFECT_NORMAL); /* set output resolution to VGA (640x480) */ if (ov2640_basic_set_image_resolution(OV2640_IMAGE_RESOLUTION_VGA) != 0) { printf("set image resolution failed\n"); } /* supported resolutions: QQVGA(160x120), QCIF(176x144), QVGA(320x240), WQVGA(400x240), CIF(352x288), VGA(640x480), SVGA(800x600), XGA(1024x768), WXGA(1280x800), XVGA(1280x960), WXGA_PLUS(1440x900), SXGA(1280x1024), UXGA(1600x1200) */ /* ... capture frames from DVP interface ... */ ov2640_basic_deinit(); return 0; } ``` -------------------------------- ### Vertical Window Configuration Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8h.html Functions to set and get the vertical window start and end lines for image capture. ```APIDOC ## ov2640_set_vertical_window_line_start ### Description Sets the starting line for the vertical window in image capture. ### Parameters - **handle** (*ov2640_handle_t*Required Pointer to the OV2640 device handle. - **start** (*uint16_t*Required The starting line for the vertical window. ### Return Value *uint8_t* - Returns the status of the operation. ``` ```APIDOC ## ov2640_get_vertical_window_line_start ### Description Gets the starting line of the vertical window. ### Parameters - **handle** (*ov2640_handle_t*Required Pointer to the OV2640 device handle. - **start** (*uint16_t*Output Pointer to store the starting line value. ### Return Value *uint8_t* - Returns the status of the operation. ``` ```APIDOC ## ov2640_set_vertical_window_line_end ### Description Sets the ending line for the vertical window in image capture. ### Parameters - **handle** (*ov2640_handle_t*Required Pointer to the OV2640 device handle. - **end** (*uint16_t*Required The ending line for the vertical window. ### Return Value *uint8_t* - Returns the status of the operation. ``` ```APIDOC ## ov2640_get_vertical_window_line_end ### Description Gets the ending line of the vertical window. ### Parameters - **handle** (*ov2640_handle_t*Required Pointer to the OV2640 device handle. - **end** (*uint16_t*Output Pointer to store the ending line value. ### Return Value *uint8_t* - Returns the status of the operation. ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/libdriver/ov2640/blob/main/CONTRIBUTING.md Configures the CMake minimum version, project name, version, C/C++ standards, and build types (Debug/Release). ```cmake # set the cmake minimum version cmake_minimum_required(VERSION 3.0) # set the project name and language project(demo C CXX) # read the version from files file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/VERSION ${CMAKE_PROJECT_NAME}_VERSION) # set the project version set(PROJECT_VERSION ${${CMAKE_PROJECT_NAME}_VERSION}) # set c standard c99 set(CMAKE_C_STANDARD 99) # enable c standard required set(CMAKE_C_STANDARD_REQUIRED True) # set c++ standard c++11 set(CMAKE_CXX_STANDARD 11) # enable c++ standard required set(CMAKE_CXX_STANDARD_REQUIRED True) # set debug level # set(CMAKE_BUILD_TYPE Debug) # set the debug flags of c # set(CMAKE_C_FLAGS_DEBUG "-O0 -g") # set the debug flags of c++ # set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") # set release level set(CMAKE_BUILD_TYPE Release) # set the release flags of c set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") # set the release flags of c++ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") ``` -------------------------------- ### OV2640 Vertical Window Configuration Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__sensor__driver.html Functions to set and get the vertical window start and end lines for the OV2640 sensor. ```APIDOC ## ov2640_set_vertical_window_line_start ### Description Sets the starting line for the vertical window in the OV2640 sensor's image capture. ### Parameters - **handle** (*ov2640_handle_t*): Pointer to the OV2640 device handle. - **start** (*uint16_t*): The starting line of the vertical window. ### Function Signature ```c uint8_t ov2640_set_vertical_window_line_start(ov2640_handle_t *handle, uint16_t start) ``` ## ov2640_get_vertical_window_line_start ### Description Retrieves the starting line of the vertical window from the OV2640 sensor. ### Parameters - **handle** (*ov2640_handle_t*): Pointer to the OV2640 device handle. - **start** (*uint16_t*): Pointer to a uint16_t variable where the starting line will be stored. ### Function Signature ```c uint8_t ov2640_get_vertical_window_line_start(ov2640_handle_t *handle, uint16_t *start) ``` ## ov2640_set_vertical_window_line_end ### Description Sets the ending line for the vertical window in the OV2640 sensor's image capture. ### Parameters - **handle** (*ov2640_handle_t*): Pointer to the OV2640 device handle. - **end** (*uint16_t*): The ending line of the vertical window. ### Function Signature ```c uint8_t ov2640_set_vertical_window_line_end(ov2640_handle_t *handle, uint16_t end) ``` ## ov2640_get_vertical_window_line_end ### Description Retrieves the ending line of the vertical window from the OV2640 sensor. ### Parameters - **handle** (*ov2640_handle_t*): Pointer to the OV2640 device handle. - **end** (*uint16_t*): Pointer to a uint16_t variable where the ending line will be stored. ### Function Signature ```c uint8_t ov2640_get_vertical_window_line_end(ov2640_handle_t *handle, uint16_t *end) ``` ``` -------------------------------- ### OV2640 Initialization and Link Functions Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640__basic_8c_source.html Macros for linking essential driver functions to the OV2640 handle. ```APIDOC ## DRIVER_OV2640_LINK_INIT ### Description Initializes the ov2640_handle_t structure. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `STRUCTURE`: The structure to initialize. ``` ```APIDOC ## DRIVER_OV2640_LINK_SCCB_INIT ### Description Links the sccb_init function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The sccb_init function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_POWER_DOWN_DEINIT ### Description Links the power_down_deinit function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The power_down_deinit function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_DELAY_MS ### Description Links the delay_ms function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The delay_ms function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_SCCB_READ ### Description Links the sccb_read function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The sccb_read function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_SCCB_WRITE ### Description Links the sccb_write function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The sccb_write function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_RESET_WRITE ### Description Links the reset_write function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The reset_write function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_SCCB_DEINIT ### Description Links the sccb_deinit function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The sccb_deinit function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_RESET_DEINIT ### Description Links the reset_deinit function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The reset_deinit function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_RESET_INIT ### Description Links the reset_init function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The reset_init function pointer. ``` ```APIDOC ## DRIVER_OV2640_LINK_DEBUG_PRINT ### Description Links the debug_print function to the driver. ### Parameters - `HANDLE`: A pointer to the ov2640_handle_t structure. - `FUC`: The debug_print function pointer. ``` -------------------------------- ### OV2640 HSYNC Position and Width Control Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8c.html Functions to set and get the end point and start point for HSYNC position and width of the OV2640 sensor. ```APIDOC ## ov2640_set_hsync_position_and_width_end_point ### Description Sets the end point for HSYNC position and width of the OV2640 sensor. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 device handle. - **position** (uint16_t) - The desired end point position. ## ov2640_get_hsync_position_and_width_end_point ### Description Gets the current end point for HSYNC position and width of the OV2640 sensor. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 device handle. - **position** (uint16_t*) - Pointer to store the current end point position. ## ov2640_set_hsync_position_and_width_start_point ### Description Sets the start point for HSYNC position and width of the OV2640 sensor. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 device handle. - **position** (uint16_t) - The desired start point position. ## ov2640_get_hsync_position_and_width_start_point ### Description Gets the current start point for HSYNC position and width of the OV2640 sensor. ### Parameters - **handle** (*ov2640_handle_t*) - Pointer to the OV2640 device handle. - **position** (uint16_t*) - Pointer to store the current start point position. ``` -------------------------------- ### Run OV2640 Photo Capture Example Source: https://github.com/libdriver/ov2640/blob/main/project/stm32f407/README.md Initiates the OV2640 photo capture function. Optionally, a path can be provided to save the captured image. If no path is specified, the image may be stored in a default location or handled by the driver's default behavior. ```shell ov2640 (-e photo | --example=photo) [--path=] ``` -------------------------------- ### Zoom Control Source: https://context7.com/libdriver/ov2640/llms.txt Enables digital zoom and configures zoom speed and vertical window start. Includes functions to get the current zoom status. ```APIDOC ## ov2640_set_zoom / ov2640_set_zoom_speed / ov2640_set_zoom_mode_vertical_window_start_point ### Description Enables digital zoom and configures the zoom speed and vertical window start for the zoom region. `ov2640_get_zoom` retrieves the current zoom status. ### Function Signatures ```c ov2640_err_t ov2640_set_zoom(ov2640_handle_t *handle, ov2640_bool_t enable); ov2640_err_t ov2640_set_zoom_speed(ov2640_handle_t *handle, uint8_t speed); ov2640_err_t ov2640_set_zoom_mode_vertical_window_start_point(ov2640_handle_t *handle, uint16_t start_point); ov2640_err_t ov2640_get_zoom(ov2640_handle_t *handle, ov2640_bool_t *enable); ``` ### Parameters #### `ov2640_set_zoom` - **handle** (*ov2640_handle_t*) - **enable** (*ov2640_bool_t*): `OV2640_BOOL_TRUE` to enable, `OV2640_BOOL_FALSE` to disable. #### `ov2640_set_zoom_speed` - **handle** (*ov2640_handle_t*) - **speed** (*uint8_t*): Zoom speed, range 0–0xF. #### `ov2640_set_zoom_mode_vertical_window_start_point` - **handle** (*ov2640_handle_t*) - **start_point** (*uint16_t*): Vertical start point, range 0–0x3FF. #### `ov2640_get_zoom` - **handle** (*ov2640_handle_t*) - **enable** (*ov2640_bool_t*): Pointer to store the zoom status. ### Request Example ```c // Enable zoom at speed 4 starting at vertical pixel 0 ov2640_set_zoom(&gs_handle, OV2640_BOOL_TRUE); ov2640_set_zoom_speed(&gs_handle, 4); ov2640_set_zoom_mode_vertical_window_start_point(&gs_handle, 0); // Disable zoom ov2640_set_zoom(&gs_handle, OV2640_BOOL_FALSE); ``` ``` -------------------------------- ### ov2640_table_rgb565_init Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640_8c.html Initializes the OV2640 sensor for RGB565 output. ```APIDOC ## ov2640_table_rgb565_init ### Description Initializes the OV2640 sensor for RGB565 output. ### Parameters * **handle** ([ov2640_handle_t](group__ov2640__sensor__driver.html#ga87a35a65c2fa8e9e5784d1a28bbeb796) *) - Pointer to the OV2640 device handle. ### Returns * uint8_t - Status code indicating success or failure. ``` -------------------------------- ### OV2640 Get Offset Y Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__dsp__driver.html Gets the current vertical offset (Y) setting for the OV2640 sensor. ```APIDOC ## ov2640_get_offset_y ### Description Gets the current vertical offset (Y) setting for the OV2640 sensor. ### Prototype ```c uint8_t ov2640_get_offset_y(ov2640_handle_t *handle, uint16_t *size) ``` ### Parameters * **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. * **size** (*uint16_t* *) - Pointer to store the retrieved vertical offset value. ``` -------------------------------- ### OV2640 Basic Initialization and Configuration Source: https://github.com/libdriver/ov2640/blob/main/doc/html/driver__ov2640__basic_8c_source.html Initializes the OV2640 sensor and sets default configurations for YUV422, RGB, RAW, and DP modes. Includes error handling and deinitialization on failure. ```c res = ov2640_set_yuv(&gs_handle, OV2640_BASIC_DEFAULT_DSP_YUV); if (res != 0) { ov2640_interface_debug_print("ov2640: set yuv failed.\n"); (void)ov2640_deinit(&gs_handle); return 1; } /* set default rgb */ res = ov2640_set_rgb(&gs_handle, OV2640_BASIC_DEFAULT_DSP_RGB); if (res != 0) { ov2640_interface_debug_print("ov2640: set rgb failed.\n"); (void)ov2640_deinit(&gs_handle); return 1; } /* set default raw */ res = ov2640_set_raw(&gs_handle, OV2640_BASIC_DEFAULT_DSP_RAW); if (res != 0) { ov2640_interface_debug_print("ov2640: set raw failed.\n"); (void)ov2640_deinit(&gs_handle); return 1; } /* set default dp selx */ res = ov2640_set_dp_selx(&gs_handle, OV2640_BASIC_DEFAULT_DSP_DP_SELX); if (res != 0) { ov2640_interface_debug_print("ov2640: set dp selx failed.\n"); (void)ov2640_deinit(&gs_handle); return 1; } /* set default dp sely */ res = ov2640_set_dp_sely(&gs_handle, OV2640_BASIC_DEFAULT_DSP_DP_SELY); if (res != 0) { ov2640_interface_debug_print("ov2640: set dp sely failed.\n"); (void)ov2640_deinit(&gs_handle); return 1; } /* disable dsp bypass */ res = ov2640_set_dsp_bypass(&gs_handle, OV2640_BOOL_FALSE); if (res != 0) { ov2640_interface_debug_print("ov2640: set dsp bypass failed.\n"); (void)ov2640_deinit(&gs_handle); return 1; } return 0; } ``` -------------------------------- ### ov2640_table_rgb565_init Source: https://github.com/libdriver/ov2640/blob/main/doc/html/globals_o.html Initializes the OV2640 sensor for RGB565 output using specific tables. ```APIDOC ## ov2640_table_rgb565_init() ### Description Initializes the OV2640 sensor for RGB565 image output, likely loading specific configuration tables for this format. ### Method (Not specified, likely a C function call) ### Parameters None ### Returns (Not specified) ``` -------------------------------- ### OV2640 Get Zoom Speed Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__dsp__driver.html Gets the current zoom speed setting for the OV2640 sensor. ```APIDOC ## ov2640_get_zoom_speed ### Description Gets the current zoom speed setting for the OV2640 sensor. ### Prototype ```c uint8_t ov2640_get_zoom_speed(ov2640_handle_t *handle, uint8_t *speed) ``` ### Parameters * **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. * **speed** (*uint8_t* *) - Pointer to store the retrieved zoom speed value. ``` -------------------------------- ### DRIVER_OV2640_LINK_INIT Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__link__driver.html Initializes the ov2640_handle_t structure with default values. ```APIDOC ## DRIVER_OV2640_LINK_INIT ### Description Initializes the [ov2640_handle_t](group__ov2640__sensor__driver.html#ga87a35a65c2fa8e9e5784d1a28bbeb796 "ov2640 handle structure definition") structure. ### Parameters * **HANDLE** (ov2640_handle_t*) - Pointer to an ov2640 handle structure. * **STRUCTURE** (ov2640_handle_t) - The structure to initialize. ### Value ```c memset(HANDLE, 0, sizeof(STRUCTURE)) ``` ``` -------------------------------- ### ov2640_interface_reset_init Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__interface__driver.html interface reset init ```APIDOC ## ov2640_interface_reset_init ### Description interface reset init ### Returns - uint8_t: status code (0 success, 1 reset init failed) ``` -------------------------------- ### OV2640 Get Output Height Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__dsp__driver.html Gets the current output height setting for the OV2640 sensor. ```APIDOC ## ov2640_get_output_height ### Description Gets the current output height setting for the OV2640 sensor. ### Prototype ```c uint8_t ov2640_get_output_height(ov2640_handle_t *handle, uint16_t *size) ``` ### Parameters * **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. * **size** (*uint16_t* *) - Pointer to store the retrieved output height value. ``` -------------------------------- ### OV2640 Get Output Width Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__dsp__driver.html Gets the current output width setting for the OV2640 sensor. ```APIDOC ## ov2640_get_output_width ### Description Gets the current output width setting for the OV2640 sensor. ### Prototype ```c uint8_t ov2640_get_output_width(ov2640_handle_t *handle, uint16_t *size) ``` ### Parameters * **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. * **size** (*uint16_t* *) - Pointer to store the retrieved output width value. ``` -------------------------------- ### Initialize and Capture Photo with OV2640 Source: https://github.com/libdriver/ov2640/blob/main/README.md Initializes the OV2640 driver, sets it to JPEG mode, configures image resolution to QQVGA, and includes a delay before proceeding with JPEG capture. Ensure platform-specific SCCB and DVP drivers are implemented. ```C #include "driver_ov2640_basic.h" uint8_t res; /* basic init */ res = ov2640_basic_init(); if (res != 0) { return 1; } /* set to jpeg mode */ res = ov2640_basic_set_jpeg_mode(); if (res != 0) { (void)ov2640_basic_deinit(); return 1; } /* set image resolution */ res = ov2640_basic_set_image_resolution(OV2640_IMAGE_RESOLUTION_QQVGA); if (res != 0) { (void)ov2640_basic_deinit(); return 1; } /* delay 500ms */ ov2640_interface_delay_ms(500); ... /* finish your jpeg captrue progress */ ... /* ov2640 deinit */ (void)ov2640_basic_deinit(); return 0; ``` -------------------------------- ### Show OV2640 Chip and Driver Information Source: https://github.com/libdriver/ov2640/blob/main/project/stm32f407/README.md Use this command to display the OV2640 chip and driver details. No specific setup is required beyond having the driver compiled. ```shell ov2640 (-i | --information) ``` -------------------------------- ### OV2640 Get Vertical Size Source: https://github.com/libdriver/ov2640/blob/main/doc/html/group__ov2640__dsp__driver.html Gets the current vertical size setting for the OV2640 sensor. ```APIDOC ## ov2640_get_vertical_size ### Description Gets the current vertical size setting for the OV2640 sensor. ### Prototype ```c uint8_t ov2640_get_vertical_size(ov2640_handle_t *handle, uint16_t *size) ``` ### Parameters * **handle** (*ov2640_handle_t* *) - Pointer to the OV2640 sensor handle. * **size** (*uint16_t* *) - Pointer to store the retrieved vertical size value. ```