Go Down

Topic: 2.4 inch TFT touch LCD Screen Module For Arduino UNO R3 SD low price jocks (Read 206585 times) previous topic - next topic

art100

New shield new problem  :smiley-roll:
I buy 2-4-inch-TFT-touch-LCD-Screen-Module-For-Arduino-UNO  ]:D
link on pcb http://www.mcufriend.com bad :(
name on pcb noname :(
price very very low  ]:D
support not :(
link on page seller have problem :( https://drive.google.com/file/d/0B3hqYAvAOKllZ0M3d3E4REdiS2c/edit?usp=sharing
http://www.aliexpress.com/item/2-4-inch-TFT-touch-LCD-Screen-Module-For-Arduino-UNO-Free-Shipping/1418497586.html

On shield read 2 simple buffers on pins and 1 power suppler 5v-3.3v problem problem problem  ]:D
14 hours problem problem problem   :smiley-mr-green:
Yhooo-hooo-hooo
1-one example to work  :smiley-roll:

very bad code  :smiley-zipper:
to work



Quiest:
Maybe is work code for TFT+Touch+SD ?


-------------------------
example bad code to work
Code: [Select]

#include "TFTLCD.h"
#include "TouchScreen.h"


//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:



#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM  7 // can be a digital pin
#define XP  6  // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
// optional
#define LCD_RESET A4

// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF



TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
 Serial.begin(9600);
 Serial.println("Paint!");
 
 tft.reset();
 
 uint16_t identifier = tft.readRegister(0x0);


 tft.initDisplay();
 tft.fillScreen(BLACK);
 
 tft.fillRect(0, 320-BOXSIZE, BOXSIZE, 320,MAGENTA );
 tft.fillRect(BOXSIZE, 320-BOXSIZE, BOXSIZE, 320,BLUE );
 tft.fillRect(BOXSIZE*2, 320-BOXSIZE, BOXSIZE, 320,CYAN );
 tft.fillRect(BOXSIZE*3, 320-BOXSIZE, BOXSIZE, 320, GREEN);
 tft.fillRect(BOXSIZE*4, 320-BOXSIZE, BOXSIZE, 320, YELLOW);
 tft.fillRect(BOXSIZE*5, 320-BOXSIZE, BOXSIZE, 320, RED);
// tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);

// tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
currentcolor = RED;

 pinMode(13, OUTPUT);
}



#define MINPRESSURE 10
#define MAXPRESSURE 1000



void loop()
{
 digitalWrite(13, HIGH);
 Point p = ts.getPoint();
 digitalWrite(13, LOW);


 pinMode(XM, OUTPUT);
 pinMode(YP, OUTPUT);
 //pinMode(YM, OUTPUT);

 // we have some minimum pressure we consider 'valid'
 // pressure of 0 means no pressing!

 if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {

   
   if (p.y < (TS_MINY-5)) {
     Serial.println("erase");
    // press the bottom of the screen to erase
     tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
     
   }
   // turn from 0->1023 to tft.width
   p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
   p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);

   if (p.y < BOXSIZE) {
      oldcolor = currentcolor;

 
      if (p.x < BOXSIZE) {
        currentcolor = RED;
     //   tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.x < BOXSIZE*2) {
        currentcolor = YELLOW;
      //  tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.x < BOXSIZE*3) {
        currentcolor = GREEN;
      //  tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.x < BOXSIZE*4) {
        currentcolor = CYAN;
     //   tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.x < BOXSIZE*5) {
        currentcolor = BLUE;
  //      tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.x < BOXSIZE*6) {
        currentcolor = MAGENTA;
      //  tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
      }
     
     // if (oldcolor != currentcolor) {
    //     if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE,MAGENTA );
   //      if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE,BLUE );
   //      if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE,CYAN );
   //      if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, GREEN);
   //      if (oldcolor == BLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, YELLOW);
   //      if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, RED);
    //  }
   }
   if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
     tft.fillCircle(240-p.x, 320-p.y, PENRADIUS, currentcolor);
   }
 }
}

maybe good code
arduino-2.6-7781-after12.22\libraries\TFTLCD-7781\TFTLCD??\TFTLCD.h
-----------------------------------------------------------^^^^-this is jock seller-or idiotism---:)

art100

Quest?
Search sequence
#include....h...cpp...o

1.The current directory?
2. \arduino\ ??? \hardware\ ???
\arduino\ ??? \library\???
\arduino\ ??? \core\???
?
?
?
3.c:\windows\system32


Where read help?

art100


Code: [Select]

#define LCD_CS A3   
#define LCD_CD A2   
#define LCD_WR A1   
#define LCD_RD A0   
// you can also just connect RESET to the arduino RESET pin
#define LCD_RESET A4
//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:
// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF

#include "TFTLCD.h"

TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

void setup(void) {
  Serial.begin(9600);
  Serial.println("8 Bit LCD test!");
 
 
  tft.reset();
 
  //uint16_t identifier = tft.readRegister(0x0);
//  if (identifier == 0x9325)
//  {
//   Serial.println("Found ILI9325");
// } else if (identifier == 0x9328)
  //{
  //  Serial.println("Found ILI9328");
  //} else
// {
//   Serial.print("Unknown driver chip ");
//   Serial.println(identifier, HEX);
  //  while (1);
  //} 

  tft.initDisplay();
 
  testtext(YELLOW);


}

void loop(void) {


}



void testFillRoundRect() {
  tft.fillScreen(BLACK);
 
  for (uint16_t x=tft.width(); x > 20 ; x-=6) {
    tft.fillRoundRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, x/8,  tft.Color565(0, x, 0));
}
}

void testRoundRect() {
  tft.fillScreen(BLACK);
 
  for (uint16_t x=0; x < tft.width(); x+=6) {
    tft.drawRoundRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, x/8, tft.Color565(x, 0, 0));
}
}

void testtriangles() {
  tft.fillScreen(BLACK);
  for (uint16_t i=0; i<tft.width()/2; i+=5) {
    tft.drawTriangle(tft.width()/2, tft.height()/2-i,
                     tft.width()/2-i, tft.height()/2+i,
                     tft.width()/2+i, tft.height()/2+i, tft.Color565(0, 0, i));
  }
}

void testfilltriangles() {
  tft.fillScreen(BLACK);
 
  for (uint16_t i=tft.width()/2; i>10; i-=5) {
    tft.fillTriangle(tft.width()/2, tft.height()/2-i,
                     tft.width()/2-i, tft.height()/2+i,
                     tft.width()/2+i, tft.height()/2+i,
                     tft.Color565(0, i, i));
    tft.drawTriangle(tft.width()/2, tft.height()/2-i,
                     tft.width()/2-i, tft.height()/2+i,
                     tft.width()/2+i, tft.height()/2+i, tft.Color565(i, i, 0));   
  }
}
void testtext(uint16_t color) {
  tft.fillScreen(BLACK);
  tft.setCursor(0, 20);
  tft.setTextColor(color);
  tft.setTextSize(3);
  tft.println("Hello aitendo!");
  // tft.setTextSize(3);
  //tft.println(1234.56);
  //tft.setTextSize(3);
  //tft.println(0xDEADBEEF, HEX);
}

void testfillcircles(uint8_t radius, uint16_t color) {
  for (uint16_t x=radius; x < tft.width(); x+=radius*2) {
    for (uint16_t y=radius; y < tft.height(); y+=radius*2) {
      tft.fillCircle(x, y, radius, color);
    }
  } 
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (uint16_t x=0; x < tft.width()+radius; x+=radius*2) {
    for (uint16_t y=0; y < tft.height()+radius; y+=radius*2) {
      tft.drawCircle(x, y, radius, color);
    }
  } 
}


void testfillrects(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t x=tft.width()-1; x > 6; x-=6) {
   //Serial.println(x, DEC);
   tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
   tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
}
}

void testdrawrects(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width(); x+=6) {
   tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
}
}

void testfastlines(uint16_t color1, uint16_t color2) {
   tft.fillScreen(BLACK);
   for (uint16_t y=0; y < tft.height(); y+=5) {
     tft.drawHorizontalLine(0, y, tft.width(), color1);
   }
   for (uint16_t x=0; x < tft.width(); x+=5) {
     tft.drawVerticalLine(x, 0, tft.height(), color2);
   }
 
}

void testlines(uint16_t color) {
   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width(); x+=6) {
     tft.drawLine(0, 0, x, tft.height()-1, color);
   }
   for (uint16_t y=0; y < tft.height(); y+=6) {
     tft.drawLine(0, 0, tft.width()-1, y, color);
   }
   
   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width(); x+=6) {
     tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
   }
   for (uint16_t y=0; y < tft.height(); y+=6) {
     tft.drawLine(tft.width()-1, 0, 0, y, color);
   }
   
   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width(); x+=6) {
     tft.drawLine(0, tft.height()-1, x, 0, color);
   }
   for (uint16_t y=0; y < tft.height(); y+=6) {
     tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
   }

   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width(); x+=6) {
     tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
   }
   for (uint16_t y=0; y < tft.height(); y+=6) {
     tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
   }
}


void testBars() {
  uint16_t i,j;
  for(i=0; i < tft.height(); i++)
  {
    for(j=0; j < tft.width(); j++)
    {
      if(i>279) tft.writeData(WHITE);
      else if(i>239) tft.writeData(BLUE);
      else if(i>199) tft.writeData(GREEN);
      else if(i>159) tft.writeData(CYAN);
      else if(i>119) tft.writeData(RED);
      else if(i>79) tft.writeData(MAGENTA);
      else if(i>39) tft.writeData(YELLOW);
      else tft.writeData(BLACK);
    }
  }
}

----------------------------------
Message
xin tu
Thu Mar 06 22:13:18 PST 2014
Friend:

I'm sorry for it.

The library is support by the factory.
If you think library is no effect for you.
You can find information of screen in Google website.
The ship is 7781.

Thank you for your understanding.
Best regards.
Lynn
----------------------------
Speed speed support only 4 day :)

This is chip 7781 :) - jock

Code: [Select]

 // find the TFT display
 uint16_t identifier = tft.readRegister(0x0);
 if (identifier == 0x9325) {
   Serial.println("Found ILI9325");
 } else if (identifier == 0x9328) {
   Serial.println("Found ILI9328");
 } else {
   Serial.print("Unknown driver chip ");//<-have answer
   Serial.println(identifier, HEX);
   while (1);
 }

have answer
Unknown driver chip 7783

art100

Quest?
Search sequence library in compiller arduino?
#include....h..


Compiller undestand path?
#include c:/workarduino/test20140307094200/tftlcdhina7783.h
#include c:/workarduino/test20140307094200/touchscreenchina7783.h

art100

http://yadi.sk/d/cWpeNS53K8S67
http://downloads.arduino.cc/arduino-1.5.6-r2-windows.exe
example:
C:\Arduino\libraries\TFTLCD\examples\tft_paint\tft_paint.pde
05.10.2013  14:46             3 615 tft_paint.pde
Code: [Select]

#include "TFTLCD.h"
#include "TouchScreen.h"


#define YP A2  
#define XM A1
#define YM 6
#define XP 7  


#define TS_MINX 120
#define TS_MINY 120
#define TS_MAXX 930
#define TS_MAXY 950

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 400);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF



TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
 Serial.begin(9600);
 Serial.println("Paint!");
 
 tft.reset();

 tft.initDisplay();
 tft.fillScreen(BLACK);
 
 tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
 tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
 tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
 tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
 tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE);
 tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
// tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);

tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
currentcolor = RED;

 pinMode(13, OUTPUT);

}


#define MINPRESSURE 10
#define MAXPRESSURE 1000




void loop()
{
 digitalWrite(13, HIGH);
 Point p = ts.getPoint();
 digitalWrite(13, LOW);

 pinMode(XM, OUTPUT);
 pinMode(YP, OUTPUT);

 if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
/*
    Serial.print(p.y);
    Serial.print(" , ");
 Serial.println(p.x);
   delay(1);
 */  
   if (p.x < (TS_MINY-5)) {
     Serial.println("erase");
    // press the bottom of the screen to erase
     tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
     
   }
   // turn from 0->1023 to tft.width
   p.y = map(p.y, TS_MINX, TS_MAXX, tft.width(), 0);
   p.x = map(p.x, TS_MINY, TS_MAXY, tft.height(), 0);

   if (p.x < BOXSIZE) {
      oldcolor = currentcolor;

 
      if (p.y < BOXSIZE) {
        currentcolor = RED;
        tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.y < BOXSIZE*2) {
        currentcolor = YELLOW;
        tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.y < BOXSIZE*3) {
        currentcolor = GREEN;
        tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.y < BOXSIZE*4) {
        currentcolor = CYAN;
        tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.y < BOXSIZE*5) {
        currentcolor = BLUE;
        tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE);
      }
      else if (p.y < BOXSIZE*6) {
        currentcolor = MAGENTA;
        tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
      }
     
      if (oldcolor != currentcolor) {
         if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
         if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
         if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
         if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
         if (oldcolor == BLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE);
         if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
      }
   }
   if (((p.x-PENRADIUS) > BOXSIZE) && ((p.x+PENRADIUS) < tft.height())) {
     tft.fillCircle(p.y, p.x, PENRADIUS, currentcolor);
   }
 }
}

Code: [Select]

...
#define YP A2  
#define XM A1
#define YM 6
#define XP 7  
...
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
...


Quest:
input and output on 1 pin?
#define LCD_CD A2 // output
#define LCD_WR A1// output
#define YP A2 //intput
#define XM A1 // input
This is work code?

art100

Now result:
1. SD card - bed.
2. touch - bed.
3.LCD 320x240 - work - example in old compiller up. TFTLCD-7781...

only 1 example to work
C:\arduino-2.6-7781-after12.22\libraries\TFTLCD778X\examples\graphicstest\graphicstest.pde

#define LCD_CS A3    
#define LCD_CD A2    
#define LCD_WR A1  
#define LCD_RD A0    
...
work pin and D0...7
...
bed
:smiley-sleep:

Forum was very helpful thank you for the informative discussion.
Strangeness in the distribution of input output directly in compilers such.
Im sorry on my english, china, italian language.

art100

.
This is no jock.
This is fact. :(

art100

Pins in out this really now all to work?

Poll resistors screen
and
immediately output to the screen simultaneously,
it is now so fashionable?

i to write code to work
Code: [Select]

//20140208 art100  tft2.4" st7783 shield on arduino uno
// art100 write message
//#include "st7783SD.h" // pins SD_SS-10 SD_DI-11(in) SD_DO-12(out) SD_SCK-13 no work
//#include "st7783TFT.h" //has not written
//#include "st7783TouchScreen.h" //has not written
#include "TFTLCD.h" // work
#include "TouchScreen.h" // bad but it works
//TouchScreen define
#define YP A1 //tftloop-YU pcbundertft-13 arduinoshieldLCD_WR!!! arduinouno-A1
#define XM A2 //tftloop-XR pcbundertft-14 arduinoshieldLCD_RS!!! arduinouno-A2
#define YM 7  //tftloop-XR pcbundertft-15 arduinoshieldLCD_D7 arduinouno-7
#define XP 6  //tftloop-XR pcbundertft-12 arduinoshieldLCD_D6 arduinouno-6
#define TS_MINX 150//0
#define TS_MINY 120//0
#define TS_MAXX 920//900//320      //for calibrate analog resistans ~1500om/700om
#define TS_MAXY 940//800//900//240 //for calibrate analog resistans ~1500om/700om
// For better pressure precision, we need to know the resistance// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
//TFT  define
#define LCD_RESET A4//
#define LCD_CS A3
#define LCD_CD A2 //cmosbuffer-arduinoshieldLCD_RS!!! arduinouno-A2 this is jock :-?
#define LCD_WR A1 //cmosbuffer-arduinoshieldLCD_WR!!! arduinouno-A1 this is jock :-?
#define LCD_RD A0
// Color definitions
#define WHITE           0xFFFF
#define BLACK           0x0000
#define RED             0xF800
#define BLUE            0x001F
#define GREEN           0x07E0
#define YELLOW          0xFFE0
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
//SD define //has not written
#define bordur   5
#define pen      3
//---------------------------------------
void setup(void) {
  Serial.begin(9600);
  Serial.println("Paint");
  tft.reset();
  uint16_t identifier = tft.readRegister(0x0);
  tft.initDisplay();
  tft.fillScreen(RED);
}
#define MINPRESSURE 10    // analog calibrate
#define MAXPRESSURE 1000  // analog calibrate
//=======================================
void loop(){
  Point p = ts.getPoint(); // get analog point
  pinMode(XM, OUTPUT); //2 chip on one pins
  pinMode(YP, OUTPUT); //2 chip on one pins
  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { // analog calibrate
    p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width ()); // aprocsimate variable
    p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height()); // aprocsimate variable
   
//    if (300< p.x) { // erase only on bordur  //no need have reset button
//      Serial.println("erase"); // test
//      tft.fillRect(0, 0, tft.width(), tft.height(), RED);// BLACK); //fill black
//    }
   
    // test
    Serial.print("getPoint x=");Serial.print(p.x);Serial.print(" y=");Serial.print(p.y);Serial.print(" PRESSURE=");Serial.print(p.z); 
   
    // paint
    if (((p.x)<tft.width()) && ((p.y)<tft.height())) { tft.fillRect(p.x,p.y,pen,pen,GREEN); }
  }
}


Need critique of the code?

http://yadi.sk/d/EPYljwnIKAWUT

art100

jock 2
  tft.fillScreen(BLACK); very slow  =(
Code: [Select]

// art100 write message
//TOUCH PCB ARDUINO UNO
//YU 13 A1
//XL 12 6
//YD 15 7
//XR 14 A2     
//TFT   
//A
//K1
//K2
//K3
//K4
#include "TFTLCD.h"
//pins
#define LCD_RESET A4
#define LCD_CS A3   
#define LCD_CD A2   
#define LCD_WR A1   
#define LCD_RD A0   
// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
const int analogInPin = A5;  // Analog input pin that the potentiometer is attached to
//const int analogInPin = A4; // :(
//const int analogInPin = A3;// :(
//const int analogInPin = A2;// :(
//const int analogInPin = A1;// :(
//const int analogInPin = A0;// :(
//const int analogInPin = A-1;// ;)
//const int analogInPin = A-2;// ;)
//const int analogInPin = A-3;// ;)
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
//-----------------------
void setup(void) {
  Serial.begin(9600);
  Serial.println("8 Bit LCD test! more pinssssss");
  tft.reset();
  tft.initDisplay();
  tft.fillScreen(BLACK); // very slooooooow
//  testtext(YELLOW);
}
//===================
void loop(void) {
//    tft.initDisplay();
    tft.fillScreen(BLACK); // very slooooooow
   
    // read the analog in value:
  sensorValue = analogRead(analogInPin);           
  // map it to the range of the analog out:
//  outputValue = map(sensorValue, 0, 1023, 0, 255);
  outputValue = map(sensorValue, 0, 1023, 0, 240);//lcd 320x240
  // print the results to the serial monitor:
  Serial.print("sensor = " );  Serial.print(sensorValue);  Serial.print("\t output = ");  Serial.println(outputValue); 
 
for (uint16_t y=0; y<tft.height(); y+=10) {
  if(180<outputValue) {tft.drawHorizontalLine(  0, y, outputValue,   RED);}
  else{                tft.drawHorizontalLine(  0, y, outputValue, GREEN);}
}


Serial.println("tft.drawHorizontalLine(125, y, pin analog A5 only , GREEN);");
delay(1000); 
//delay(1);

}



http://yadi.sk/d/dHTPynHxL35v6
http://yadi.sk/d/xjjgeolAL35wT

casemod

CircuitGuru
http://www.circuitguru.co.uk/

marcoseduardo

I have the same problem with the same board.

I had bought this TFT 2.4 LCD Touch Shield for over a year, but only now I could test it. I can only see a white screen (backlight).
My Arduino is a Duemilanove.

Can you help me?
I just dont know where to start to make it work.





casemod

Use the libraries for the ST7781R controller.
Adafruit has a 2.8" TFT with the same controller. You can use those.

Just dont use the version above. Aprarently the poster hasnt gone anywhere and they dont work with the current version of the IDE.
CircuitGuru
http://www.circuitguru.co.uk/

marcoseduardo

Thank you for the tip.
I will try again with that and then return here to tell what happend.

Regards
Marcos

ThomasDG

I also bought this shield and after searching the web found this page with a working library and demos:
http://www.smokeandwires.co.nz/blog/a-2-4-tft-touchscreen-shield-for-arduino/

Hope this might help some of you...

berni_

Hi, I'm newbie with displays, and after more or less difficulties, I could make the things runing,
I share some observations:
On arduino UNO, after mapping correctly the pins according to display design, it is working quite well with a library called TFTLCD, found in this forum: http://misc.ws/2013/11/08/touch-screen-shield-for-arduino-uno/
Connected to  Arduino MEGA, is is more complicated, the TFT pins D0 to D7 must be connected to pins 22 to 29, the other pins are unchanged (MEGA has strange port arrangement connected to digital pins 0 to 13, therefore the library is not able to use the shield directly connected to MEGA). I have made the tes and it is working well also.
The touchscreen share the same pins as TFT, therefore it can be used only when LCD_CS is high (LCD outputs are high impedance). To run the touchscreen alone, on UNO, this is added in setup():
  pinMode(A3, OUTPUT);
  digitalWrite(A3, HIGH);
The SD card is also working well... BUT there is a problem: the voltage given to the SD is 4.3V, and the absolute maximum voltage allowed for SD is 3.6V... DANGER to burn the SD card. This is caused by the HC245 buffer, which is not a level shifter, it has internal diodes between I/O and VCC and it push up the VCC3.3V by taking current on the arduino I/O. When Arduino is connected to USB (USB voltage on my computer=4.6V), the SD is powered at 3.9V; but with the jack, the SD has 4.3V.
I am not sure how to solve that... adding level shfters somewhere... The most safe is not using the SD slot at all.

About the libraries for TFT:
The author Mike McCaule, explained he has used the Adafruit TFT library, and modified several elements: capability to mirror X and Y, update the pins for UNO and MEGA, and use a faster method for rotation.
Anyway, it is very slow. This display is able to show moovies at 60fps, but filling it with plain color, it takes ~0.3 second on Arduino.
320x240=76800 pixels with 16MHz processor, that means ~70 CPU clock per pixel, it seems not very optimized...

Also the tested library has poor text function (the text background is always transparent, making problems to overwrite an existing text; font management does not exist, writing bigger than 8point font is managed by zoom 2, 3, 4, ... times the 8point font, the result is slow and ugly).
The display has some hardware accelerator (scrolling functions, layers management,...), but this is not used with the library; except rotation.

Does someone here has made comparaison between the available libraries?


Go Up