Andrew Russell / Mbed 2 deprecated _____testcode_c

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //#include    "mbed.h"
00002 #include    <stdio.h>
00003 
00004 #include    "font_new.h"
00005 
00006 #ifdef   TEST
00007 extern unsigned char    screen[ SC_WIDTH * SC_HEIGHT ]    = { '.' };
00008 #endif
00009 
00010 void clear_screen( void );
00011 void show_screen( int xs, int width, int ys, int height );
00012 
00013 
00014 int main()
00015 {
00016     FontDrawInit();
00017     
00018     printf( "\r\n<< font drawing test >>\r\n" );
00019 #ifdef SMALL_TEST
00020     clear_screen();    
00021 
00022     FontDraw_SetInterCharSpace( 0 );
00023     FontDraw_SetForegroundColor( 'Må' );
00024     FontDraw_SetBackgroundColor( ' ' );
00025     FontDraw_SetFont( Calibri14 );
00026 //    FontDraw_printf( 0, 0, "Test %d", 0, 9 );
00027     FontDraw_printf( 0, 0, "+012" );
00028     FontDraw_SetAlphaMode( 1 );
00029     FontDrawChar( 'W', 20, 5, '@', '.', &Calibri28 );
00030 
00031     FontDrawChar( '@', 0, 0, '*', '.', &Calibri72 );
00032     show_screen( 0, 100, 0, 40 );
00033 
00034 #else
00035     
00036     FontDraw_SetInterCharSpace( 2 );
00037     FontDraw_SetForegroundColor( 'M' );
00038     FontDraw_SetBackgroundColor( ' ' );
00039     FontDraw_SetFont( Calibri14 );
00040     FontDraw_printf( 20, 23, "test %d W1", 9 );
00041     
00042     FontDraw_SetInterCharSpace( 10 );
00043     FontDrawString( "Test ABCD", 10, 0, '@', '-', &Calibri14 );    
00044     
00045     int start    = 0;
00046     start    += FontDrawChar( '@', start, 46, '@', '.', &Calibri28 );
00047     
00048     FontDraw_SetAlphaMode( 1 );
00049     start    += FontDrawChar( 'W', 50, 15, '@', '.', &Calibri72 );
00050 #ifdef TEST
00051     show_screen( 0, 200, 0, 150 );
00052 #endif
00053     
00054 #endif
00055     return ( 0 );
00056 }
00057 #ifdef TEST
00058 
00059 void clear_screen( void )
00060 {
00061     for ( int i = 0; i < SC_WIDTH * SC_HEIGHT; i++ )
00062         *(screen + i)    = '.';
00063 }
00064 
00065 
00066 void show_screen( int xs, int width, int ys, int height )
00067 {
00068     int        i;
00069     int        j;
00070     
00071     for ( j = (ys + height - 1); j >= 0; j-- )
00072     {
00073         printf( "%04d  ", j );
00074         
00075         for ( i = xs; i < xs + width; i++ )
00076         {
00077             printf( "%c", *(screen + (j * SC_WIDTH) + i) & 0xFF );
00078             //            printf( "%c", *(screen + (((SC_HEIGHT - 1) - j) * SC_HEIGHT) + i) & 0xFF );
00079         }
00080         printf( "\r\n" );
00081     }
00082 }
00083 #endif