chris stevens / LCDTFT_ssd0139

Dependents:   receiver TFT_CJS_ssd0139 poster8x8_ranger

Fork of LCDTFT by Ale C.-

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCDTFT.cpp Source File

LCDTFT.cpp

00001 /*
00002   @file LCDTFT.cpp
00003   @version: 1.0
00004  
00005   @web www.micros-designs.com.ar
00006   @date 30/01/11
00007   
00008 *- Version Log --------------------------------------------------------------*
00009 *   Fecha       Autor                Comentarios                             *
00010 *----------------------------------------------------------------------------*
00011 * 30/01/11      Suky        Original                                         *
00012 *----------------------------------------------------------------------------*/ 
00013 ///////////////////////////////////////////////////////////////////////////
00014 ////                                                                   ////
00015 ////                                                                   ////
00016 ////        (C) Copyright 2011 www.micros-designs.com.ar               ////
00017 //// Este c�digo puede ser usado, modificado y distribuido libremente  ////
00018 //// sin eliminar esta cabecera y  sin garant�a de ning�n tipo.        ////
00019 ////                                                                   ////
00020 ////                                                                   ////
00021 ///////////////////////////////////////////////////////////////////////////
00022 //
00023 //NB May 2015
00024  // because this uses BusOut its not really very quick. would be better to use PortOut which 
00025  // is generally a lot faster - typical exmaple max speed Busout=168kHz whereas PortOut=2470kHz - >10xfaster!
00026  // will try to re-write this sometime for this kind of access but will be a pain due to the pinning
00027  // of the paralell TFTLCD
00028  /*
00029  TFTLCD module pin------KL25Z matching pi
00030  LCD_D0                 PTA13
00031  LCD_D1                 PTD5
00032  LCD_D2                 PTD4
00033  LCD_D3                 PTA12
00034  LCD_D4                 PTA$
00035  LCD_D5                 PTA5
00036  LCD_D6                 PTC8
00037  LCD_D7                 PTC9
00038  
00039  */
00040  // so hard to get a single port to do this 8 bit interface.... but could use PTC 0 3 4 5 6 7 8 9 by masking out PTC1 and 2
00041  // would need a separate pcb to hold the screen...
00042  //can't be stripboard thanks to stupid arduino pins
00043 #include "LCDTFT.h"
00044 
00045 LCDTFT::LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD)
00046     : 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){
00047     LCD_PORT=BUSLCD;
00048     X=0;
00049     Y=0;
00050     X_min=0;
00051     X_max=LCD_X_MAX;
00052     _Alto=1;
00053     _Color=0x0000;
00054 }
00055 // global variable for screen orientation set by init
00056 bool orient=0;
00057 
00058  static const unsigned short regValues[] = {
00059     0x0000, 0x0001, // start oscillation
00060     0x00FF, 0x0010, // wait 16 ms
00061     0x0007, 0x0000, //display control - zeros everything ??? 
00062     0x0013, 0x0000, // power control 3 setting = all zero
00063     0x0011, 0x2604, //power control 2 seting = gvd voltage 0x26 vci1 voltage 0x04
00064     0x0014, 0x0015, // power contrlol 4 setting vcmr=0 vcomh=0 vml=13 = amplitude of vcom voltage
00065     0x0010, 0x3C00, // power control 1 bt3=0 sap=7 (0b111) bt=4 (0b100)
00066     0x0013, 0x0040, //power control 3 PON=1 PON1=0 AON=0
00067     0x00FF,0x0010, // wait 16ms
00068     0x0013, 0x0060, // power control 3 PON=1 PON1=1 AON=0    
00069     0x00FF, 0x0032, // wait 50ms
00070     0x0013, 0x0070, //power control 3 PON=1 PON1=1 AON=1
00071     0x00FF, 0x0028, // wait 40ms
00072        
00073     0x0001, 0x0127,  // driver ouptut control
00074     0x0002, 0x0700,  //LCD driving waveform settings
00075     0x0003, 0x1030,  // entry mode settingtri=0 dfm=0 bgr=1 id1:id0=11
00076     0x0007, 0x0000,  // display control 1 pt1-0=0 vle2-1=0 spt=0 gon=0 rev=0 d1-0=0
00077     0x0008, 0x0404,  //black period control fp3-0=4 bp3-0=4
00078     0x000B, 0x0200,  //frame cycle setting nd1-0=0 sdt1-0=2 ecs2-0=0 div1-0=0 dcr_ex=0 dcr2-0=0 rtn1-0=0
00079     0x000C, 0x0000,  //external interface controlrm=0 dm1-0=0 rim1-0=0
00080     0x00015,0x0000,  //sub panel control sub_im1-0=0 stn_en=0 mpu_mode=0 fcv_en=0
00081        
00082     //gamma setting    
00083     0x0030, 0x0000,      
00084     0x0031, 0x0606,    
00085     0x0032, 0x0006,    
00086     0x0033, 0x0403,  
00087     0x0034, 0x0107,  
00088     0x0035, 0x0101, 
00089     0x0036, 0x0707,   
00090     0x0037, 0x0304,   
00091     0x0038, 0x0A00,     
00092     0x0039, 0x0706,     
00093        // end of gamma settings
00094     0x0040, 0x0000,   // gate scan position (start g1 scan) scn5-0=0
00095     0x0041, 0x0000,   // vertical scroll setting vl8-0=0
00096     0x0042, 0x013F,   // screen end position se18-10=0x13F
00097     0x0043, 0x0000,   // screen_start position ss28-20=0
00098     0x0044, 0x0000,   // 2nd screen driving position end 00
00099     0x0045, 0x0000,   //2nd screen driving position start =00
00100     0x0046, 0xEF00,   //window addre horizontal ram for x0,x1 HEA=0xEF HSA=00 ie x=0 and x=239
00101     0x0047, 0x013F,   //vertical ram address end vea=0x13F ie y=319
00102     0x0048, 0x0000,    //vertical ram address start=00 ie y=0
00103     0x0007, 0x0011,  //dispaly control 1
00104     0x00FF, 0x0028, //wait 40ms
00105     0x0007, 0x0017,    //display control 1
00106 
00107 };
00108 
00109 
00110 void LCDTFT::vLCDTFTSetParametersPrintf(unsigned short Xo,unsigned short Yo,unsigned short Xmin,unsigned short Xmax,unsigned char Alto, unsigned short Color,unsigned short BackColor){
00111 
00112     X=Xo;
00113     Y=Yo;
00114     X_min=Xmin;
00115     X_max=Xmax;
00116     _Alto=Alto;
00117     _Color=Color;
00118     _Background=BackColor;
00119 }
00120 
00121 int LCDTFT::_putc(int value){
00122     char Fmt[2]={value,0};
00123 
00124     if(value=='\n'){
00125         X=X_min;
00126         Y+=8*_Alto + 1;
00127     }else{
00128         vLCDTFTText(X,Y,(const char *)&Fmt[0],&ARIAL[0],_Alto,_Color,_Background);
00129         X+=5*_Alto+1;
00130         if(X >= X_max){
00131             X = X_min;                           
00132             Y += 8*_Alto + 1;                
00133         }
00134     }
00135     return(value);
00136 }
00137 
00138 int LCDTFT::_getc(){
00139     return(-1);
00140 }
00141 
00142 void LCDTFT::vLCDTFTWriteCommand(unsigned short Data){   
00143     
00144     LCD_PIN_RS=0;
00145     LCD_PIN_CS=0;   
00146     LCD_PORT->write(Data>>8);   // MSB so with an 8 bit port we need to write here the high and ,low bytes successively
00147     LCD_PIN_WR=0;
00148     LCD_PIN_WR=1;
00149     LCD_PORT->write(Data & 0x00FF);   // LSB
00150     LCD_PIN_WR=0;
00151     LCD_PIN_WR=1;
00152     
00153     LCD_PIN_CS=1;   
00154 }
00155 
00156 void LCDTFT::vLCDTFTWriteData(unsigned short Data){
00157     LCD_PIN_RS=1;
00158     LCD_PIN_CS=0;   
00159     LCD_PORT->write(Data>>8);   // MSB so with an 8 bit port we need to write here the high and ,low bytes successively
00160     LCD_PIN_WR=0;
00161     LCD_PIN_WR=1;
00162     LCD_PORT->write(Data & 0x00FF);   // LSB
00163     LCD_PIN_WR=0;
00164     LCD_PIN_WR=1;
00165     LCD_PIN_CS =1;   
00166 }
00167 
00168 
00169 void LCDTFT::vLCDTFTWriteCommandData(unsigned short CMD,unsigned short Data){
00170     vLCDTFTWriteCommand(CMD);
00171     vLCDTFTWriteData(Data);
00172 }
00173 
00174 void LCDTFT::vLCDTFTAddressSet(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2){ 
00175 
00176     vLCDTFTWriteCommandData(0x0044,(x2<<8)+x1);
00177     vLCDTFTWriteCommandData(0x0045,y1);
00178     vLCDTFTWriteCommandData(0x0046,y2);
00179     vLCDTFTWriteCommandData(0x004e,x1);
00180     vLCDTFTWriteCommandData(0x004f,y1);
00181     vLCDTFTWriteCommand(0x0022);       
00182 }  
00183 
00184 void LCDTFT::vLCDTFTAddressSetPoint(unsigned short x,unsigned short y){ 
00185 
00186 // CGRAM addresses are given by (x+y*256) - for some reason the y cordinate 
00187 // addresses require 17 bits
00188 // equiv if y is given by 0xYYY and x by 0xXX
00189 // then address of point x,y is 0xYYYXXX
00190      int add;
00191      int adl,adh;
00192      if(orient==0){ // portrait
00193             add=x+y*256; //240 x 320 y but 256 bytes for each x row
00194          
00195             }
00196     else{
00197             add=(239-y)+x*256;
00198         }   
00199       adl=add & 0x00FF; // selects the 8 low bits
00200             adh=(add >>8); // the 9 high bits
00201    vLCDTFTWriteCommandData(0x0020,adl); // 8 lsb of address
00202    vLCDTFTWriteCommandData(0x0021,adh); //9 msb of address
00203     vLCDTFTWriteCommand(0x0022);       // prepare to send rgb data
00204 }  
00205 
00206 void LCDTFT::vLCDTFTInit(bool format){
00207 
00208     int i;
00209     unsigned short  address,data;
00210     orient=format;
00211     LCD_PIN_RESET=1;
00212     wait_ms(5);   // must hold for at least 1ms after reset
00213     LCD_PIN_RESET=0;
00214     wait_ms(10); // wait for stable R-C oscillation
00215     LCD_PIN_RESET=1;
00216     wait_ms(5); // final wait for rest to be acitvated
00217     LCD_PIN_CS=1;
00218     LCD_PIN_RD=1;
00219     LCD_PIN_WR=1;
00220     wait_ms(20);
00221     
00222     for(i=0;i<sizeof(regValues)/4;i++)
00223     {
00224         address=regValues[i*2];
00225         data=regValues[i*2+1];
00226         
00227         if(address==0xFF)
00228         {
00229             wait_ms(data);
00230             }
00231             else {
00232                 vLCDTFTWriteCommandData(address,data);
00233                 }
00234         }
00235         wait_ms(1);
00236         
00237 
00238 /*
00239     vLCDTFTWriteCommandData(0x0000,0x0001);    wait_ms(1);  
00240     vLCDTFTWriteCommandData(0x0003,0xA8A4);    wait_ms(1);  
00241     vLCDTFTWriteCommandData(0x000C,0x0000);    wait_ms(1);   
00242     vLCDTFTWriteCommandData(0x000D,0x080C);    wait_ms(1);   
00243     vLCDTFTWriteCommandData(0x000E,0x2B00);    wait_ms(1);   
00244     vLCDTFTWriteCommandData(0x001E,0x00B0);    wait_ms(1);   
00245     vLCDTFTWriteCommandData(0x0001,0x2B3F);    wait_ms(1);   
00246     vLCDTFTWriteCommandData(0x0002,0x0600);    wait_ms(1);
00247     vLCDTFTWriteCommandData(0x0010,0x0000);    wait_ms(1);
00248     vLCDTFTWriteCommandData(0x0011,0x6070);    wait_ms(1);        
00249     vLCDTFTWriteCommandData(0x0005,0x0000);    wait_ms(1);
00250     vLCDTFTWriteCommandData(0x0006,0x0000);    wait_ms(1);
00251     vLCDTFTWriteCommandData(0x0016,0xEF1C);    wait_ms(1);
00252     vLCDTFTWriteCommandData(0x0017,0x0003);    wait_ms(1);
00253     vLCDTFTWriteCommandData(0x0007,0x0233);    wait_ms(1);          
00254     vLCDTFTWriteCommandData(0x000B,0x0000);    wait_ms(1);
00255     vLCDTFTWriteCommandData(0x000F,0x0000);    wait_ms(1);        
00256     vLCDTFTWriteCommandData(0x0041,0x0000);    wait_ms(1);
00257     vLCDTFTWriteCommandData(0x0042,0x0000);    wait_ms(1);
00258     vLCDTFTWriteCommandData(0x0048,0x0000);    wait_ms(1);
00259     vLCDTFTWriteCommandData(0x0049,0x013F);    wait_ms(1);
00260     vLCDTFTWriteCommandData(0x004A,0x0000);    wait_ms(1);
00261     vLCDTFTWriteCommandData(0x004B,0x0000);    wait_ms(1);
00262     vLCDTFTWriteCommandData(0x0044,0xEF00);    wait_ms(1);
00263     vLCDTFTWriteCommandData(0x0045,0x0000);    wait_ms(1);
00264     vLCDTFTWriteCommandData(0x0046,0x013F);    wait_ms(1);
00265     vLCDTFTWriteCommandData(0x0030,0x0707);    wait_ms(1);
00266     vLCDTFTWriteCommandData(0x0031,0x0204);    wait_ms(1);
00267     vLCDTFTWriteCommandData(0x0032,0x0204);    wait_ms(1);
00268     vLCDTFTWriteCommandData(0x0033,0x0502);    wait_ms(1);
00269     vLCDTFTWriteCommandData(0x0034,0x0507);    wait_ms(1);
00270     vLCDTFTWriteCommandData(0x0035,0x0204);    wait_ms(1);
00271     vLCDTFTWriteCommandData(0x0036,0x0204);    wait_ms(1);
00272     vLCDTFTWriteCommandData(0x0037,0x0502);    wait_ms(1);
00273     vLCDTFTWriteCommandData(0x003A,0x0302);    wait_ms(1);
00274     vLCDTFTWriteCommandData(0x003B,0x0302);    wait_ms(1);
00275     vLCDTFTWriteCommandData(0x0023,0x0000);    wait_ms(1);
00276     vLCDTFTWriteCommandData(0x0024,0x0000);    wait_ms(1);
00277     vLCDTFTWriteCommandData(0x0025,0x8000);    wait_ms(1);
00278     vLCDTFTWriteCommandData(0x004f,0);        
00279     vLCDTFTWriteCommandData(0x004e,0);        
00280     vLCDTFTWriteCommand(0x0022);
00281     */
00282 }
00283 
00284 void LCDTFT::vLCDTFTFillScreen(unsigned short Color){
00285     unsigned short i,j;
00286 
00287      vLCDTFTWriteCommandData(0x0020,00); //set x=0
00288     vLCDTFTWriteCommandData(0x0021,00); // set y=0
00289     vLCDTFTWriteCommand(0x0022);       
00290 
00291     for(i=0;i<320;i++){
00292         for (j=0;j<240;j++){
00293             vLCDTFTWriteData(Color);
00294         }
00295     }      
00296 }
00297 
00298 void LCDTFT::vLCDTFTPoint(unsigned short x,unsigned short y,unsigned short Color){
00299 
00300     vLCDTFTAddressSetPoint(x,y);
00301     vLCDTFTWriteData(Color);
00302 }
00303  
00304 void LCDTFT::vLCDTFTText(unsigned short x,unsigned short y,const char *PtrText,const char (*Fuente)[5],unsigned char Alto,unsigned short Color,unsigned short BackColor){
00305    unsigned short i, j, k, l, m, temp,lmax;           
00306    char DataPunto[5]; 
00307    const char *Ptr;
00308    if(orient==0) lmax=LCD_X_MAX;
00309    else lmax=LCD_Y_MAX;
00310     
00311    while(*PtrText!='\0'){
00312       Ptr=(Fuente+*PtrText-' ')[0];
00313       for(i=0;i<5;i++){DataPunto[i]=*Ptr++;}
00314       switch(*PtrText){
00315          case '\n':
00316             y += 7*Alto + 1;
00317          break;
00318          case '\r':
00319             x = 0;
00320          break;
00321          default:
00322             if(x+5*Alto >= lmax){
00323                  x = 0;                           
00324                  y += 7*Alto + 1;                
00325               }
00326               for(j=0; j<5; ++j, x+=Alto){
00327                  for(k=0; k < 7; k++){
00328                     temp=(0x01<<k);
00329                     if((DataPunto[j]&temp)==temp){
00330                        for(l=0; l < Alto; ++l){                         
00331                           for(m=0; m < Alto; ++m){
00332                              vLCDTFTPoint(x+m,y+k*Alto+l,Color);
00333                           }//endform
00334                        }//endforl
00335                     }//endif
00336                     else{
00337                         for(l=0; l < Alto; ++l){                         
00338                           for(m=0; m < Alto; ++m){
00339                              vLCDTFTPoint(x+m,y+k*Alto+l,BackColor);
00340                           }//endform
00341                        }//endforl
00342                         }
00343                  }
00344               }
00345               x++;
00346           break;
00347       } 
00348       *PtrText++;     
00349    }
00350 }
00351 
00352 void LCDTFT::vLCDTFTLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short Color){
00353 
00354    unsigned short dy, dx;
00355    short addx=1, addy=1;
00356    short P, diff;
00357    unsigned short i=0;
00358 
00359    diff=((short)x2-x1);
00360    if(diff<0) diff*=-1;
00361    dx=diff;
00362    diff=((short)y2-y1);
00363    if(diff<0) diff*=-1;
00364    dy=diff;
00365 
00366 
00367    if(x1 > x2)addx = -1;
00368    if(y1 > y2)addy = -1;
00369    if(dx >= dy){
00370       dy *= 2;
00371       P = dy - dx;
00372       diff = P - dx;
00373       for(;i<=dx;++i){
00374          vLCDTFTPoint(x1, y1, Color);
00375          if(P < 0){
00376             P  += dy;
00377             x1 += addx;
00378          }else{
00379             P  += diff;
00380             x1 += addx;
00381             y1 += addy;
00382          }
00383       }
00384    }else{
00385       dx *= 2;
00386       P = dx - dy;
00387       diff = P - dy;
00388       for(; i<=dy; ++i){
00389          vLCDTFTPoint(x1, y1, Color);
00390          if(P < 0){
00391             P  += dx;
00392             y1 += addy;
00393          }else{
00394             P  += diff;
00395             x1 += addx;
00396             y1 += addy;
00397          }
00398       }
00399    }
00400 }
00401 
00402 
00403 void LCDTFT::vLCDTFTRectangle(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,bool Filled,unsigned short Color){
00404    
00405     if(Filled){
00406         int Lenght=(int)(x2-x1);  
00407        
00408             
00409         for(int i=0;i<Lenght;i++){
00410             vLCDTFTLine(x1,y1+i,x2,y1+i,Color);                         
00411         }   
00412     }else{
00413         vLCDTFTLine(x1, y1, x2, y1, Color);     
00414         vLCDTFTLine(x1, y2, x2, y2, Color);
00415         vLCDTFTLine(x1, y1, x1, y2, Color);
00416         vLCDTFTLine(x2, y1, x2, y2, Color);
00417     }
00418 }
00419 
00420 
00421 void LCDTFT::vLCDTFTCircle(unsigned short x,unsigned short y,unsigned short Radius,bool Filled,unsigned short Color){
00422     short  a, b, P;
00423 
00424     a = 0;
00425     b = Radius;
00426     P = 1 - Radius;
00427 
00428     do{
00429         if(Filled){
00430             vLCDTFTLine(x-a, y+b, x+a, y+b, Color);
00431             vLCDTFTLine(x-a, y-b, x+a, y-b, Color);
00432             vLCDTFTLine(x-b, y+a, x+b, y+a, Color);
00433             vLCDTFTLine(x-b, y-a, x+b, y-a, Color);
00434         }else{
00435             vLCDTFTPoint(a+x, b+y, Color);
00436             vLCDTFTPoint(b+x, a+y, Color);
00437             vLCDTFTPoint(x-a, b+y, Color);
00438             vLCDTFTPoint(x-b, a+y, Color);
00439             vLCDTFTPoint(b+x, y-a, Color);
00440             vLCDTFTPoint(a+x, y-b, Color);
00441             vLCDTFTPoint(x-a, y-b, Color);
00442             vLCDTFTPoint(x-b, y-a, Color);
00443         }
00444         if(P < 0) P += 3 + 2 * a++;
00445         else P += 5 + 2 * (a++ - b--);
00446     }while(a <= b);
00447 }
00448 /*
00449 void LCDTFT::vDrawImageBMP24Bits(const char *NameImagen){
00450 
00451     #define OffsetWidthPixel    18
00452     #define OffsetHeighPixel    22
00453     #define OffsetSizeFile      34
00454     #define OffsetInitData      10
00455     #define OffserTipeFile      28
00456     char Nombre[80],k;
00457     unsigned short PosXImagen,PosYImagen;
00458     unsigned char Temp,BufferHeader[54],BufferTemp[3],Adicional;
00459     unsigned int WidthPixel,HeighPixel;
00460     unsigned short TipeFile,InitData,Temp16bits;
00461     union{
00462         unsigned short Val;
00463         struct{
00464             unsigned Blue:5;
00465             unsigned Green:6;
00466             unsigned Red:5;
00467         };
00468     }Color; 
00469 
00470     LocalFileSystem local("mbedMemory");
00471     sprintf(&Nombre[0],"/mbedMemory/");
00472     k=12;
00473     while(*NameImagen!='\0'){
00474         Nombre[k++]=*NameImagen++;
00475     }
00476     
00477     FILE *Imagen = fopen((const char *)&Nombre[0], "r"); // Abrimos archivo para lectura.
00478     // Si no se pudo encontrar archivo:
00479     if(!Imagen) {
00480         vLCDTFTFillScreen(ColorBlack);
00481         return;
00482     }
00483     // Leemos cabecera de archivo
00484     fread(&BufferHeader[0],1,54,Imagen);
00485     
00486     WidthPixel = ((unsigned int)BufferHeader[OffsetWidthPixel + 3]*16777216+BufferHeader[OffsetWidthPixel + 2]*65536+BufferHeader[OffsetWidthPixel + 1]*256+BufferHeader[OffsetWidthPixel]);
00487     HeighPixel = ((unsigned int)BufferHeader[OffsetHeighPixel + 3]*16777216+BufferHeader[OffsetHeighPixel + 2]*65536+BufferHeader[OffsetHeighPixel + 1]*256+BufferHeader[OffsetHeighPixel]);
00488     InitData = ((unsigned short)BufferHeader[OffsetInitData]);
00489     TipeFile = ((unsigned short)BufferHeader[OffserTipeFile + 1]*256 + BufferHeader[OffserTipeFile]);
00490     
00491     if((WidthPixel>LCD_X_MAX) || (HeighPixel>LCD_Y_MAX) || (TipeFile!=24)){
00492         fclose(Imagen);
00493         return;
00494     }
00495     
00496     if(InitData!=54){
00497         for(int k=54;k<InitData;k++){
00498             fread(&Temp,1,1,Imagen);
00499         }
00500     }
00501     
00502     PosXImagen=(LCD_X_MAX/2)-(WidthPixel/2);
00503     PosYImagen=(LCD_Y_MAX/2)+(HeighPixel/2);
00504     
00505     Temp16bits=WidthPixel*3;
00506     Adicional=0;
00507     while(((Temp16bits)%4)!=0){
00508         Adicional++;
00509         Temp16bits++;
00510     }
00511     
00512     for(int k=0,y=PosYImagen;k<HeighPixel;k++,y--){
00513         vLCDTFTAddressSet(PosXImagen,y,PosXImagen+WidthPixel-1,y);
00514         for(int i=0;i<WidthPixel;i++){
00515             fread(&BufferTemp[0],1,3,Imagen); // Leemos 3 bytes (R,G,B)
00516             Color.Blue=BufferTemp[0]>>3;Color.Green=BufferTemp[1]>>2;Color.Red=BufferTemp[2]>>3; // Conversion de 24-bits a 16-bits.-
00517             vLCDTFTWriteData(Color.Val);
00518         }
00519         // Bytes adicionales para que linea sea multiplo de 4.-
00520         for(int p=0;p<Adicional;p++){
00521             fread(&Temp,1,1,Imagen);
00522         }
00523     }
00524     fclose(Imagen);
00525 }
00526 */
00527 void LCDTFT::vLCDTFTDrawImage(unsigned short x,unsigned short y, unsigned short Width, unsigned short Heigh, unsigned int Lenght, const unsigned short *Imagen){
00528 
00529     vLCDTFTAddressSet(x,y,x+Width-1,y+Heigh-1);      
00530     for(int i=0;i<Lenght;i++){
00531         vLCDTFTWriteData(*Imagen++);                         
00532     }
00533 }