Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: MARY_CAMERA.cpp
- Revision:
- 30:5d8e86cd337d
- Parent:
- 29:4432c5282c7b
- Child:
- 31:7599da3895e1
--- a/MARY_CAMERA.cpp Sat Mar 22 01:50:50 2014 +0000 +++ b/MARY_CAMERA.cpp Sat Mar 22 03:18:51 2014 +0000 @@ -49,7 +49,6 @@ #define RESET_RECOVERY_TIME 100 // mili-seconds #define COMMAND_INTERVAL 20 // mili-seconds - char camera_register_setting[ PARAM_NUM ][ 2 ] = { { 0x01, 0x40 }, { 0x02, 0x60 }, { 0x03, 0x02 }, { 0x0C, 0x0C }, { 0x0E, 0x61 }, { 0x0F, 0x4B }, { 0x11, 0x81 }, { 0x12, 0x04 }, @@ -97,11 +96,12 @@ _reset = 0; wait_ms( RESET_PULSE_WIDTH ); // assert RESET signal _reset = 1; + wait_ms( RESET_RECOVERY_TIME ); // deassert RESET signal if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, camera_reset_command, 2 )) ) return _error_state; // return non-zero if I2C access failed - wait_ms( RESET_RECOVERY_TIME ); // deassert RESET signal + wait_ms( 100 ); // deassert RESET signal _horizontal_size = QCIF_PIXEL_PER_LINE; _vertical_size = QCIF_LINE_PER_FRAME; @@ -116,7 +116,6 @@ } } } -#endif switch ( res ) { case QCIF: @@ -137,6 +136,8 @@ break; } +#endif + for ( int i = 0; i < PARAM_NUM; i++ ) { if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, camera_register_setting[ i ], 2 )) ) break; @@ -145,17 +146,41 @@ } #ifndef UNIFIED_RESOLUTION_CHANGE - char d[ 2 ]; - for ( int i = 0; i < RES_CHANGE_PARAM_NUM; i++ ) { - d[ 0 ] = res_change_param[ 0 ][ i ]; - d[ 1 ] = res_change_param[ res ][ i ]; + if ( QCIF != res ) { + char d[ 2 ]; + for ( int i = 0; i < RES_CHANGE_PARAM_NUM; i++ ) { + d[ 0 ] = res_change_param[ 0 ][ i ]; + d[ 1 ] = res_change_param[ res ][ i ]; + + if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, d, 2 )) ) + break; + + wait_ms( COMMAND_INTERVAL ); // camera register writing requires this interval + } + } - if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, d, 2 )) ) + switch ( res ) { + case QCIF: + _horizontal_size = QCIF_PIXEL_PER_LINE; + _vertical_size = QCIF_LINE_PER_FRAME; + break; + case VGA: + _horizontal_size = VGA_PIXEL_PER_LINE; + _vertical_size = VGA_LINE_PER_FRAME; + break; + case QVGA: + _horizontal_size = VGA_PIXEL_PER_LINE / 2; + _vertical_size = VGA_LINE_PER_FRAME / 2; + break; + case QQVGA: + _horizontal_size = VGA_PIXEL_PER_LINE / 4; + _vertical_size = VGA_LINE_PER_FRAME / 4; break; } + +printf( "resolution : h,v = %d,%d\r\n", _horizontal_size, _vertical_size ); #endif - return _error_state; // return non-zero if I2C access failed }