Tedd OKANO / Mbed 2 deprecated MARY_CAMERA_Hello

Dependencies:   MARY_CAMERA NokiaLCD mbed

Committer:
okano
Date:
Mon Mar 10 02:11:25 2014 +0000
Revision:
21:a2ac746dd516
Parent:
16:fa1bd83e34b0
Parent:
12:6ddd07d59c55
Child:
22:d5e24ab4afb7
1st frame saving into mbed storage if the mbed is blue or yellow

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:1062142e5718 1 #include "mbed.h"
okano 0:1062142e5718 2 #include "MARMEX_OB_oled.h"
okano 4:5e1828a8e238 3 #include "MARY_CAMERA.h"
okano 3:152362acd181 4
okano 16:fa1bd83e34b0 5 #if defined( TARGET_MBED_LPC1768 ) || defined( TARGET_LPC11U24_401 )
okano 16:fa1bd83e34b0 6
okano 4:5e1828a8e238 7 MARMEX_OB_oled oled1( p5, p7, p20, p16, p15 ); // mosi, sclk, cs, rst, power_control -- maple-mini-type-b-slot1
okano 6:f5b4e088087b 8 MARY_CAMERA camera( p5, p6, p7, p22, p26, p28, p27 ); // mosi, miso, sclk, cs, reset, I2C_SDA, I2C_SCL
okano 16:fa1bd83e34b0 9
okano 16:fa1bd83e34b0 10 #endif
okano 16:fa1bd83e34b0 11
okano 16:fa1bd83e34b0 12 #if defined( TARGET_LPC11U35_401 )
okano 16:fa1bd83e34b0 13
okano 16:fa1bd83e34b0 14 MARMEX_OB_oled oled1( P0_9, P0_10, P0_16, P0_12, P0_11 ); // mosi, sclk, cs, rst, power_control -- maple-mini-type-b-slot1
okano 16:fa1bd83e34b0 15 MARY_CAMERA camera( P0_9, P0_8, P0_10, P0_2, P1_15, P0_5, P0_4 ); // mosi, miso, sclk, cs, reset, I2C_SDA, I2C_SCL
okano 16:fa1bd83e34b0 16
okano 16:fa1bd83e34b0 17 #endif
okano 16:fa1bd83e34b0 18
okano 9:68408189efde 19 BusOut led( LED3, LED4 );
okano 1:ce27bc7b44d4 20
okano 9:68408189efde 21 #define X_OFFSET ((MARY_CAMERA::PIXEL_PER_LINE - MARMEX_OB_oled::WIDTH ) / 2)
okano 9:68408189efde 22 #define Y_OFFSET ((MARY_CAMERA::LINE_PER_FRAME - MARMEX_OB_oled::HEIGHT) / 2)
okano 9:68408189efde 23
okano 9:68408189efde 24 void line_mirroring( short *buf );
okano 10:3c8fc9569377 25 void save_still_image( char *file_name );
okano 16:fa1bd83e34b0 26 void oled_test_screen( void );
okano 0:1062142e5718 27
okano 0:1062142e5718 28 int main()
okano 0:1062142e5718 29 {
okano 6:f5b4e088087b 30 led = 0x3;
okano 6:f5b4e088087b 31
okano 1:ce27bc7b44d4 32 oled1.cls();
okano 16:fa1bd83e34b0 33 oled_test_screen();
okano 1:ce27bc7b44d4 34
okano 9:68408189efde 35 short buf[ MARMEX_OB_oled::WIDTH ];
okano 0:1062142e5718 36
okano 21:a2ac746dd516 37 #if defined( TARGET_MBED_LPC1768 ) || defined( TARGET_LPC11U24_401 )
okano 21:a2ac746dd516 38 save_still_image( "image.bmp" );
okano 12:6ddd07d59c55 39 #endif
okano 10:3c8fc9569377 40
okano 0:1062142e5718 41 while ( 1 ) {
okano 7:380026dd09fd 42
okano 7:380026dd09fd 43 led = 0x1;
okano 4:5e1828a8e238 44 camera.open_transfer();
okano 0:1062142e5718 45
okano 10:3c8fc9569377 46 for ( int line = 0; line < MARMEX_OB_oled::HEIGHT; line++ ) {
okano 10:3c8fc9569377 47 camera.transfer_a_line( buf, line + Y_OFFSET, X_OFFSET, MARMEX_OB_oled::WIDTH );
okano 9:68408189efde 48 line_mirroring( buf );
okano 10:3c8fc9569377 49 oled1.blit565( 0, line, MARMEX_OB_oled::WIDTH, 1, buf );
okano 0:1062142e5718 50 }
okano 0:1062142e5718 51
okano 4:5e1828a8e238 52 camera.close_transfer();
okano 6:f5b4e088087b 53 led = 0x2;
okano 0:1062142e5718 54 }
okano 0:1062142e5718 55 }
okano 6:f5b4e088087b 56
okano 9:68408189efde 57
okano 9:68408189efde 58 void line_mirroring( short *buf )
okano 9:68408189efde 59 {
okano 9:68408189efde 60 short tmp;
okano 9:68408189efde 61
okano 9:68408189efde 62 for ( int i = 0; i < (MARMEX_OB_oled::WIDTH / 2); i++ ) {
okano 9:68408189efde 63 tmp = buf[ i ];
okano 9:68408189efde 64 buf[ i ] = buf[ (MARMEX_OB_oled::WIDTH - 1) - i ];
okano 9:68408189efde 65 buf[ (MARMEX_OB_oled::WIDTH - 1) - i ] = tmp;
okano 9:68408189efde 66 }
okano 10:3c8fc9569377 67 }
okano 10:3c8fc9569377 68
okano 10:3c8fc9569377 69
okano 16:fa1bd83e34b0 70 void oled_test_screen( void )
okano 16:fa1bd83e34b0 71 {
okano 16:fa1bd83e34b0 72 oled1.background( 0x000000 );
okano 16:fa1bd83e34b0 73 oled1.cls();
okano 16:fa1bd83e34b0 74
okano 16:fa1bd83e34b0 75 int colorbar_width = MARMEX_OB_oled::WIDTH / 8;
okano 16:fa1bd83e34b0 76
okano 16:fa1bd83e34b0 77 for ( int i = 0; i < 8; i++ )
okano 16:fa1bd83e34b0 78 oled1.fill( colorbar_width * i, 0, colorbar_width, MARMEX_OB_oled::HEIGHT, ((i & 0x4) ? 0xFF0000 : 0x000000) | ((i & 0x2) ? 0x00FF00 : 0x000000) | ((i & 0x1) ? 0x0000FF : 0x000000) );
okano 16:fa1bd83e34b0 79
okano 16:fa1bd83e34b0 80 oled1.fill( 50, 50, 64, 64, 0xCCCCCC );;
okano 16:fa1bd83e34b0 81
okano 16:fa1bd83e34b0 82 oled1.locate( 0, 2 );
okano 16:fa1bd83e34b0 83 oled1.printf( "MaryCemara test" );
okano 16:fa1bd83e34b0 84 oled1.locate( 0, 4 );
okano 16:fa1bd83e34b0 85 oled1.printf( "%s", (MARY_CAMERA::NO_ERROR == camera.ready()) ? "Camera is ready" : "No Camera found" );
okano 16:fa1bd83e34b0 86
okano 21:a2ac746dd516 87 for (int i = 0; i < MARMEX_OB_oled::WIDTH; i++ )
okano 16:fa1bd83e34b0 88 oled1.pixel( i, 80 + sin( (float)i / 5.0 ) * 10, 0x000000 );
okano 21:a2ac746dd516 89 }
okano 21:a2ac746dd516 90
okano 21:a2ac746dd516 91
okano 10:3c8fc9569377 92 #include "bmp_handler.h"
okano 10:3c8fc9569377 93
okano 10:3c8fc9569377 94 void save_still_image( char *file_name )
okano 10:3c8fc9569377 95 {
okano 10:3c8fc9569377 96 short buf[ MARY_CAMERA::PIXEL_PER_LINE ];
okano 10:3c8fc9569377 97
okano 10:3c8fc9569377 98 if ( open_BMP( file_name ) )
okano 10:3c8fc9569377 99 return;
okano 10:3c8fc9569377 100
okano 10:3c8fc9569377 101 camera.open_transfer();
okano 10:3c8fc9569377 102
okano 10:3c8fc9569377 103 for ( int line = (MARY_CAMERA::LINE_PER_FRAME - 1); 0 <= line; line-- ) {
okano 10:3c8fc9569377 104 camera.transfer_a_line( buf, line, 0, MARY_CAMERA::PIXEL_PER_LINE );
okano 10:3c8fc9569377 105 write_BMP( buf, MARY_CAMERA::PIXEL_PER_LINE );
okano 10:3c8fc9569377 106 }
okano 10:3c8fc9569377 107 camera.close_transfer();
okano 11:149993faf2be 108
okano 10:3c8fc9569377 109 close_BMP();
okano 21:a2ac746dd516 110 }