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.
Dependencies: MARY_CAMERA NokiaLCD mbed
Diff: main.cpp
- Revision:
- 28:ef40d40b5d39
- Parent:
- 27:625e40d60c7b
- Child:
- 29:a026f42d0498
- Child:
- 30:eaab2c4bbe22
--- a/main.cpp Wed Mar 12 06:21:03 2014 +0000 +++ b/main.cpp Thu Mar 13 04:44:50 2014 +0000 @@ -21,11 +21,15 @@ void line_mirroring( short *buf ); void save_still_image( char *file_name ); void oled_test_screen( void ); +void capture_to_bmp( void ); -#define SAVE_EACH_SIZES_OF_STILL_IMAGE +//#define SAVE_EACH_SIZES_OF_STILL_IMAGE +int read_order_change = 0; int main() { + printf( "\r\n\r\nMARY-CAMERA test program\r\n\r\n" ); + led = 0x3; oled1.cls(); @@ -54,20 +58,56 @@ #endif #endif + printf( " camera operation started\r\n" ); + printf( " hit key [c] for saving data into BMP\r\n" ); + printf( " hit key [o] to change data reading order\r\n" ); + printf( " hit key [1], [2], [3] or [4] to change resolution QCIF, QQVGA, QVGA, VGA\r\n" ); -// test_camera_QCIF_video_with_colorbar(); // doesn't return - test_camera_resolution_change(); // doesn't return + test_camera_QCIF_video_with_colorbar(); // doesn't return +// test_camera_resolution_change(); // doesn't return } +Serial pc(USBTX, USBRX); // tx, rx void test_camera_QCIF_video_with_colorbar( void ) { int count = 0; while ( 1 ) { + + if ( pc.readable() ) { + switch ( pc.getc() ) { + case 'c' : + capture_to_bmp(); + printf( " [c] : capture started\r\n" ); + break; + case 'o' : + read_order_change = read_order_change ? 0 : 1; + printf( " [o] read order change : %s\r\n", read_order_change ? "ENABLED" : "DISABLED" ); + break; + case '1' : + printf( " [1] resolution change : QCIF\r\n" ); + camera.resolution( MARY_CAMERA::QCIF ); + break; + case '2' : + printf( " [1] resolution change : QQVGA\r\n" ); + camera.resolution( MARY_CAMERA::QQVGA ); + break; + case '3' : + printf( " [1] resolution change : QVGA\r\n" ); + camera.resolution( MARY_CAMERA::QVGA ); + break; + case '4' : + printf( " [1] resolution change : VGA\r\n" ); + camera.resolution( MARY_CAMERA::VGA ); + break; + } + } + + led = 0x1; copy_image_to_oled(); - camera.colorbar( ((count++ >> 2) & 0x1) ? MARY_CAMERA::ON : MARY_CAMERA::OFF ); +// camera.colorbar( ((count++ >> 2) & 0x1) ? MARY_CAMERA::ON : MARY_CAMERA::OFF ); led = 0x2; } } @@ -85,7 +125,7 @@ camera.resolution( (MARY_CAMERA::CameraResolution)(setting + 1) ); led = 0x1 << setting; } - + count++; copy_image_to_oled(); @@ -168,4 +208,65 @@ camera.close_transfer(); close_BMP(); -} \ No newline at end of file +} + +void capture_to_bmp( void ) +{ + short buf[ camera.horizontal_size() ]; + camera.open_transfer(); + +#if 0 + for ( int line = 0; line < MARMEX_OB_oled::HEIGHT; line++ ) { + camera.transfer_a_line( buf, line + (camera.vertical_size() - (int)MARMEX_OB_oled::HEIGHT) / 2, (camera.horizontal_size() - (int)MARMEX_OB_oled::WIDTH ) / 2, MARMEX_OB_oled::WIDTH ); + line_mirroring( buf ); + oled1.blit565( 0, line, MARMEX_OB_oled::WIDTH, 1, buf ); + } +#endif + + if ( open_BMP( "RGB.bmp", camera.horizontal_size(), camera.vertical_size() ) ) + return; + + for ( int line = (camera.vertical_size() - 1); 0 <= line; line-- ) { + camera.transfer_a_line( buf, line, 0, camera.horizontal_size() ); + write_BMP( buf, camera.horizontal_size(), 0x7 ); + } + + close_BMP(); + +#if 0 + + if ( open_BMP( "R.bmp", camera.horizontal_size(), camera.vertical_size() ) ) + return; + + for ( int line = (camera.vertical_size() - 1); 0 <= line; line-- ) { + camera.transfer_a_line( buf, line, 0, camera.horizontal_size() ); + write_BMP( buf, camera.horizontal_size(), 0x4 ); + } + + close_BMP(); + + + if ( open_BMP( "G.bmp", camera.horizontal_size(), camera.vertical_size() ) ) + return; + + for ( int line = (camera.vertical_size() - 1); 0 <= line; line-- ) { + camera.transfer_a_line( buf, line, 0, camera.horizontal_size() ); + write_BMP( buf, camera.horizontal_size(), 0x2 ); + } + + close_BMP(); + + + if ( open_BMP( "B.bmp", camera.horizontal_size(), camera.vertical_size() ) ) + return; + + for ( int line = (camera.vertical_size() - 1); 0 <= line; line-- ) { + camera.transfer_a_line( buf, line, 0, camera.horizontal_size() ); + write_BMP( buf, camera.horizontal_size(), 0x1 ); + } + + close_BMP(); + +#endif + camera.close_transfer(); +}