Versión de Firmware con funciones de RAM incorporadas.

Dependencies:   mbed

Fork of VmRecorderV1dot1 by virtualmech

Committer:
JuanManuelAmador
Date:
Tue Jul 14 08:34:11 2015 +0000
Revision:
2:e818c80e6d5c
Parent:
0:3d456b8ce449
Funciones de memoria RAM introducidas.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JuanManuelAmador 0:3d456b8ce449 1 #include "doggy.h"
JuanManuelAmador 0:3d456b8ce449 2
JuanManuelAmador 0:3d456b8ce449 3 XGlyph DogMLCD::GetGlyph( int code )
JuanManuelAmador 0:3d456b8ce449 4 {
JuanManuelAmador 0:3d456b8ce449 5 if( code > 31 && code < 256 )
JuanManuelAmador 0:3d456b8ce449 6 return XFont[code - 31];
JuanManuelAmador 0:3d456b8ce449 7 return XFont[0];
JuanManuelAmador 0:3d456b8ce449 8 }
JuanManuelAmador 0:3d456b8ce449 9
JuanManuelAmador 0:3d456b8ce449 10 void DogMLCD::XChar( int x, int y, int code, doggy_op raster )
JuanManuelAmador 0:3d456b8ce449 11 {
JuanManuelAmador 0:3d456b8ce449 12 XChar( x, y, GetGlyph( code ) );
JuanManuelAmador 0:3d456b8ce449 13 }
JuanManuelAmador 0:3d456b8ce449 14 void DogMLCD::XChar( int x, int y, XGlyph f, doggy_op raster )
JuanManuelAmador 0:3d456b8ce449 15 {
JuanManuelAmador 0:3d456b8ce449 16 const char* p = f.bmp;
JuanManuelAmador 0:3d456b8ce449 17 RasterOp op = ((RasterOp[]){ &DogMLCD::Poke, &DogMLCD::Wipe, &DogMLCD::Inv })[raster];
JuanManuelAmador 0:3d456b8ce449 18 int y1 = y + f.hei;
JuanManuelAmador 0:3d456b8ce449 19 for( int w = 0 ; w < f.wid ; w++ )
JuanManuelAmador 0:3d456b8ce449 20 {
JuanManuelAmador 0:3d456b8ce449 21 for( int z = y, m = 1 ; z < y1 ; z++ )
JuanManuelAmador 0:3d456b8ce449 22 {
JuanManuelAmador 0:3d456b8ce449 23 if( m == 256 ) { m = 1; p++; }
JuanManuelAmador 0:3d456b8ce449 24 if( *p & m )
JuanManuelAmador 0:3d456b8ce449 25 (this->*op)( x, z );
JuanManuelAmador 0:3d456b8ce449 26 m <<= 1;
JuanManuelAmador 0:3d456b8ce449 27 }
JuanManuelAmador 0:3d456b8ce449 28 p++;
JuanManuelAmador 0:3d456b8ce449 29 x++;
JuanManuelAmador 0:3d456b8ce449 30 }
JuanManuelAmador 0:3d456b8ce449 31 }
JuanManuelAmador 0:3d456b8ce449 32 int DogMLCD::XString( int x, int y, int i, doggy_op raster )
JuanManuelAmador 0:3d456b8ce449 33 {
JuanManuelAmador 0:3d456b8ce449 34 char buf[32];
JuanManuelAmador 0:3d456b8ce449 35 sprintf( buf, "%d", i );
JuanManuelAmador 0:3d456b8ce449 36 return XString( x, y, buf, raster );
JuanManuelAmador 0:3d456b8ce449 37 }
JuanManuelAmador 0:3d456b8ce449 38 int DogMLCD::XString( int x, int y, float f, doggy_op raster )
JuanManuelAmador 0:3d456b8ce449 39 {
JuanManuelAmador 0:3d456b8ce449 40 char buf[32];
JuanManuelAmador 0:3d456b8ce449 41 sprintf( buf, "%f", f );
JuanManuelAmador 0:3d456b8ce449 42 return XString( x, y, buf, raster );
JuanManuelAmador 0:3d456b8ce449 43 }
JuanManuelAmador 0:3d456b8ce449 44 int DogMLCD::XString( int x, int y, const char* s, doggy_op raster )
JuanManuelAmador 0:3d456b8ce449 45 {
JuanManuelAmador 0:3d456b8ce449 46 int oldx = x;
JuanManuelAmador 0:3d456b8ce449 47 int trc = 0, brc = 0, inter = XFont[0].hei;
JuanManuelAmador 0:3d456b8ce449 48 while( *s )
JuanManuelAmador 0:3d456b8ce449 49 {
JuanManuelAmador 0:3d456b8ce449 50 if( *s == 13 )
JuanManuelAmador 0:3d456b8ce449 51 {
JuanManuelAmador 0:3d456b8ce449 52 x = oldx;
JuanManuelAmador 0:3d456b8ce449 53 y += inter;
JuanManuelAmador 0:3d456b8ce449 54 }
JuanManuelAmador 0:3d456b8ce449 55 else if( *s > 31 )
JuanManuelAmador 0:3d456b8ce449 56 {
JuanManuelAmador 0:3d456b8ce449 57 XGlyph f = GetGlyph( *s );
JuanManuelAmador 0:3d456b8ce449 58
JuanManuelAmador 0:3d456b8ce449 59 while( ( x > 0 ) && ( trc + f.tlc ) > 0 && ( brc + f.blc ) > 0 )
JuanManuelAmador 0:3d456b8ce449 60 {
JuanManuelAmador 0:3d456b8ce449 61 x--;
JuanManuelAmador 0:3d456b8ce449 62 trc--;
JuanManuelAmador 0:3d456b8ce449 63 brc--;
JuanManuelAmador 0:3d456b8ce449 64 }
JuanManuelAmador 0:3d456b8ce449 65
JuanManuelAmador 0:3d456b8ce449 66 if( x + f.wid > 128 ) // simplified form of [ x + f.wid - 1 > 127 ]
JuanManuelAmador 0:3d456b8ce449 67 {
JuanManuelAmador 0:3d456b8ce449 68 x = oldx;
JuanManuelAmador 0:3d456b8ce449 69 y += inter;
JuanManuelAmador 0:3d456b8ce449 70 if( *s != 32 ) // don't ouput begining space on new line
JuanManuelAmador 0:3d456b8ce449 71 {
JuanManuelAmador 0:3d456b8ce449 72 XChar( x, y, f, raster );
JuanManuelAmador 0:3d456b8ce449 73 x += f.wid + 1;
JuanManuelAmador 0:3d456b8ce449 74 }
JuanManuelAmador 0:3d456b8ce449 75 }
JuanManuelAmador 0:3d456b8ce449 76 else
JuanManuelAmador 0:3d456b8ce449 77 {
JuanManuelAmador 0:3d456b8ce449 78 XChar( x, y, f, raster );
JuanManuelAmador 0:3d456b8ce449 79 x += f.wid + 1;
JuanManuelAmador 0:3d456b8ce449 80 }
JuanManuelAmador 0:3d456b8ce449 81 if( *s != 32 ) // for space keep crening of previous char
JuanManuelAmador 0:3d456b8ce449 82 {
JuanManuelAmador 0:3d456b8ce449 83 trc = f.trc;
JuanManuelAmador 0:3d456b8ce449 84 brc = f.brc;
JuanManuelAmador 0:3d456b8ce449 85 }
JuanManuelAmador 0:3d456b8ce449 86 }
JuanManuelAmador 0:3d456b8ce449 87 s++;
JuanManuelAmador 0:3d456b8ce449 88 }
JuanManuelAmador 0:3d456b8ce449 89 return y;
JuanManuelAmador 0:3d456b8ce449 90 }