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:
- 24:cc4271d1545f
- Parent:
- 23:214896356355
- Child:
- 25:8f6c2a094544
- Child:
- 27:f31bff7335ae
--- a/MARY_CAMERA.cpp Wed Mar 12 00:46:48 2014 +0000 +++ b/MARY_CAMERA.cpp Thu Mar 13 04:44:34 2014 +0000 @@ -174,10 +174,14 @@ return _error_state; // return last state of I2C access } +extern int read_order_change; + void MARY_CAMERA::transfer_a_line( short *p, int line_number, int x_offset, int n_of_pixels ) { +#if 0 + char tmp; - + if ( line_number < 0 ) return; @@ -192,6 +196,43 @@ tmp = read_register( CAMERA_DATA_REGISTER ); // read lower byte *p++ = (read_register( CAMERA_DATA_REGISTER ) << 8) | tmp; // read upper byte } + +#else + + + short tmp; + + if ( line_number < 0 ) + return; + + // set camera module's buffer address + set_address( line_number * horizontal_size() * BYTE_PER_PIXEL + x_offset * BYTE_PER_PIXEL ); + + // put a read command, first return byte should be ignored + read_register( CAMERA_DATA_REGISTER ); + + + if ( read_order_change ) { + + read_register( CAMERA_DATA_REGISTER ); + + for( int x = 0; x < n_of_pixels; x++ ) { + // perform 2 bytes read. a pixel data is in RGB565 format (16bits) + tmp = read_register( CAMERA_DATA_REGISTER ) << 8; // read lower byte + *p++ = (read_register( CAMERA_DATA_REGISTER ) << 0) | tmp; // read upper byte + } + + } else { + + for( int x = 0; x < n_of_pixels; x++ ) { + // perform 2 bytes read. a pixel data is in RGB565 format (16bits) + tmp = read_register( CAMERA_DATA_REGISTER ); // read lower byte + *p++ = (read_register( CAMERA_DATA_REGISTER ) << 8) | tmp; // read upper byte + } + + } + +#endif } void MARY_CAMERA::open_transfer( void )