2.8" TFT LCD: TFT01-2.8

From ELECFREAKS-WIKI
Jump to: navigation, search

Introduction

TFT LCD module has always been one of the hot products in DIY industry and LCD is basically the necessary products during all projects. This 2.8-inch TFT LCD integrated features of compact, high resolution, UTFT compatible, supporting TFT01 LCD Shield / TFT01 Mega Shield , and it can be directly used with Arduino

  • TFT01_2.8 is a 2.8"TFT LCD Screen Module , 40pins interface , not just a LCD break but include SD card , and touch panel.
  • VCC 3.3V and Backlight LED 3.3V
  • Touch panel, control ic AD7843 ,
  • The LCD in the TFT01 is ILI9325D . It’s 240*320(resolution), the contrast is also very suitable.
  • t’s a support 16bit data interface , easy to drive by many MCU like Arduino ,STM32 ,AVR and 8051.
  • The TFT01_2.8 layout a 40 pins interface for your project , the interface include LCD bus, SD card bus, Touch screen bus and the Flash bus.
  • And we have TFT01 LCD Shield / TFT01 Mega Shield , you can directly plug the TFT01 LCD module in the shield and stand on the Arduino board.


Model:TFT01--2.8

2.8 A.JPG 2.8 C.jpg

Parameter

  • Display Size:2.8
  • Display Resolution:240 * 320
  • Display Interface:Parallel 16 Bit
  • Display Controller :ILI9325D
  • Expand:SD Card Socket
  • Board Size:65 x 50mm
  • Weight:60.00g

Application Ideas

  • Digital Photo Frame (DPF)
  • Video terminals
  • Instrumentation
  • GPS
  • Game consoles
  • Video phones and Portable VCD, DVD

Cautions

  • The I/O of the Panel is 3.3v voltage , so you had better not to directly connect it to the 5v voltage I/O .We suggest using the 30K and 20K resistor to reduce voltage.

TFT01 Family

NewTFT2.4-04-LGR.jpg

Pin definition and Rating

2.8 F.jpg

The pins named with “D_” is the touch bus , the pins named with “SD_” is SD bus, the pins named with “F_” is Flash bus.

TFT01 is work at 3.3v DC, if you need to connect the module with the 5v voltage I/O , you need to add the 30k and 20k resistors to reduce voltage.


Mechanic Dimensions

New Version

New version independent backlight LED-A, PWM supply or 5V supply.

2.8 E.jpg

Usage

Programming

Includes important code snippet. Download the below code. You could direct used TFT-01 Mega Shield v1.2(Recommand),which for Mega1280 or Mega2560 and there are enough IO for Touch and SD card function .


Pant and Touch Code

<syntaxhighlight lang="php">

/*================================================================ This demo code shows how to use the touch screen in TFT01-2.8 The LCD connection is the same as that in 鈥?6 Bit Pant Demo鈥? by Elecfreaks 6/28/2013 ================================================================*/

  1. define LCD_RS 38
  2. define LCD_WR 39
  3. define LCD_CS 40
  4. define LCD_REST 41
  1. define DCLK 6
  2. define CS 5
  3. define DIN 4
  4. define DOUT 3
  5. define IRQ 2

unsigned int TP_X,TP_Y; void spistar() //SPI Start {

 digitalWrite(CS,HIGH);
 digitalWrite(DCLK,HIGH);
 digitalWrite(DIN,HIGH);
 digitalWrite(DCLK,HIGH);

} //********************************************************** void WriteCharTo7843(unsigned char num) //SPI Write Data {

 unsigned char count=0;
 unsigned char temp;
 unsigned nop;
 temp=num;
 digitalWrite(DCLK,LOW);
 for(count=0;count<8;count++)
 {
   if(temp&0x80)
     digitalWrite(DIN,HIGH);
   else
     digitalWrite(DIN,LOW);

   temp=temp<<1; 

   digitalWrite(DCLK,LOW);                
   nop++;
   nop++;
   digitalWrite(DCLK,HIGH);
   nop++;
   nop++;
 }

}

//********************************************************** unsigned int ReadFromCharFrom7843() //SPI Read Data {

 unsigned nop;
 unsigned char count=0;
 unsigned int Num=0;
 for(count=0;count<12;count++)
 {
   Num<<=1;
   digitalWrite(DCLK,HIGH);//DCLK=1; _nop_();_nop_();_nop_();                
   nop++;
   digitalWrite(DCLK,LOW);//DCLK=0; _nop_();_nop_();_nop_();
   nop++;
   if(digitalRead(DOUT)) Num++;
 }
 return(Num);

}

void AD7843(void) {

 digitalWrite(CS,LOW);                    
 WriteCharTo7843(0x90); 
 digitalWrite(DCLK,HIGH);
 digitalWrite(DCLK,LOW); 
 TP_Y=ReadFromCharFrom7843();
 WriteCharTo7843(0xD0);   
 digitalWrite(DCLK,HIGH);
 digitalWrite(DCLK,LOW);
 TP_X=ReadFromCharFrom7843();
 digitalWrite(CS,HIGH);

}


void Lcd_Writ_Bus(char VH,char VL) {

 digitalWrite(LCD_CS,LOW); 
 PORTA = VH;
 PORTC = VL;
 digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);
 digitalWrite(LCD_CS,HIGH);  

}


void Lcd_Write_Com(char da) {

 digitalWrite(LCD_RS,LOW);
 Lcd_Writ_Bus(da>>8, da);

}

void Lcd_Write_Data(char VH,char VL) {

 digitalWrite(LCD_RS,HIGH);
 Lcd_Writ_Bus(VH,VL);

}

void Lcd_Write_Com_Data(int com,int dat) {

    Lcd_Write_Com(com);
    Lcd_Write_Data(dat>>8, dat);

}

void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2) {

     Lcd_Write_Com(0x0020);Lcd_Write_Data(x1>>8,x1);	  //璁剧疆X鍧愭爣浣嶇疆
     Lcd_Write_Com(0x0021);Lcd_Write_Data(y1>>8,y1);     //璁剧疆Y鍧愭爣浣嶇疆
     Lcd_Write_Com(0x0050);Lcd_Write_Data(x1>>8,x1);     //寮€濮媂
     Lcd_Write_Com(0x0052);Lcd_Write_Data(y1>>8,y1);	  //寮€濮媃
     Lcd_Write_Com(0x0051);Lcd_Write_Data(x2>>8,x2);     //缁撴潫X
     Lcd_Write_Com(0x0053);Lcd_Write_Data(y2>>8,y2);     //缁撴潫Y
     Lcd_Write_Com(0x0022);							 

}

void Lcd_Init(void) {

      digitalWrite(LCD_REST,HIGH);
      delay(5); 
      digitalWrite(LCD_REST,LOW);
      delay(15);
      digitalWrite(LCD_REST,HIGH);
      delay(15);
      
      Lcd_Write_Com_Data(0x0001,0x0100); 
      Lcd_Write_Com_Data(0x0002,0x0700); 
      Lcd_Write_Com_Data(0x0003,0x1030); 
      Lcd_Write_Com_Data(0x0004,0x0000); 
      Lcd_Write_Com_Data(0x0008,0x0207);  
      Lcd_Write_Com_Data(0x0009,0x0000);
      Lcd_Write_Com_Data(0x000A,0x0000); 
      Lcd_Write_Com_Data(0x000C,0x0000); 
      Lcd_Write_Com_Data(0x000D,0x0000);
      Lcd_Write_Com_Data(0x000F,0x0000);
     //power on sequence VGHVGL
      Lcd_Write_Com_Data(0x0010,0x0000);   
      Lcd_Write_Com_Data(0x0011,0x0007);  
      Lcd_Write_Com_Data(0x0012,0x0000);  
      Lcd_Write_Com_Data(0x0013,0x0000); 
     //vgh 
      Lcd_Write_Com_Data(0x0010,0x1290);   
      Lcd_Write_Com_Data(0x0011,0x0227);
      //delayms(100);
      //vregiout 
      Lcd_Write_Com_Data(0x0012,0x001d); //0x001b
      //delayms(100); 
      //vom amplitude
      Lcd_Write_Com_Data(0x0013,0x1500);
      //delayms(100); 
      //vom H
      Lcd_Write_Com_Data(0x0029,0x0018); 
      Lcd_Write_Com_Data(0x002B,0x000D); 
     
     //gamma
      Lcd_Write_Com_Data(0x0030,0x0004);
      Lcd_Write_Com_Data(0x0031,0x0307);
      Lcd_Write_Com_Data(0x0032,0x0002);// 0006
      Lcd_Write_Com_Data(0x0035,0x0206);
      Lcd_Write_Com_Data(0x0036,0x0408);
      Lcd_Write_Com_Data(0x0037,0x0507); 
      Lcd_Write_Com_Data(0x0038,0x0204);//0200
      Lcd_Write_Com_Data(0x0039,0x0707); 
      Lcd_Write_Com_Data(0x003C,0x0405);// 0504
      Lcd_Write_Com_Data(0x003D,0x0F02); 
      //ram
      Lcd_Write_Com_Data(0x0050,0x0000); 
      Lcd_Write_Com_Data(0x0051,0x00EF);
      Lcd_Write_Com_Data(0x0052,0x0000); 
      Lcd_Write_Com_Data(0x0053,0x013F);  
      Lcd_Write_Com_Data(0x0060,0xA700); 
      Lcd_Write_Com_Data(0x0061,0x0001); 
      Lcd_Write_Com_Data(0x006A,0x0000); 
      //
      Lcd_Write_Com_Data(0x0080,0x0000); 
      Lcd_Write_Com_Data(0x0081,0x0000); 
      Lcd_Write_Com_Data(0x0082,0x0000); 
      Lcd_Write_Com_Data(0x0083,0x0000); 
      Lcd_Write_Com_Data(0x0084,0x0000); 
      Lcd_Write_Com_Data(0x0085,0x0000); 
      //
      Lcd_Write_Com_Data(0x0090,0x0010); 
      Lcd_Write_Com_Data(0x0092,0x0600); 
      Lcd_Write_Com_Data(0x0093,0x0003); 
      Lcd_Write_Com_Data(0x0095,0x0110); 
      Lcd_Write_Com_Data(0x0097,0x0000); 
      Lcd_Write_Com_Data(0x0098,0x0000);
      Lcd_Write_Com_Data(0x0007,0x0133);

}

void Pant(char VH,char VL) {

 int i,j;
 Address_set(0,0,239,319);
 for(i=0;i<320;i++)
 {
   for (j=0;j<240;j++)
   {
     Lcd_Write_Data(VH,VL);
   }

 }

}

void setup() {

 for(int p=22;p<42;p++)
 {
   pinMode(p,OUTPUT);
 }
 for(int p=2; p<7;p++)
     pinMode(p,OUTPUT);
 pinMode(DOUT,INPUT);
 pinMode(IRQ,INPUT);

 Lcd_Init();         
 Pant(0x00, 0x00);
 delay(500); 

}

void loop() {

 unsigned char flag;
 unsigned char ss[6];	
 unsigned int lx,ly;
 spistar();  
 int pacy=random(0, 7);  
 while(digitalRead(IRQ)==0)
 {  	
     digitalWrite(LCD_CS,LOW); 
     AD7843();
     lx=240-((TP_X-340)*10/144);
     if(lx>237) lx=237;
     ly=320-((TP_Y-320)/11);
     if(ly<0) ly=0;
     Address_set(lx,ly,lx+2,ly+2);
     switch(pacy)
                               {
                                 case 0: for(int i=0; i<5; i++)  Lcd_Write_Data(0xF8,0x00);  break;   //Red
                                 case 1: for(int i=0; i<5; i++)  Lcd_Write_Data(0xFF,0xE0);  break;   //Yellow
                                 case 2: for(int i=0; i<5; i++)  Lcd_Write_Data(0xFF,0xFF);  break;   //White 
                                 case 3: for(int i=0; i<5; i++)  Lcd_Write_Data(0x05,0x1F);  break;   //Blue
                                 case 4: for(int i=0; i<5; i++)  Lcd_Write_Data(0x00,0x1F);  break;   //Blue-2
                                 case 5: for(int i=0; i<5; i++)  Lcd_Write_Data(0xF8,0x1F);  break;   //Magenta
                                 case 6: for(int i=0; i<5; i++)  Lcd_Write_Data(0x07,0xE0);  break;   //Green
                                 case 7: for(int i=0; i<5; i++)  Lcd_Write_Data(0x7F,0xFF);  break;   //Cyan
                                 defoult:for(int i=0; i<5; i++)  Lcd_Write_Data(0x00,0x00);  break;   //Black
                               }
     digitalWrite(LCD_CS,HIGH); 
   }

}


</syntaxhighlight>

Example

The projects and application examples.

Bill of Materials (BOM) /parts list

All the components used to produce the product.

FAQ

Please list your question here:

Support

If you have questions or other better design ideas,

Version Tracker

Revision Descriptions Release
v1.0 Initial public release date

Bug Tracker

Bug Tracker is the place you can publish any bugs you think you might have found during use. Please write down what you have to say, your answers will help us improve our

products.

Additional Idea

The Additional Idea is the place to write your project ideas about this product, or other usages you've found. Or you can write them on Projects page.

Resources

How to buy

Click here to buy:http://www.elecfreaks.com/estore/2-8-tft-lcd-tft01-2-8.html

See Also

Other related products and resources.

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are

licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries