MARMEX_VB test application program. This application works on "mbed NXP LPC1768" only. This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with MARMEX_OB module (on slot1)
Dependencies: MARMEX_VB NokiaLCD mbed
This is the library test program.
The program can test features of the library (refer to MARMEX-VB's API document) and can save captured data into BMP file.
Warning!
This test program can run on "mbed NXP LPC1768" only.
Picture : sample of test program operation
The modules of MARMEX-VB and MARMEX-OB are set on the "MAPLE mini type-B (MARM03-BASE)" baseboard.
The image data from camera is mirrored and alpha graphics added by software.
Revision 8:86aae677a68b, committed 2014-06-20
- Comitter:
- nxpfan
- Date:
- Fri Jun 20 09:05:45 2014 +0000
- Parent:
- 7:125538c50c22
- Commit message:
- SPI-FIFO operation option added
Changed in this revision
diff -r 125538c50c22 -r 86aae677a68b MARMEX_OB_oled.h --- a/MARMEX_OB_oled.h Thu Jun 19 12:21:50 2014 +0000 +++ b/MARMEX_OB_oled.h Fri Jun 20 09:05:45 2014 +0000 @@ -2,8 +2,8 @@ * * @class MARMEX_OB_oled * @author tedd - * @version 0.54 (optimized for "line data transfer") - * @date 19-Jun-2014 + * @version 0.55 (optimized for "line data transfer") + * @date 20-Jun-2014 * * Released under the MIT License: http://mbed.org/license/mit * @@ -22,6 +22,19 @@ #include "mbed.h" #include "NokiaLCD.h" +//#define LINE_WRITE_OPT NO_OPTIMIZATION +#define LINE_WRITE_OPT LOOP_UNROLL +//#define LINE_WRITE_OPT USING_SSP_FIFO + +/* Setting for "LINE_WRITE_OPT == USING_SSP_FIFO" + * Choose one line from next 3 lines when the FIFO option is taken + */ +#define SSP_AUTO_SELECTION // for demo setup on "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1) +//#define SSP_USE_SSP0 +//#define SSP_USE_SSP1 + + + /** @def MARMEX_OB_SPI_8BIT_MODE * * MARMEX_OB_oled_oled OLED screen SPI access length setting @@ -320,10 +333,24 @@ } void blit565( int x, int y, int width, int height, short* colour ) { + + // OPTION REFERENCE NUMBER (DO NOT EDIT) + #define NO_OPTIMIZATION 0 + #define LOOP_UNROLL 1 + #define USING_SSP_FIFO 2 + _window( x, y, width, height ); -#define OPTIMIZE_KEEP_ASSERTING_CS_DURING_LINE_DATA_TRANSFER -#ifdef OPTIMIZE_KEEP_ASSERTING_CS_DURING_LINE_DATA_TRANSFER +#if ( LINE_WRITE_OPT == NO_OPTIMIZATION ) + + for (int i = 0; i < width * height; i++ ) { + _putp565( colour[i] ); + } + +#endif + + +#if ( LINE_WRITE_OPT == LOOP_UNROLL ) _cs = 0; @@ -353,43 +380,31 @@ _spi.write( 0x100 | *colour++ ); } - _cs = 0; - -#else - for (int i = 0; i < width * height; i++ ) { - _putp565( colour[i] ); - } + _cs = 1; #endif - _cs = 1; - _window( 0, 0, WIDTH, HEIGHT ); - } - - - - void blit565_SPI_FIFO_WRITE( int x, int y, int width, int height, short* colour ) { - _window( x, y, width, height ); +#if ( LINE_WRITE_OPT == USING_SSP_FIFO ) -#define FIFO_DEPTH 4 - -#ifdef TARGET_MBED_LPC1768 -#define SPI_PORT_SELECTOR LPC_SSP1 -#endif + #define FIFO_DEPTH 4 -#ifdef TARGET_LPC11U35_501 -#define SPI_PORT_SELECTOR LPC_SSP0 -#endif + #if defined( SSP_AUTO_SELECTION ) + #if defined( TARGET_MBED_LPC1768 ) + #define SPI_PORT_SELECTOR LPC_SSP1 + #elif defined( TARGET_LPC11U35_501 ) || defined( TARGET_LPC11U24_401 ) + #define SPI_PORT_SELECTOR LPC_SSP0 + #endif + #elif defined( SSP_USE_SSP0 ) + #define SPI_PORT_SELECTOR LPC_SSP0 + #elif defined( SSP_USE_SSP1 ) + #define SPI_PORT_SELECTOR LPC_SSP1 + #else + #error when using FIFO option for the optimization, choose one of definition from SSP_AUTO_SELECTION, SSP_USE_SSP0 or SSP_USE_SSP1 + #endif // #if defined( SSP_AUTO_SELECTION ) -#ifdef TARGET_LPC11U24_401 -#define SPI_PORT_SELECTOR LPC_SSP0 -#endif - - char dummy; - int n; - int length; - - length = width * height; + int length = width * height; + char dummy; + int n; _cs = 0; @@ -399,6 +414,8 @@ } do { +#pragma diag_suppress 550 // surpressing a warning messase of "Variable "dummy" was set but never used" + while (!(SPI_PORT_SELECTOR->SR & 0x4)); dummy = SPI_PORT_SELECTOR->DR; @@ -413,12 +430,12 @@ } while(n < length); +#endif _cs = 1; _window( 0, 0, WIDTH, HEIGHT ); } - void bitblit( int x, int y, int width, int height, const char* bitstream ) { _cs = 0; _window( x, y, width, height ); @@ -583,4 +600,3 @@ -
diff -r 125538c50c22 -r 86aae677a68b MARMEX_VB.lib --- a/MARMEX_VB.lib Thu Jun 19 12:21:50 2014 +0000 +++ b/MARMEX_VB.lib Fri Jun 20 09:05:45 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/CQ-Publishing/code/MARMEX_VB/#8ef31b67c0ab +http://mbed.org/teams/CQ-Publishing/code/MARMEX_VB/#84e6c89a9a6d
diff -r 125538c50c22 -r 86aae677a68b main.cpp --- a/main.cpp Thu Jun 19 12:21:50 2014 +0000 +++ b/main.cpp Fri Jun 20 09:05:45 2014 +0000 @@ -1,7 +1,7 @@ /** Test program for MARMEX_VB Camera control library * - * @version 0.3 - * @date 19-Jun-2014 + * @version 0.4 + * @date 20-Jun-2014 * * Released under the Apache License, Version 2.0 : http://mbed.org/handbook/Apache-Licence * @@ -171,11 +171,16 @@ // camera.colorbar( ((count++ >> 2) & 0x1) ? MARMEX_VB::ON : MARMEX_VB::OFF ); +#if 0 + #define SCREEN_TOP 9 + t = looptimer.read(); looptimer.reset(); oled1.locate( 0, 0 ); oled1.printf( " %.2f %s/s", 1.0 / t, interlace ? "field" : "frame" ); - +#else + #define SCREEN_TOP 0 +#endif led = 0x2; frame_count++; @@ -223,48 +228,6 @@ } } - -#define OPTIMIZATION_ENABLED -#define SCREEN_TOP 9 - -#ifdef OPTIMIZATION_ENABLED -void copy_image_from_camera_to_oled( void ) -{ - short buf[ MARMEX_OB_oled::WIDTH ]; // array size should be multiple of 8 for "mbed LPC1768" optimization - static int count = 0; - - camera.open_transfer(); - - for ( int line = SCREEN_TOP; line < MARMEX_OB_oled::HEIGHT; line++ ) { - camera.read_a_line_SPI_FIFO_READ( buf, line + (camera.get_vertical_size() - (int)MARMEX_OB_oled::HEIGHT) / 2, (camera.get_horizontal_size() - (int)MARMEX_OB_oled::WIDTH ) / 2, MARMEX_OB_oled::WIDTH ); - line_mirroring( buf ); - alpha( line, buf, ((count >> 4) & 1) ? 60 : 8, ((count >> 4) & 1) ^ ((count >> 3) & 1) ? ((int)MARMEX_OB_oled::HEIGHT - (ap.v + 4)) : 4 + SCREEN_TOP, &ap ); - oled1.blit565_SPI_FIFO_WRITE( 0, line, MARMEX_OB_oled::WIDTH, 1, buf ); - } - - count++; - camera.close_transfer(); -} - - -void copy_image_from_camera_to_oled_interlaced( void ) -{ - short buf[ MARMEX_OB_oled::WIDTH ]; - static int count = 0; - - camera.open_transfer(); - - for ( int line = ((count++) & 1) + SCREEN_TOP; line < MARMEX_OB_oled::HEIGHT; line += 2 ) { - camera.read_a_line_SPI_FIFO_READ( buf, line + (camera.get_vertical_size() - (int)MARMEX_OB_oled::HEIGHT) / 2, (camera.get_horizontal_size() - (int)MARMEX_OB_oled::WIDTH ) / 2, MARMEX_OB_oled::WIDTH ); - line_mirroring( buf ); - alpha( line, buf, ((count >> 4) & 1) ? 60 : 8, ((count >> 4) & 1) ^ ((count >> 3) & 1) ? ((int)MARMEX_OB_oled::HEIGHT - (ap.v + 4)) : 4 + SCREEN_TOP, &ap ); - oled1.blit565_SPI_FIFO_WRITE( 0, line, MARMEX_OB_oled::WIDTH, 1, buf ); - } - - camera.close_transfer(); -} - -#else void copy_image_from_camera_to_oled( void ) { short buf[ MARMEX_OB_oled::WIDTH ]; // array size should be multiple of 8 for "mbed LPC1768" optimization @@ -300,7 +263,7 @@ camera.close_transfer(); } -#endif + void copy_image_from_camera_to_oled_small( void ) {
diff -r 125538c50c22 -r 86aae677a68b mbed.bld --- a/mbed.bld Thu Jun 19 12:21:50 2014 +0000 +++ b/mbed.bld Fri Jun 20 09:05:45 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43 \ No newline at end of file