TFT01 LCD Shield

From ELECFREAKS-WIKI
Jump to: navigation, search

Introduction

The TFT01 LCD module is work in 3.3V voltage level and it's not compatible with Arduino pins , so we make a shield for Arduino. Now you can directly plug the TFT01 in the shield and stand on the Arduino board.

The TFT01 shield support both 16 bit mode and 8 bit mode, you can use 2.4" or 3.2" with it . If you use the 8 bit mode , you can use the SD card or Touch in the TFT01 either .There is setting 10 Pin(D_CS/SD_CS), when you use 8 bit mode , you can select using SD card(10 Pin set LOW) or Touch(10 Pin set High) function.

Model:SHD09
Arduino Shield TFT01 1.jpg

Feature

  • Compatible with Arduino pins
  • Support 8 bit and 16 bit mode
  • Software switch SD card or Touch function
  • Size: 550 mm x 550 mm

Application Ideas

  • Digital Photo Frame (DPF)
  • Video terminals
  • GPS
  • Game consoles

Cautions

  • The TFT01 shield support both 16 bit mode and 8 bit mode, if you use the 8 bit mode , you can use the SD card or Touch in the TFT01 either.
  • Select SD card or Touch function by 10 Pin(D_CS/SD_CS), select using SD card(set D10 Pin LOW enable) or Touch(set D10 Pin High enable)

Schematic

Arduino TFT01 Shield2.jpg

Specification

Pin definition and Rating

TFT01-2.4-04.jpg

Mechanic Dimensions

  • Dimensions: 550 mm x 550 mm

Arduino TFT01 Shield.jpg

Usage

Hardware Installation

Programming

  • Pant Screen

TFT01-2.4-11.jpg


8 bit Pant Demo code

Download the code below into Arduino :

<syntaxhighlight lang="php">

/* The demo is in 8 bit mode, DB9-DB16 to pin D0-D7 ; DB0 – DB8 to GND ; LDEA to 3.3V  ; VCC to 5V ; GND to GND RESET to A2 CS to A3 WR to A4 RS to A5

  • /
  1. include <avr/pgmspace.h>
  1. define LCD_RS 19
  2. define LCD_WR 18
  3. define LCD_CS 17
  4. define LCD_REST 16

void LCD_Writ_Bus(char VH,char VL) {

 unsigned char i,temp,data; 
 data=VH; 
 for(i=0;i<8;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }
 digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);
 data=VL;
 for(i=0;i<8;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }		
 digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);

}


void LCD_Write_COM(char VH,char VL) //send com {

 digitalWrite(LCD_RS,LOW);
 LCD_Writ_Bus(VH,VL);

}


void LCD_Write_DATA(char VH,char VL) //send data {

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

}

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

 LCD_Write_COM(0x00,0x20);
 LCD_Write_DATA(x1>>8,x1);    
 LCD_Write_COM(0x00,0x21);
 LCD_Write_DATA(y1>>8,y1);   
 LCD_Write_COM(0x00,0x50);
 LCD_Write_DATA(x1>>8,x1);   
 LCD_Write_COM(0x00,0x52);
 LCD_Write_DATA(y1>>8,y1);   
 LCD_Write_COM(0x00,0x51);
 LCD_Write_DATA(x2>>8,x2);  
 LCD_Write_COM(0x00,0x53);
 LCD_Write_DATA(y2>>8,y2);   
 LCD_Write_COM(0x00,0x22);           				 

}

void LCD_Init(void) {

 digitalWrite(LCD_REST,HIGH);
 delay(5); 
 digitalWrite(LCD_REST,LOW);
 delay(5);
 digitalWrite(LCD_REST,HIGH);
 delay(5);

 digitalWrite(LCD_CS,LOW);  
 //************* Start Initial Sequence **********//
 LCD_Write_COM(0x00,0xE5); 
 LCD_Write_DATA(0x78,0xF0); // set SRAM internal timing
 LCD_Write_COM(0x00,0x01); 
 LCD_Write_DATA(0x01,0x00); // set SS and SM bit
 LCD_Write_COM(0x00,0x02); 
 LCD_Write_DATA(0x07,0x00); // set 1 line inversion
 LCD_Write_COM(0x00,0x03); 
 LCD_Write_DATA(0x10,0x30); // set GRAM write direction and BGR=1.
 LCD_Write_COM(0x00,0x04); 
 LCD_Write_DATA(0x00,0x00); // Resize register
 LCD_Write_COM(0x00,0x08); 
 LCD_Write_DATA(0x02,0x07); // set the back porch and front porch
 LCD_Write_COM(0x00,0x09); 
 LCD_Write_DATA(0x00,0x00); // set non-display area refresh cycle ISC[3:0]
 LCD_Write_COM(0x00,0x0A); 
 LCD_Write_DATA(0x00,0x00); // FMARK function
 LCD_Write_COM(0x00,0x0C); 
 LCD_Write_DATA(0x00,0x00); // RGB interface setting
 LCD_Write_COM(0x00,0x0D); 
 LCD_Write_DATA(0x00,0x00); // Frame marker Position
 LCD_Write_COM(0x00,0x0F); 
 LCD_Write_DATA(0x00,0x00); // RGB interface polarity
 //*************Power On sequence ****************//
 LCD_Write_COM(0x00,0x10); 
 LCD_Write_DATA(0x00,0x00); // SAP, BT[3:0], AP, DSTB, SLP, STB
 LCD_Write_COM(0x00,0x11); 
 LCD_Write_DATA(0x00,0x07); // DC1[2:0], DC0[2:0], VC[2:0]
 LCD_Write_COM(0x00,0x12); 
 LCD_Write_DATA(0x00,0x00); // VREG1OUT voltage
 LCD_Write_COM(0x00,0x13); 
 LCD_Write_DATA(0x00,0x00); // VDV[4:0] for VCOM amplitude
 LCD_Write_COM(0x00,0x07); 
 LCD_Write_DATA(0x00,0x01);
 delay(50); // Dis-charge capacitor power voltage
 LCD_Write_COM(0x00,0x10); 
 LCD_Write_DATA(0x10,0x90); // 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
 LCD_Write_COM(0x00,0x11); 
 LCD_Write_DATA(0x02,0x27); // DC1[2:0], DC0[2:0], VC[2:0]
 delay(50); // Delay 50ms
 LCD_Write_COM(0x00,0x12); 
 LCD_Write_DATA(0x00,0x1F); //001C// Internal reference voltage= Vci;
 delay(50); // Delay 50ms
 LCD_Write_COM(0x00,0x13); 
 LCD_Write_DATA(0x15,0x00); //0x1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
 LCD_Write_COM(0x00,0x29); 
 LCD_Write_DATA(0x00,0x27); //0x0012 //001a  Set VCM[5:0] for VCOMH  //0x0025  0034
 LCD_Write_COM(0x00,0x2B); 
 LCD_Write_DATA(0x00,0x0D); // Set Frame Rate   000C
 delay(50); // Delay 50ms
 LCD_Write_COM(0x00,0x20); 
 LCD_Write_DATA(0x00,0x00); // GRAM horizontal Address
 LCD_Write_COM(0x00,0x21); 
 LCD_Write_DATA(0x00,0x00); // GRAM Vertical Address
 // ----------- Adjust the Gamma Curve ----------//
 LCD_Write_COM(0x00,0x30); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x31); 
 LCD_Write_DATA(0x07,0x07);
 LCD_Write_COM(0x00,0x32); 
 LCD_Write_DATA(0x03,0x07);
 LCD_Write_COM(0x00,0x35); 
 LCD_Write_DATA(0x02,0x00);
 LCD_Write_COM(0x00,0x36); 
 LCD_Write_DATA(0x00,0x08);//0207
 LCD_Write_COM(0x00,0x37); 
 LCD_Write_DATA(0x00,0x04);//0306
 LCD_Write_COM(0x00,0x38); 
 LCD_Write_DATA(0x00,0x00);//0102
 LCD_Write_COM(0x00,0x39); 
 LCD_Write_DATA(0x07,0x07);//0707
 LCD_Write_COM(0x00,0x3C); 
 LCD_Write_DATA(0x00,0x02);//0702
 LCD_Write_COM(0x00,0x3D); 
 LCD_Write_DATA(0x1D,0x04);//1604

   //------------------ Set GRAM area ---------------//
 LCD_Write_COM(0x00,0x50); 
 LCD_Write_DATA(0x00,0x00); // Horizontal GRAM Start Address
 LCD_Write_COM(0x00,0x51); 
 LCD_Write_DATA(0x00,0xEF); // Horizontal GRAM End Address
 LCD_Write_COM(0x00,0x52); 
 LCD_Write_DATA(0x00,0x00); // Vertical GRAM Start Address
 LCD_Write_COM(0x00,0x53); 
 LCD_Write_DATA(0x01,0x3F); // Vertical GRAM Start Address
 LCD_Write_COM(0x00,0x60); 
 LCD_Write_DATA(0xA7,0x00); // Gate Scan Line
 LCD_Write_COM(0x00,0x61); 
 LCD_Write_DATA(0x00,0x01); // NDL,VLE, REV
 LCD_Write_COM(0x00,0x6A); 
 LCD_Write_DATA(0x00,0x00); // set scrolling line
 //-------------- Partial Display Control ---------//
 LCD_Write_COM(0x00,0x80); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x81); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x82); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x83); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x84); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x85); 
 LCD_Write_DATA(0x00,0x00);
 //-------------- Panel Control -------------------//
 LCD_Write_COM(0x00,0x90); 
 LCD_Write_DATA(0x00,0x10);
 LCD_Write_COM(0x00,0x92); 
 LCD_Write_DATA(0x06,0x00);
 LCD_Write_COM(0x00,0x07); 
 LCD_Write_DATA(0x01,0x33); // 262K color and display ON
 digitalWrite(LCD_CS,HIGH);  

}

void Pant(char VH,char VL) {

 int i,j;
 digitalWrite(LCD_CS,LOW); 
 Address_set(0,0,240,320);
 for(i=0;i<320;i++)
 {
   for (j=0;j<240;j++)
   {
     LCD_Write_DATA(VH,VL);
   }

 }
 digitalWrite(LCD_CS,HIGH);  

}

void setup() {

 for(int p=0;p<20;p++)
 {
   pinMode(p,OUTPUT);
 }
 LCD_Init();          

}

void loop() {

  Pant(0x0, 0x0);
  delay(500);
  Pant(0xff, 0x00);
  delay(500);
  Pant(0x00, 0xff);
  delay(500);
  Pant(0xff, 0xff);
  delay(500);

} </syntaxhighlight>

16 bit Pant Demo code

<syntaxhighlight lang="php"> /*

This example code is 16bit mode for TFT01 demo.

Connect the pins to Arduino first : DB0-DB16 to pin D0-D13 , pin A0-A1 of Arduino RESET to A2 CS to A3 WR to A4 RS to A5

All the data pins of Arduino is used ….So , we just can connect the RD to 3.3V. We don’t used it because we don’t need to read back the data from the screen. Connect the power pins : LCD-A to 3.3V , VCC to 5V , GND to GND

Note that the LCD is use the 3.3V voltage level , so if you want to connect the 5V Arduino pins to it , you need add a resister about 20K to reduce voltage. We use the 3.3V Arduino Pro which work in 8M , so we connect the pins directly — this is why we used 16 bit mode, 8 bit mode is too slow to refresh the screen.

  • /
  1. define Bus_16
  2. define LCD_RS 19
  3. define LCD_WR 18
  4. define LCD_CS 17
  5. define LCD_REST 16

void Lcd_Writ_Bus(char VH,char VL) {

 unsigned char i,temp,data; 
 data=VH;
 for(i=0;i<8;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }	 
 data=VL; 
 for(i=8;i<16;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }	
 digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);

}


void Lcd_Write_Com(char VH,char VL) {

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

}

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>>8,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(0x00,0x20);
     Lcd_Write_Data(x1>>8,x1);	  //setting X
     Lcd_Write_Com(0x00,0x21);
     Lcd_Write_Data(y1>>8,y1);   //setting Y
     Lcd_Write_Com(0x00,0x50);
     Lcd_Write_Data(x1>>8,x1);   //starting X
     Lcd_Write_Com(0x00,0x52);
     Lcd_Write_Data(y1>>8,y1);	  //starting Y
     Lcd_Write_Com(0x00,0x51);
     Lcd_Write_Data(x2>>8,x2);   //ending X
     Lcd_Write_Com(0x00,0x53);
     Lcd_Write_Data(y2>>8,y2);   //ending Y
     Lcd_Write_Com(0x00,0x22);							 

}

void Lcd_Init(void) {

      digitalWrite(LCD_REST,HIGH);
      delay(5); 
      digitalWrite(LCD_REST,LOW);
      delay(15);
      digitalWrite(LCD_REST,HIGH);
      delay(15);
       digitalWrite(LCD_CS,LOW);
       Lcd_Write_Com_Data(0x0001, 0x0100); // set SS and SM bit

Lcd_Write_Com_Data(0x0002, 0x0200); // set 1 line inversion Lcd_Write_Com_Data(0x0003, 0x1030); // set GRAM write direction and BGR=1. Lcd_Write_Com_Data(0x0004, 0x0000); // Resize register Lcd_Write_Com_Data(0x0008, 0x0207); // set the back porch and front porch Lcd_Write_Com_Data(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0] Lcd_Write_Com_Data(0x000A, 0x0000); // FMARK function Lcd_Write_Com_Data(0x000C, 0x0000); // RGB interface setting Lcd_Write_Com_Data(0x000D, 0x0000); // Frame marker Position Lcd_Write_Com_Data(0x000F, 0x0000); // RGB interface polarity //*************Power On sequence ****************// Lcd_Write_Com_Data(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB Lcd_Write_Com_Data(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0] Lcd_Write_Com_Data(0x0012, 0x0000); // VREG1OUT voltage Lcd_Write_Com_Data(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude Lcd_Write_Com_Data(0x0007, 0x0001); delay(200); // Dis-charge capacitor power voltage Lcd_Write_Com_Data(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB Lcd_Write_Com_Data(0x0011, 0x0227); // Set DC1[2:0], DC0[2:0], VC[2:0] delay(50); // Delay 50ms Lcd_Write_Com_Data(0x0012, 0x000D); // 0012 delay(50); // Delay 50ms Lcd_Write_Com_Data(0x0013, 0x1200); // VDV[4:0] for VCOM amplitude Lcd_Write_Com_Data(0x0029, 0x000A); // 04 VCM[5:0] for VCOMH Lcd_Write_Com_Data(0x002B, 0x000D); // Set Frame Rate delay(50); // Delay 50ms Lcd_Write_Com_Data(0x0020, 0x0000); // GRAM horizontal Address Lcd_Write_Com_Data(0x0021, 0x0000); // GRAM Vertical Address // ----------- Adjust the Gamma Curve ----------// Lcd_Write_Com_Data(0x0030, 0x0000); Lcd_Write_Com_Data(0x0031, 0x0404); Lcd_Write_Com_Data(0x0032, 0x0003); Lcd_Write_Com_Data(0x0035, 0x0405); Lcd_Write_Com_Data(0x0036, 0x0808); Lcd_Write_Com_Data(0x0037, 0x0407); Lcd_Write_Com_Data(0x0038, 0x0303); Lcd_Write_Com_Data(0x0039, 0x0707); Lcd_Write_Com_Data(0x003C, 0x0504); Lcd_Write_Com_Data(0x003D, 0x0808); //------------------ Set GRAM area ---------------// Lcd_Write_Com_Data(0x0050, 0x0000); // Horizontal GRAM Start Address Lcd_Write_Com_Data(0x0051, 0x00EF); // Horizontal GRAM End Address Lcd_Write_Com_Data(0x0052, 0x0000); // Vertical GRAM Start Address Lcd_Write_Com_Data(0x0053, 0x013F); // Vertical GRAM Start Address Lcd_Write_Com_Data(0x0060, 0xA700); // Gate Scan Line Lcd_Write_Com_Data(0x0061, 0x0001); // NDL,VLE, REV

Lcd_Write_Com_Data(0x006A, 0x0000); // set scrolling line //-------------- Partial Display Control ---------// 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); //-------------- Panel Control -------------------// Lcd_Write_Com_Data(0x0090, 0x0010); Lcd_Write_Com_Data(0x0092, 0x0000); Lcd_Write_Com_Data(0x0007, 0x0133); // 262K color and display ON

       digitalWrite(LCD_CS,HIGH);

}

void Pant(char VH,char VL) {

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

 }
 digitalWrite(LCD_CS,HIGH);  

}

void setup() {

 for(int p=0;p<20;p++)
 {
   pinMode(p,OUTPUT);
 }
 Lcd_Init();          

}

void loop() {

  Pant(0x0, 0x0);
  delay(500);
  Pant(0xff, 0x00);
  delay(500);
  Pant(0x00, 0xff);
  delay(500);
  Pant(0xff, 0xff);
  delay(500);

}

</syntaxhighlight>


  • Touch Demo

TFT01-2.4-13.jpg

8 bit Touch Demo

<syntaxhighlight lang="php">

/*================================================================ This demo code shows how to use the touch screen in TFT01 The LCD connection is the same as that in “8 Bit Pant Demo“

by Elecfreaks ================================================================*/

  1. define LCD_RS 19
  2. define LCD_WR 18
  3. define LCD_CS 17
  4. define LCD_REST 16
  1. define DCLK 15
  2. define DIN 14
  3. define CS 10
  4. define DOUT 9
  5. define IRQ 8

unsigned int TP_X,TP_Y;


void spistar() //SPI Start {

 digitalWrite(CS,LOW);
 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 LCD_Writ_Bus(char VH,char VL) {

 unsigned char i,temp,data; 
 data=VH; 
 for(i=0;i<8;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }
 digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);
 data=VL;
 for(i=0;i<8;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }		
 digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);

}


void LCD_Write_COM(char VH,char VL) {

 digitalWrite(LCD_RS,LOW);
 LCD_Writ_Bus(VH,VL);

}


void LCD_Write_DATA(char VH,char VL) {

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

}

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

 LCD_Write_COM(0x00,0x20);
 LCD_Write_DATA(x1>>8,x1);    
 LCD_Write_COM(0x00,0x21);
 LCD_Write_DATA(y1>>8,y1);   
 LCD_Write_COM(0x00,0x50);
 LCD_Write_DATA(x1>>8,x1);   
 LCD_Write_COM(0x00,0x52);
 LCD_Write_DATA(y1>>8,y1);   
 LCD_Write_COM(0x00,0x51);
 LCD_Write_DATA(x2>>8,x2);  
 LCD_Write_COM(0x00,0x53);
 LCD_Write_DATA(y2>>8,y2);   
 LCD_Write_COM(0x00,0x22);           				 

}

void LCD_Init(void) {

 digitalWrite(LCD_REST,HIGH);
 delay(5); 
 digitalWrite(LCD_REST,LOW);
 delay(5);
 digitalWrite(LCD_REST,HIGH);
 delay(5);
 digitalWrite(LCD_CS,LOW);  
 //************* Start Initial Sequence **********//
 LCD_Write_COM(0x00,0xE5); 
 LCD_Write_DATA(0x78,0xF0); // set SRAM internal timing
 LCD_Write_COM(0x00,0x01); 
 LCD_Write_DATA(0x01,0x00); // set SS and SM bit
 LCD_Write_COM(0x00,0x02); 
 LCD_Write_DATA(0x07,0x00); // set 1 line inversion
 LCD_Write_COM(0x00,0x03); 
 LCD_Write_DATA(0x10,0x30); // set GRAM write direction and BGR=1.
 LCD_Write_COM(0x00,0x04); 
 LCD_Write_DATA(0x00,0x00); // Resize register
 LCD_Write_COM(0x00,0x08); 
 LCD_Write_DATA(0x02,0x07); // set the back porch and front porch
 LCD_Write_COM(0x00,0x09); 
 LCD_Write_DATA(0x00,0x00); // set non-display area refresh cycle ISC[3:0]
 LCD_Write_COM(0x00,0x0A); 
 LCD_Write_DATA(0x00,0x00); // FMARK function
 LCD_Write_COM(0x00,0x0C); 
 LCD_Write_DATA(0x00,0x00); // RGB interface setting
 LCD_Write_COM(0x00,0x0D); 
 LCD_Write_DATA(0x00,0x00); // Frame marker Position
 LCD_Write_COM(0x00,0x0F); 
 LCD_Write_DATA(0x00,0x00); // RGB interface polarity
 //*************Power On sequence ****************//
 LCD_Write_COM(0x00,0x10); 
 LCD_Write_DATA(0x00,0x00); // SAP, BT[3:0], AP, DSTB, SLP, STB
 LCD_Write_COM(0x00,0x11); 
 LCD_Write_DATA(0x00,0x07); // DC1[2:0], DC0[2:0], VC[2:0]
 LCD_Write_COM(0x00,0x12); 
 LCD_Write_DATA(0x00,0x00); // VREG1OUT voltage
 LCD_Write_COM(0x00,0x13); 
 LCD_Write_DATA(0x00,0x00); // VDV[4:0] for VCOM amplitude
 LCD_Write_COM(0x00,0x07); 
 LCD_Write_DATA(0x00,0x01);
 delay(50); // Dis-charge capacitor power voltage
 LCD_Write_COM(0x00,0x10); 
 LCD_Write_DATA(0x10,0x90); // 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
 LCD_Write_COM(0x00,0x11); 
 LCD_Write_DATA(0x02,0x27); // DC1[2:0], DC0[2:0], VC[2:0]
 delay(50); // Delay 50ms
 LCD_Write_COM(0x00,0x12); 
 LCD_Write_DATA(0x00,0x1F); //001C// Internal reference voltage= Vci;
 delay(50); // Delay 50ms
 LCD_Write_COM(0x00,0x13); 
 LCD_Write_DATA(0x15,0x00); //0x1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
 LCD_Write_COM(0x00,0x29); 
 LCD_Write_DATA(0x00,0x27); //0x0012 //001a  Set VCM[5:0] for VCOMH  //0x0025  0034
 LCD_Write_COM(0x00,0x2B); 
 LCD_Write_DATA(0x00,0x0D); // Set Frame Rate   000C
 delay(50); // Delay 50ms
 LCD_Write_COM(0x00,0x20); 
 LCD_Write_DATA(0x00,0x00); // GRAM horizontal Address
 LCD_Write_COM(0x00,0x21); 
 LCD_Write_DATA(0x00,0x00); // GRAM Vertical Address
 // ----------- Adjust the Gamma Curve ----------//
 LCD_Write_COM(0x00,0x30); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x31); 
 LCD_Write_DATA(0x07,0x07);
 LCD_Write_COM(0x00,0x32); 
 LCD_Write_DATA(0x03,0x07);
 LCD_Write_COM(0x00,0x35); 
 LCD_Write_DATA(0x02,0x00);
 LCD_Write_COM(0x00,0x36); 
 LCD_Write_DATA(0x00,0x08);//0207
 LCD_Write_COM(0x00,0x37); 
 LCD_Write_DATA(0x00,0x04);//0306
 LCD_Write_COM(0x00,0x38); 
 LCD_Write_DATA(0x00,0x00);//0102
 LCD_Write_COM(0x00,0x39); 
 LCD_Write_DATA(0x07,0x07);//0707
 LCD_Write_COM(0x00,0x3C); 
 LCD_Write_DATA(0x00,0x02);//0702
 LCD_Write_COM(0x00,0x3D); 
 LCD_Write_DATA(0x1D,0x04);//1604
   //------------------ Set GRAM area ---------------//
 LCD_Write_COM(0x00,0x50); 
 LCD_Write_DATA(0x00,0x00); // Horizontal GRAM Start Address
 LCD_Write_COM(0x00,0x51); 
 LCD_Write_DATA(0x00,0xEF); // Horizontal GRAM End Address
 LCD_Write_COM(0x00,0x52); 
 LCD_Write_DATA(0x00,0x00); // Vertical GRAM Start Address
 LCD_Write_COM(0x00,0x53); 
 LCD_Write_DATA(0x01,0x3F); // Vertical GRAM Start Address
 LCD_Write_COM(0x00,0x60); 
 LCD_Write_DATA(0xA7,0x00); // Gate Scan Line
 LCD_Write_COM(0x00,0x61); 
 LCD_Write_DATA(0x00,0x01); // NDL,VLE, REV
 LCD_Write_COM(0x00,0x6A); 
 LCD_Write_DATA(0x00,0x00); // set scrolling line
 //-------------- Partial Display Control ---------//
 LCD_Write_COM(0x00,0x80); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x81); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x82); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x83); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x84); 
 LCD_Write_DATA(0x00,0x00);
 LCD_Write_COM(0x00,0x85); 
 LCD_Write_DATA(0x00,0x00);
 //-------------- Panel Control -------------------//
 LCD_Write_COM(0x00,0x90); 
 LCD_Write_DATA(0x00,0x10);
 LCD_Write_COM(0x00,0x92); 
 LCD_Write_DATA(0x06,0x00);
 LCD_Write_COM(0x00,0x07); 
 LCD_Write_DATA(0x01,0x33); // 262K color and display ON
 digitalWrite(LCD_CS,HIGH);  

}

void Pant(char VH,char VL) {

 int i,j;
 digitalWrite(LCD_CS,LOW); 
 Address_set(0,0,240,320);
 for(i=0;i<320;i++)
 {
   for (j=0;j<240;j++)
   {
     LCD_Write_DATA(VH,VL);
   }
 }
 digitalWrite(LCD_CS,HIGH);  

}


void AD7843(void) {

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

}



void setup() {

 unsigned char p;
 int i,j,k;
 for(p=0;p<20;p++)
 {
   pinMode(p,OUTPUT);
 }
 pinMode(DOUT,INPUT);
 pinMode(IRQ,INPUT);
 LCD_Init();  
 Pant(0xff,0xff);   

}

void loop() {

 unsigned char flag;
 unsigned char ss[6];	
 unsigned int lx,ly;
 spistar();  
 while(1)
 {
   flag = digitalRead(IRQ); 
   if (flag == 0)
   {  	
     digitalWrite(LCD_CS,LOW); 
     AD7843();
     lx=240-((TP_X-220)/16);
     ly=320-((TP_Y-400)/11);
     Address_set(lx,ly,lx+2,ly+2);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     LCD_Write_DATA(0,255);
     digitalWrite(LCD_CS,HIGH); 
   }
 }

}

</syntaxhighlight>


  • Show Picture

TFT01-2.4-12.jpg

8 bit Show Picture Demo

Show the Picture you must have the picture array, maybe you need a tool which could conver image to array.

<syntaxhighlight lang="php"> unsigned char image[3200]={ /* 0X00,0X10,0X28,0X00,0X28,0X00,0X01,0X1B, */ 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, . . . };

...

void loop() {

  Pant(0xff,0xff);	 // Clear TFT

digitalWrite(LCD_CS,LOW); for(int k=0;k<8;k++) { for(int j=0;j<6;j++) { Address_set(40*j,40*k,40*j+39,40*k+39); for(int i=0;i<1600;i++) LCD_Write_DATA(image[i*2+1],image[i*2]); } } digitalWrite(LCD_CS,HIGH); delay(1000);

}


</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/lcd-tft01-arduino-shield-v2-0-shd09.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