LCD TFT

Dependents:   Example_Menu_LCD_TFT

Files at this revision

API Documentation at this revision

Comitter:
Suky
Date:
Sun Jan 30 20:25:48 2011 +0000
Child:
1:1085b6177f6e
Commit message:

Changed in this revision

Fuentes.h Show annotated file Show diff for this revision Revisions of this file
LCDTFT.cpp Show annotated file Show diff for this revision Revisions of this file
LCDTFT.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Fuentes.h	Sun Jan 30 20:25:48 2011 +0000
@@ -0,0 +1,96 @@
+const char ARIAL[95][5]={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
+                         0x00, 0x00, 0x5F, 0x00, 0x00, // !
+                         0x00, 0x03, 0x00, 0x03, 0x00, // "
+                         0x14, 0x3E, 0x14, 0x3E, 0x14, // #
+                         0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
+                         0x43, 0x33, 0x08, 0x66, 0x61, // %
+                         0x36, 0x49, 0x55, 0x22, 0x50, // &
+                         0x00, 0x07, 0x05, 0x07, 0x00, // ? -> '
+                         0x00, 0x1C, 0x22, 0x41, 0x00, // (
+                         0x00, 0x41, 0x22, 0x1C, 0x00, // )
+                         0x14, 0x08, 0x3E, 0x08, 0x14, // *
+                         0x08, 0x08, 0x3E, 0x08, 0x08, // +
+                         0x00, 0x50, 0x30, 0x00, 0x00, // ,
+                         0x08, 0x08, 0x08, 0x08, 0x08, // -
+                         0x00, 0x60, 0x60, 0x00, 0x00, // .
+                         0x20, 0x10, 0x08, 0x04, 0x02, // /
+                         0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
+                         0x00, 0x04, 0x02, 0x7F, 0x00, // 1
+                         0x42, 0x61, 0x51, 0x49, 0x46, // 2
+                         0x22, 0x41, 0x49, 0x49, 0x36, // 3
+                         0x18, 0x14, 0x12, 0x7F, 0x10, // 4
+                         0x27, 0x45, 0x45, 0x45, 0x39, // 5
+                         0x3E, 0x49, 0x49, 0x49, 0x32, // 6
+                         0x01, 0x01, 0x71, 0x09, 0x07, // 7
+                         0x36, 0x49, 0x49, 0x49, 0x36, // 8
+                         0x26, 0x49, 0x49, 0x49, 0x3E, // 9
+                         0x00, 0x36, 0x36, 0x00, 0x00, // :
+                         0x00, 0x56, 0x36, 0x00, 0x00, // ;
+                         0x08, 0x14, 0x22, 0x41, 0x00, // <
+                         0x14, 0x14, 0x14, 0x14, 0x14, // =
+                         0x00, 0x41, 0x22, 0x14, 0x08, // >
+                         0x02, 0x01, 0x51, 0x09, 0x06, // ?
+                         0x3E, 0x41, 0x59, 0x55, 0x5E, // @
+                         0x7E, 0x09, 0x09, 0x09, 0x7E, // A
+                         0x7F, 0x49, 0x49, 0x49, 0x36, // B
+                         0x3E, 0x41, 0x41, 0x41, 0x22, // C
+                         0x7F, 0x41, 0x41, 0x41, 0x3E, // D
+                         0x7F, 0x49, 0x49, 0x49, 0x41, // E
+                         0x7F, 0x09, 0x09, 0x09, 0x01, // F
+                         0x3E, 0x41, 0x41, 0x49, 0x3A, // G
+                         0x7F, 0x08, 0x08, 0x08, 0x7F, // H
+                         0x00, 0x41, 0x7F, 0x41, 0x00, // I
+                         0x30, 0x40, 0x40, 0x40, 0x3F, // J
+                         0x7F, 0x08, 0x14, 0x22, 0x41, // K
+                         0x7F, 0x40, 0x40, 0x40, 0x40, // L
+                         0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
+                         0x7F, 0x02, 0x04, 0x08, 0x7F, // N
+                         0x3E, 0x41, 0x41, 0x41, 0x3E, // O
+                         0x7F, 0x09, 0x09, 0x09, 0x06, // P
+                         0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
+                         0x7F, 0x09, 0x09, 0x09, 0x76, // R
+                         0x26, 0x49, 0x49, 0x49, 0x32, // S
+                         0x01, 0x01, 0x7F, 0x01, 0x01, // T
+                         0x3F, 0x40, 0x40, 0x40, 0x3F, // U
+                         0x1F, 0x20, 0x40, 0x20, 0x1F, // V
+                         0x7F, 0x20, 0x10, 0x20, 0x7F, // W
+                         0x41, 0x22, 0x1C, 0x22, 0x41, // X
+                         0x07, 0x08, 0x70, 0x08, 0x07, // Y
+                         0x61, 0x51, 0x49, 0x45, 0x43, // Z
+                         0x00, 0x7F, 0x41, 0x00, 0x00, // [
+                         0x02, 0x04, 0x08, 0x10, 0x20, // \
+						 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
+                         0x00, 0x00, 0x41, 0x7F, 0x00, // ]
+                         0x04, 0x02, 0x01, 0x02, 0x04, // ^
+                         0x40, 0x40, 0x40, 0x40, 0x40, // _
+                         0x00, 0x01, 0x02, 0x04, 0x00, // `
+                         0x20, 0x54, 0x54, 0x54, 0x78, // a
+                         0x7F, 0x44, 0x44, 0x44, 0x38, // b
+                         0x38, 0x44, 0x44, 0x44, 0x44, // c
+                         0x38, 0x44, 0x44, 0x44, 0x7F, // d
+                         0x38, 0x54, 0x54, 0x54, 0x18, // e
+                         0x04, 0x04, 0x7E, 0x05, 0x05, // f
+                         0x08, 0x54, 0x54, 0x54, 0x3C, // g
+                         0x7F, 0x08, 0x04, 0x04, 0x78, // h
+                         0x00, 0x44, 0x7D, 0x40, 0x00, // i
+                         0x20, 0x40, 0x44, 0x3D, 0x00, // j
+                         0x7F, 0x10, 0x28, 0x44, 0x00, // k
+                         0x00, 0x41, 0x7F, 0x40, 0x00, // l
+                         0x7C, 0x04, 0x78, 0x04, 0x78, // m
+                         0x7C, 0x08, 0x04, 0x04, 0x78, // n
+                         0x38, 0x44, 0x44, 0x44, 0x38, // o
+                         0x7C, 0x14, 0x14, 0x14, 0x08, // p
+                         0x08, 0x14, 0x14, 0x14, 0x7C, // q
+                         0x00, 0x7C, 0x08, 0x04, 0x04, // r
+                         0x48, 0x54, 0x54, 0x54, 0x20, // s
+                         0x04, 0x04, 0x3F, 0x44, 0x44, // t
+                         0x3C, 0x40, 0x40, 0x20, 0x7C, // u
+                         0x1C, 0x20, 0x40, 0x20, 0x1C, // v
+                         0x3C, 0x40, 0x30, 0x40, 0x3C, // w
+                         0x44, 0x28, 0x10, 0x28, 0x44, // x
+                         0x0C, 0x50, 0x50, 0x50, 0x3C, // y
+                         0x44, 0x64, 0x54, 0x4C, 0x44, // z
+                         0x00, 0x08, 0x36, 0x41, 0x41, // {
+                         0x00, 0x00, 0x7F, 0x00, 0x00, // |
+                         0x41, 0x41, 0x36, 0x08, 0x00, // }
+                         0x02, 0x01, 0x02, 0x04, 0x02};// ~
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCDTFT.cpp	Sun Jan 30 20:25:48 2011 +0000
@@ -0,0 +1,393 @@
+/*
+  @file LCDTFT.cpp
+  @version: 1.0
+ 
+  @web www.micros-designs.com.ar
+  @date 30/01/11
+  
+*- Version Log --------------------------------------------------------------*
+*   Fecha       Autor                Comentarios                             *
+*----------------------------------------------------------------------------*
+* 30/01/11      Suky        Original                                         *
+*----------------------------------------------------------------------------*/ 
+///////////////////////////////////////////////////////////////////////////
+////                                                                   ////
+////                                                                   ////
+////        (C) Copyright 2011 www.micros-designs.com.ar               ////
+//// Este código puede ser usado, modificado y distribuido libremente  ////
+//// sin eliminar esta cabecera y  sin garantía de ningún tipo.        ////
+////                                                                   ////
+////                                                                   ////
+/////////////////////////////////////////////////////////////////////////// 
+#include "LCDTFT.h"
+
+LCDTFT::LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD)
+	: LCD_PIN_RD(PIN_RD),LCD_PIN_WR(PIN_WR),LCD_PIN_RS(PIN_RS),LCD_PIN_CS(PIN_CS),LCD_PIN_RESET(PIN_RESET){
+	LCD_PORT=BUSLCD;
+	X=0;
+	Y=0;
+	X_min=0;
+	X_max=LCD_X_MAX;
+	_Alto=1;
+	_Color=0x0000;
+}
+
+void LCDTFT::vLCDTFTSetParametersPrintf(unsigned short Xo,unsigned short Yo,unsigned short Xmin,unsigned short Xmax,unsigned char Alto, unsigned short Color){
+
+	X=Xo;
+	Y=Yo;
+	X_min=Xmin;
+	X_max=Xmax;
+	_Alto=Alto;
+	_Color=Color;
+}
+
+int LCDTFT::_putc(int value){
+	char Fmt[2]={value,0};
+
+	if(value=='\n'){
+		X=X_min;
+		Y+=7*_Alto + 1;
+	}else{
+		vLCDTFTText(X,Y,(const char *)&Fmt[0],&ARIAL[0],_Alto,_Color);
+		X+=5*_Alto+1;
+		if(X >= X_max){
+			X = X_min;                           
+			Y += 7*_Alto + 1;                
+		}
+	}
+	return(value);
+}
+
+int LCDTFT::_getc(){
+	return(-1);
+}
+
+void LCDTFT::vLCDTFTWriteCommand(unsigned short Data){   
+    
+    LCD_PIN_RS=0;
+    LCD_PIN_CS=0;   
+    LCD_PORT->write(Data);   
+    LCD_PIN_WR=0;
+    LCD_PIN_WR=1;
+    LCD_PIN_CS=1;   
+}
+
+void LCDTFT::vLCDTFTWriteData(unsigned short Data){
+    LCD_PIN_RS=1;
+    LCD_PIN_CS=0;   
+    LCD_PORT->write(Data);   
+    LCD_PIN_WR=0;
+    LCD_PIN_WR=1;
+    LCD_PIN_CS =1;   
+}
+
+
+void LCDTFT::vLCDTFTWriteCommandData(unsigned short CMD,unsigned short Data){
+    vLCDTFTWriteCommand(CMD);
+    vLCDTFTWriteData(Data);
+}
+
+void LCDTFT::vLCDTFTAddressSet(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2){ 
+
+    vLCDTFTWriteCommandData(0x0044,(x2<<8)+x1);
+    vLCDTFTWriteCommandData(0x0045,y1);
+    vLCDTFTWriteCommandData(0x0046,y2);
+    vLCDTFTWriteCommandData(0x004e,x1);
+    vLCDTFTWriteCommandData(0x004f,y1);
+    vLCDTFTWriteCommand(0x0022);       
+}  
+
+void LCDTFT::vLCDTFTAddressSetPoint(unsigned short x,unsigned short y){ 
+
+    vLCDTFTWriteCommandData(0x004e,x);
+    vLCDTFTWriteCommandData(0x004f,y);
+    vLCDTFTWriteCommand(0x0022);       
+}  
+
+void LCDTFT::vLCDTFTInit(void){
+
+	LCD_PIN_RESET=1;
+    wait_ms(5);   
+    LCD_PIN_RESET=0;
+    wait_ms(10);
+    LCD_PIN_RESET=1;
+    LCD_PIN_CS=1;
+    LCD_PIN_RD=1;
+    LCD_PIN_WR=1;
+    wait_ms(20);
+
+	vLCDTFTWriteCommandData(0x0000,0x0001);    wait_ms(1);  
+	vLCDTFTWriteCommandData(0x0003,0xA8A4);    wait_ms(1);  
+    vLCDTFTWriteCommandData(0x000C,0x0000);    wait_ms(1);   
+    vLCDTFTWriteCommandData(0x000D,0x080C);    wait_ms(1);   
+    vLCDTFTWriteCommandData(0x000E,0x2B00);    wait_ms(1);   
+    vLCDTFTWriteCommandData(0x001E,0x00B0);    wait_ms(1);   
+    vLCDTFTWriteCommandData(0x0001,0x2B3F);    wait_ms(1);   
+    vLCDTFTWriteCommandData(0x0002,0x0600);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0010,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0011,0x6070);    wait_ms(1);        
+    vLCDTFTWriteCommandData(0x0005,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0006,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0016,0xEF1C);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0017,0x0003);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0007,0x0233);    wait_ms(1);          
+    vLCDTFTWriteCommandData(0x000B,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x000F,0x0000);    wait_ms(1);        
+    vLCDTFTWriteCommandData(0x0041,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0042,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0048,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0049,0x013F);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x004A,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x004B,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0044,0xEF00);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0045,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0046,0x013F);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0030,0x0707);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0031,0x0204);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0032,0x0204);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0033,0x0502);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0034,0x0507);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0035,0x0204);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0036,0x0204);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0037,0x0502);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x003A,0x0302);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x003B,0x0302);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0023,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0024,0x0000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x0025,0x8000);    wait_ms(1);
+    vLCDTFTWriteCommandData(0x004f,0);        
+    vLCDTFTWriteCommandData(0x004e,0);        
+    vLCDTFTWriteCommand(0x0022);
+}
+
+void LCDTFT::vLCDTFTFillScreen(unsigned short Color){
+    unsigned short i,j;
+    vLCDTFTAddressSet(0,0,239,319);
+
+    for(i=0;i<320;i++){
+        for (j=0;j<240;j++){
+            vLCDTFTWriteData(Color);
+        }
+    }      
+}
+
+void LCDTFT::vLCDTFTPoint(unsigned short x,unsigned short y,unsigned short Color){
+
+    vLCDTFTAddressSetPoint(x,y);
+    vLCDTFTWriteData(Color);
+}
+ 
+void LCDTFT::vLCDTFTText(unsigned short x,unsigned short y,const char *PtrText,const char (*Fuente)[5],unsigned char Alto,unsigned short Color){
+   unsigned short i, j, k, l, m, temp;           
+   char DataPunto[5]; 
+   const char *Ptr;
+    
+   while(*PtrText!='\0'){
+      Ptr=(Fuente+*PtrText-' ')[0];
+      for(i=0;i<5;i++){DataPunto[i]=*Ptr++;}
+      switch(*PtrText){
+         case '\n':
+            y += 7*Alto + 1;
+         break;
+         case '\r':
+            x = 0;
+         break;
+         default:
+            if(x+5*Alto >= LCD_X_MAX){
+                 x = 0;                           
+                 y += 7*Alto + 1;                
+              }
+              for(j=0; j<5; ++j, x+=Alto){
+                 for(k=0; k < 7; k++){
+                    temp=(0x01<<k);
+                    if((DataPunto[j]&temp)==temp){
+                       for(l=0; l < Alto; ++l){                         
+                          for(m=0; m < Alto; ++m){
+                             vLCDTFTPoint(x+m,y+k*Alto+l,Color);
+                          }
+                       }
+                    }
+                 }
+              }
+              x++;
+          break;
+      } 
+      *PtrText++;     
+   }
+}
+
+void LCDTFT::vLCDTFTLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short Color){
+
+   unsigned short dy, dx;
+   short addx=1, addy=1;
+   short P, diff;
+   unsigned short i=0;
+
+   diff=((short)x2-x1);
+   if(diff<0) diff*=-1;
+   dx=diff;
+   diff=((short)y2-y1);
+   if(diff<0) diff*=-1;
+   dy=diff;
+
+
+   if(x1 > x2)addx = -1;
+   if(y1 > y2)addy = -1;
+   if(dx >= dy){
+      dy *= 2;
+      P = dy - dx;
+      diff = P - dx;
+      for(;i<=dx;++i){
+         vLCDTFTPoint(x1, y1, Color);
+         if(P < 0){
+            P  += dy;
+            x1 += addx;
+         }else{
+            P  += diff;
+            x1 += addx;
+            y1 += addy;
+         }
+      }
+   }else{
+      dx *= 2;
+      P = dx - dy;
+      diff = P - dy;
+      for(; i<=dy; ++i){
+         vLCDTFTPoint(x1, y1, Color);
+         if(P < 0){
+            P  += dx;
+            y1 += addy;
+         }else{
+            P  += diff;
+            x1 += addx;
+            y1 += addy;
+         }
+      }
+   }
+}
+
+
+void LCDTFT::vLCDTFTRectangle(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,bool Filled,unsigned short Color){
+   
+    if(Filled){
+        int Lenght=((int)(x2-x1+1)*(y2-y1+1));  
+       
+        vLCDTFTAddressSet(x1,y1,x2,y2);      
+        for(int i=0;i<Lenght;i++){
+            vLCDTFTWriteData(Color);                         
+        }   
+    }else{
+        vLCDTFTLine(x1, y1, x2, y1, Color);     
+        vLCDTFTLine(x1, y2, x2, y2, Color);
+        vLCDTFTLine(x1, y1, x1, y2, Color);
+        vLCDTFTLine(x2, y1, x2, y2, Color);
+    }
+}
+
+
+void LCDTFT::vLCDTFTCircle(unsigned short x,unsigned short y,unsigned short Radius,bool Filled,unsigned short Color){
+    short  a, b, P;
+
+    a = 0;
+    b = Radius;
+    P = 1 - Radius;
+
+    do{
+        if(Filled){
+            vLCDTFTLine(x-a, y+b, x+a, y+b, Color);
+            vLCDTFTLine(x-a, y-b, x+a, y-b, Color);
+            vLCDTFTLine(x-b, y+a, x+b, y+a, Color);
+            vLCDTFTLine(x-b, y-a, x+b, y-a, Color);
+        }else{
+            vLCDTFTPoint(a+x, b+y, Color);
+            vLCDTFTPoint(b+x, a+y, Color);
+            vLCDTFTPoint(x-a, b+y, Color);
+            vLCDTFTPoint(x-b, a+y, Color);
+            vLCDTFTPoint(b+x, y-a, Color);
+            vLCDTFTPoint(a+x, y-b, Color);
+            vLCDTFTPoint(x-a, y-b, Color);
+            vLCDTFTPoint(x-b, y-a, Color);
+        }
+        if(P < 0) P += 3 + 2 * a++;
+        else P += 5 + 2 * (a++ - b--);
+    }while(a <= b);
+}
+
+void LCDTFT::vDrawImageBMP24Bits(const char *NameImagen){
+
+    #define OffsetWidthPixel    18
+    #define OffsetHeighPixel    22
+    #define OffsetSizeFile      34
+    #define OffsetInitData      10
+    #define OffserTipeFile      28
+    char Nombre[80],k;
+    unsigned short PosXImagen,PosYImagen;
+    unsigned char Temp,BufferHeader[54],BufferTemp[3],Adicional;
+    unsigned int WidthPixel,HeighPixel;
+    unsigned short TipeFile,InitData,Temp16bits;
+    union{
+        unsigned short Val;
+        struct{
+            unsigned Blue:5;
+            unsigned Green:6;
+            unsigned Red:5;
+        };
+    }Color; 
+
+    LocalFileSystem local("mbedMemory");
+    sprintf(&Nombre[0],"/mbedMemory/");
+    k=12;
+    while(*NameImagen!='\0'){
+        Nombre[k++]=*NameImagen++;
+    }
+    
+    FILE *Imagen = fopen((const char *)&Nombre[0], "r"); // Abrimos archivo para lectura.
+    // Si no se pudo encontrar archivo:
+    if(!Imagen) {
+		vLCDTFTFillScreen(ColorBlack);
+        return;
+    }
+    // Leemos cabecera de archivo
+    fread(&BufferHeader[0],1,54,Imagen);
+    
+    WidthPixel = ((unsigned int)BufferHeader[OffsetWidthPixel + 3]*16777216+BufferHeader[OffsetWidthPixel + 2]*65536+BufferHeader[OffsetWidthPixel + 1]*256+BufferHeader[OffsetWidthPixel]);
+    HeighPixel = ((unsigned int)BufferHeader[OffsetHeighPixel + 3]*16777216+BufferHeader[OffsetHeighPixel + 2]*65536+BufferHeader[OffsetHeighPixel + 1]*256+BufferHeader[OffsetHeighPixel]);
+    InitData = ((unsigned short)BufferHeader[OffsetInitData]);
+    TipeFile = ((unsigned short)BufferHeader[OffserTipeFile + 1]*256 + BufferHeader[OffserTipeFile]);
+    
+    if((WidthPixel>LCD_X_MAX) || (HeighPixel>LCD_Y_MAX) || (TipeFile!=24)){
+        fclose(Imagen);
+        return;
+    }
+    
+    if(InitData!=54){
+        for(int k=54;k<InitData;k++){
+            fread(&Temp,1,1,Imagen);
+        }
+    }
+    
+    PosXImagen=(LCD_X_MAX/2)-(WidthPixel/2);
+    PosYImagen=(LCD_Y_MAX/2)+(HeighPixel/2);
+    
+    Temp16bits=WidthPixel*3;
+    Adicional=0;
+    while(((Temp16bits)%4)!=0){
+        Adicional++;
+        Temp16bits++;
+    }
+    
+    for(int k=0,y=PosYImagen;k<HeighPixel;k++,y--){
+        vLCDTFTAddressSet(PosXImagen,y,PosXImagen+WidthPixel-1,y);
+        for(int i=0;i<WidthPixel;i++){
+            fread(&BufferTemp[0],1,3,Imagen); // Leemos 3 bytes (R,G,B)
+            Color.Blue=BufferTemp[0]>>3;Color.Green=BufferTemp[1]>>2;Color.Red=BufferTemp[2]>>3; // Conversion de 24-bits a 16-bits.-
+            vLCDTFTWriteData(Color.Val);
+        }
+        // Bytes adicionales para que linea sea multiplo de 4.-
+        for(int p=0;p<Adicional;p++){
+            fread(&Temp,1,1,Imagen);
+        }
+    }
+    fclose(Imagen);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCDTFT.h	Sun Jan 30 20:25:48 2011 +0000
@@ -0,0 +1,156 @@
+/*
+  @file LCDTFT.h
+  @version: 1.0
+  
+  @web www.micros-designs.com.ar
+  @date 30/01/11
+  
+*- Version Log --------------------------------------------------------------*
+*   Fecha       Autor                Comentarios                             *
+*----------------------------------------------------------------------------*
+* 30/01/11      Suky        Original                                         *
+*----------------------------------------------------------------------------*/ 
+///////////////////////////////////////////////////////////////////////////
+////                                                                   ////
+////                                                                   ////
+////        (C) Copyright 2011 www.micros-designs.com.ar               ////
+//// Este código puede ser usado, modificado y distribuido libremente  ////
+//// sin eliminar esta cabecera y  sin garantía de ningún tipo.        ////
+////                                                                   ////
+////                                                                   ////
+/////////////////////////////////////////////////////////////////////////// 
+
+/** Libreria para LCD TFT chip Himax HX8347-A
+ *
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "LCDTFT.h"
+ * 
+ *BusOut 	MyBus(p13,p14,p15,p16,p17,p18,p19,p20,p30,p29,p28,p27,p26,p25,p24,p23);
+ *LCDTFT 	MyLCD(p5,p6,p7,p22,p21,&MyBus);
+ *
+ *int main(){
+ *	MyLCD.vLCDTFTInit();
+ *	MyLCD.vLCDTFTFillScreen(ColorWhite);
+ *	MyLCD.printf("Hola mbed!!!");
+ *
+ *	MyLCD.vDrawImageBMP24Bits("IMG0.BMP");
+ *
+ *    while(1){  
+ *    }
+ *}
+ * @endcode
+ */
+
+#include "mbed.h"
+#include "Fuentes.h"
+
+#define    ColorRed        		0xf800
+#define    ColorGreen        	0x400
+#define    ColorBlue        	0x001f
+#define    ColorMarron        	0x8208
+#define    ColorBlack        	0x0
+#define    ColorWhite        	0xffff
+#define    ColorMaroon        	0x8000
+#define    ColorFuchsia    		0xf81f
+#define    ColorVioleta    		0x801f
+#define    ColorAzulMarino    	0x14
+#define    ColorGray        	0x8410
+#define    ColorOlive        	0x8400
+#define    ColorNaranja    		0xfc08
+#define    ColorYellow        	0xffe0
+#define    ColorCian        	0x87ff
+#define    ColorRosado        	0xf810
+#define    ColorNavy        	0x10
+#define    ColorPurple        	0x8010
+#define    ColorTeal        	0x410
+#define    ColorLime        	0x7e0
+#define    ColorAqua        	0x7ff
+
+#define	   LCD_X_MAX			240
+#define	   LCD_Y_MAX			320
+
+class LCDTFT: public Stream {
+	public:
+    	 /** Crea LCDTFT interface
+         *
+         * @param RD    
+         * @param WR     
+         * @param RS
+         * @param CS
+         * @param RESET
+         * @param BusLCD (16-bits) 
+         */
+		LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD);
+		/** Inicializa LCD
+		*
+		*/
+		void vLCDTFTInit(void);
+		/** Fija parametros para escritura mediante printf
+		*
+		* @param Xo X inicial
+		* @param Yo Y inicial
+		* @param Xmin X minimo
+		* @param Xmax X maximo
+		* @param Alto Alto de letra (1,2,3..)
+		* @param Color Color de letra 16-bits
+		*/
+		void vLCDTFTSetParametersPrintf(unsigned short Xo,unsigned short Yo,unsigned short Xmin,unsigned short Xmax,unsigned char Alto, unsigned short Color);
+		/** Pinta pantalla completa de color
+		* @param Color Color de 16-bits
+		*/
+		void vLCDTFTFillScreen(unsigned short Color);
+		/** Dibuja punto en pantalla
+		* @param x Posicion x
+		* @param y Posicion y
+		* @param Color Color 16-bits
+		*/
+		void vLCDTFTPoint(unsigned short x,unsigned short y,unsigned short Color);
+		/** Escribe string en LCD
+		* @param x X inicial
+		* @param y Y inicial
+		* @param *PtrText Texto a escribir
+		* @param *Fuente Fuente de letra a escribir (ARIAL)
+		* @param Alto Alto de letra (1,2,3)
+		* @param Color Color de 16-bits
+		*/
+		void vLCDTFTText(unsigned short x,unsigned short y,const char *PtrText,const char (*Fuente)[5],unsigned char Alto,unsigned short Color);
+		
+		void vLCDTFTLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short Color);
+		void vLCDTFTRectangle(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,bool Filled,unsigned short Color);
+		void vLCDTFTCircle(unsigned short x,unsigned short y,unsigned short Radius,bool Filled,unsigned short Color);
+		/** Dibuja imagen ubicada en memoria de mbed (2Mbytes) centrada en patalla
+		* @param NameImagen nombre de imagen (ejm: IMAGEN.BMP)
+		*/		
+		void vDrawImageBMP24Bits(const char *NameImagen);
+	#if DOXYGEN_ONLY
+	    /** Escribe un caracter en LCD
+	     *
+	     * @param c El caracter a escribir en LCD
+	     */
+	    int putc(int c);
+	
+	    /** Escribe un string formateado en LCD
+	     *
+	     * @param format A printf-style format string, followed by the
+	     *               variables to use in formating the string.
+	     */
+	    int printf(const char* format, ...);
+	#endif	    	    
+
+	private:
+		DigitalOut LCD_PIN_RD,LCD_PIN_WR,LCD_PIN_RS,LCD_PIN_CS,LCD_PIN_RESET;	
+		BusOut *LCD_PORT;	
+		unsigned short X,Y,X_min,X_max,_Alto,_Color;
+		// Stream implementation functions
+	    virtual int _putc(int value);
+	    virtual int _getc();
+
+		virtual void vLCDTFTWriteCommand(unsigned short Data);
+		virtual void vLCDTFTWriteData(unsigned short Data);
+		virtual void vLCDTFTWriteCommandData(unsigned short CMD,unsigned short Data);
+		virtual void vLCDTFTAddressSet(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2);
+		virtual void vLCDTFTAddressSetPoint(unsigned short x,unsigned short y);	
+};
+// **************************************************************************************************************************************