Pages: [1]   Go Down
Author Topic: 2.8 TFT Touch Shield: Nothing Displayed  (Read 3112 times)
0 Members and 1 Guest are viewing this topic.
Philippines
Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to use the Seeed Studio 2.8" TFT Touch Shield v1.0. I downloaded the library provided at: http://www.seeedstudio.com/wiki/File:TFT_Touch_Shield_libraries.zip . The example code wouldn't upload as is, I would get the error: "Tft was not declared in this scope." I've tried all of the example codes, but here's one of them:
Code:
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#ifdef SEEEDUINO
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 14   // can be a digital pin, this is A0
  #define XP 17   // can be a digital pin, this is A3
#endif

#ifdef MEGA
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 54   // can be a digital pin, this is A0
  #define XP 57   // can be a digital pin, this is A3
#endif

//Measured ADC values for (0,0) and (210-1,320-1)
//TS_MINX corresponds to ADC value when X = 0
//TS_MINY corresponds to ADC value when Y = 0
//TS_MAXX corresponds to ADC value when X = 240 -1
//TS_MAXY corresponds to ADC value when Y = 320 -1

#define TS_MINX 140
#define TS_MAXX 900

#define TS_MINY 120
#define TS_MAXY 940


// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// The 2.8" TFT Touch shield has 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  // a point object holds x y and z coordinates
  Point p = ts.getPoint();

  if (p.z > ts.pressureThreshhold) {
     Serial.print("Raw X = "); Serial.print(p.x);
     Serial.print("\tRaw Y = "); Serial.print(p.y);
     Serial.print("\tPressure = "); Serial.println(p.z);
  }
 
 
  p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
  p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);
 
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!
  if (p.z > ts.pressureThreshhold) {
     Serial.print("X = "); Serial.print(p.x);
     Serial.print("\tY = "); Serial.print(p.y);
     Serial.print("\tPressure = "); Serial.println(p.z);
  }

  delay(100);
}
To get the example to upload, I had to move the contents within the library folder. The library is called "TFT_Touch_Shield_libraries" and when you open it, two sub folders are shown: "TFT" and "TouchScreen." I kept the contents within the sub folders, but got rid of the separate sub folders themselves. So when I open up "TFT_Touch_Shield_libraries" everything that was within the two sub folders is shown in the window. Now the program uploads without an error.
But here's my problem, I do not see the program being displayed on the TFT shield. Instead the screen only powers up. The bottom of the screen is white, and fades into a tan color at the top of the display:



I was hoping someone might know why the TFT shield is not displaying the animations from any of the example codes. In the example code provided above, you can use the Serial Monitor to print the coordinates of where you are touching the screen as well as the amount of pressure your finger is applying. I am getting those numbers on the Serial Monitor (though the coordinates are always the same, wherever I push), so the program must be working, it's just not being displayed.
In the picture I'm using a Seeeduino Mega 2560, but I've also had the same results on a Seeeduino v3.0 and an Arduino Uno. Thanks.
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 66
Posts: 2484
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Forget the SeedStudio stuff. I spent hours messing about with different version/setting and in the end downloaded libraries from here and they worked first time.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Pennsylvania
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Artie,

There is no code (in touchscreendemo) to display the coordinates where you touch the screen, on the screen.  The coordinates are only sent to the serial monitor.

If the coordinates are the same value wherever you touch, the screen is defective, as it appears to be by the color of your screen.

Did you try the text example?  That should display text on the screen, and if it doesn't, that would also indicate the screen is defective.

Regards
-__-

Logged

Software's good, software's impressive, but it's hardware that does the work.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you first open the demo sketch that comes with the library it has actually has 2 sketches. goto the second tab select all and delete or make a new sketch and copy all the demo sketch to it
YOU MUST INCLUDE SPI and have the ADAFRUIT ST7735 library installed if it didnt come with the Seeed TFT library (In sub folder UTILITY)
You must also open the config file and replace "def SEEEDUINO"(line 7 in the TFT.h file)with def MEGA if using a MEGA. You do not need to do this for the UNO!!!!!!!!!!!!!!!!!!!!!!!!!

This is what I have come up with to make mine werk.
Code:
// THIS SKETCH IS FOR THE MEGA
//Binary sketch size: 20,914 bytes (of a 258,048 byte maximum)

#include <SPI.h>// MUST INCLUDE THIS for the TFT because the adafruit_ST7735 library uses it, (Seeed hijacked it to make their TFT werk and it compiles with very thing else so watch your memory)
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

#define YP A2   // must be an analog pin, use "An" notation!
#define XM A1   // must be an analog pin, use "An" notation!
#define YM 54   // can be a digital pin, this is A0
#define XP 57   // can be a digital pin, this is A3 #define GPSECHO  false
#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940
#define GPSECHO  false
#define displayTemp
#define gpsHOUR  GPS.hour - 4//neg 4 for the eastern U.S.
Adafruit_BMP085 bmp;
Adafruit_GPS GPS(&Serial1);
int highT = 0.0 ; // Top temp
long runningT;
int SampleT;
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
char Temp [32];//BMP
char Baro [32];//BMP
char Alti [32];//BMP
char Hour [32];//TIME
char Min [32];//TIME
char Sec [32];//TIME
char Lat [32];//GPS
char Lon [32];//GPS

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); //init TouchScreen port pins
void setup()
{
  Serial.begin(115200); // com19 on CPU
  bmp.begin();
  Tft.init();  //init TFT library
  pinMode(0,OUTPUT);
  
  Serial.println("Adafruit GPS library basic test!");
  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
  useInterrupt(true);
  delay(1000);
  // Ask for firmware version
  Serial1.println(PMTK_Q_RELEASE);
  Tft.fillRectangle(100,200,30,30,GREEN);
}


  //Tft.setDisplayDirect(DOWN2UP);

uint32_t timer = millis();
void loop(){
  
  // a point object holds x y and z coordinates.
  Point p = ts.getPoint();

  //map the ADC value read to into pixel co-ordinates

  p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
  p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);
  
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > ts.pressureThreshhold) {
  
 
 // Detect  paint brush color change
 if(p.y < 200)
  {
    if(p.x >= 99 && p.x < 120)
        {
      (GPS.LOCUS_StartLogger());
      Tft.drawString  ("Logging",0,140,2.5,GREEN );
    }
  }
 }
  
  
  
  if (! usingInterrupt) {
    char c = GPS.read();
    if (GPSECHO)
      if (c) UDR0 = c;
  }
  if (GPS.newNMEAreceived()) {
  if (!GPS.parse(GPS.lastNMEA()))  
      return;
  }
  if (timer > millis())  timer = millis();

  // approximately every 2 seconds or so, print out the current stats
  if (millis() - timer > 100) {
    timer = millis(); // reset the timer
    float x = (GPS.latitude);
    int x1=(x-(int)x)*10000;//kick it to the "k" to get all the digits 100 only gives 2 digits after the decimal
    sprintf(Lat, "%0d.%d",(int)x,x1);
    //Baro
    float y = (GPS.longitude);
    int y1=(y-(int)y)*10000;//kick it to the "k" to get all the digits 100 only gives 2 digits after the decimal
    sprintf(Lon, "%0d.%d",(int)y,y1);
    //BMP085 Alt
    //adjust for pressure at sea level and convert from meters to feet."
    float a = (bmp.readAltitude(102500)/3.3);
    int a1=(a-(int)a)*100;//only need Hundredths to get all the digits
    sprintf(Alti, "%0d.%d",(int)a,a1);
    //Baro
    float b = (bmp.readPressure()* 0.0002953);
    int b1=(b-(int)b)*100;//only need Hundredths to get all the digits
    sprintf(Baro, "%0d.%d",(int)b,b1);
    //Temp
    float t = bmp.readTemperature();
    int t1=(t-(int)t)*100;//only need Hundredths to get all the digits
    sprintf(Temp, "%0d.%d",(int)t,t1);
  
/*
if you want to display TIME
    float h = (gpsHOUR);
    int h1=(h-(int)h)*100;
    sprintf(Hour, "%0d",(int)h,h1);//Dont need All the other numbers after the Hour so kill the ".%d".

    float m = ((GPS.minute), DEC);
    int m1=(m-(int)m)*100;
    sprintf(Min, "%0d",(int)m,m1);//Dont need All the other numbers after the Mnutes so kill the ".%d".

    float s = ((GPS.seconds), DEC);
    int s1=(t-(int)s)*100;
    sprintf(Sec, "%0d",(int)s,s1);//Dont need All the other numbers after the Seconds so kill the ".%d".
    */
    
    // =================================for sideways display=================================
    //Tft.fillRectangle (100,160,30,30,RED);//Test
    //Tft.fillRectangle (0,0,50,320,YELLOW);//temp box
    //Tft.fillRectangle (51,51,50,320,BLUE);//Baro box
    //Tft.setDisplayDirect(DOWN2UP);// USB plug to the left
    // =================================for sideways display=================================
    //----------------------Display function------------------------------------
  //BMP085 Temp display
    Tft.drawString   ("Temp: ",0,10,2.5,BLUE);
    //Change the color of the Temp reading when it gets Above or Below a set point
    if (t > 80.00){
      Tft.drawString  ( Temp,100,10,2.5,RED);
    }
    if (t < 80.00){
      Tft.drawString  ( Temp,100,10,2.5,GREEN );
    }
    Tft.drawString     ("*F",200,10,2.5,GREEN );
    //Baro display  
    Tft.drawString    ("Baro:",0,30,2.5,GREEN );
    Tft.drawString    ( Baro,100,30,2.5,GREEN );
    Tft.drawString     ("Hg",200,30,2.5,GREEN );
    //Alt display
    Tft.drawString    ("Alt :",0,50,2.5,GREEN );
    Tft.drawString     (Alti,100,50,2.5,GREEN );
    Tft.drawString     ("Ft",200,50,2.5,GREEN );
    //delay(5000);

    Tft.drawString     ("N:",0,90,2.5,GREEN );
    Tft.drawString     (Lat,55,90,2.5,GREEN );
    Tft.drawString  ("W:",0,110,2.5,GREEN );
    Tft.drawString    (Lon,55,110,2.5,GREEN );
    delay(100);
    //----------------------Clear function----------------------------------
    //delay(Clear);//(Clear the readings only) set prior to void setup().
//====================TEST=========================
//Put test clear code here
//====================TEST=========================
    Tft.drawString     (Baro,100,30,2.5,BLACK);
    Tft.drawString     (Alti,100,50,2.5,BLACK);
    Tft.drawString   (Lat,55,90,2.5,BLACK);
    Tft.drawString  (Lon,55,110,2.5,BLACK);
    //----------------------Clear function----------------------------------
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *F");
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure()* 0.0002953);
    Serial.println(" Hg");
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude(102500)/3.3);
    Serial.println(" feet");
    Serial.println();
    Serial.print("12 Hour, EST: ");
    if(gpsHOUR > 12){  
      //Serial.print("0");
      Serial.print("0");
      Serial.print((gpsHOUR > 12) ? gpsHOUR - 12 :((gpsHOUR == 0) ? 12 : gpsHOUR ), DEC  ); // Once the clock reaches 12:00 Hrs
      // I take away 12 Hrs from the 24 hour clock and print it out
    }
    else{
      Serial.print(gpsHOUR , DEC ); // Conversion to AM/PM
    }

    Serial.print(':');
    if((GPS.minute) < 10){  // Zero padding if value less than 10 ie."09" instead of "9"
      Serial.print("0"); // keeps the numbers in one place when less than 10
      Serial.print((GPS.minute), DEC);
    }
    else{
      Serial.print((GPS.minute), DEC);
    }
    Serial.print(':');
    if((GPS.seconds) < 10){  // Zero padding if value less than 10 ie."09" instead of "9"
      Serial.print("0");// keeps the numbers in one place when less than 10
      Serial.print((GPS.seconds), DEC);
    }
    else{
      Serial.print((GPS.seconds), DEC);
    }
    if(gpsHOUR < 12){   // Adding the AM/PM sufffix
      Serial.println(" AM");
    }
    else{
      Serial.println(" PM");
    }
    Serial.println();
    Serial.print(Lat);
    Serial.print(GPS.lat);
    Serial.print(", ");
    Serial.print(Lon);
    Serial.println(GPS.lon);
  }
}


// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
  // if you want to debug, this is a good time to do it!
  if (GPSECHO)
    if (c) UDR0 = c;  
    // writing direct to UDR0 is much much faster than Serial.print
    // but only one character can be written at a time.
}
void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  }
  else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }

}

  




Logged

Pennsylvania
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

fmbfla,

Why would the SPI library be required to make the OP's unit work?  The V1 LCD, which the OP has, doesn't use SPI; the V2 LCD does.
-__-
Logged

Software's good, software's impressive, but it's hardware that does the work.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry i lost this.
The goofy reason is that SEED is using the TFT library from Adafruit which calls for the SPI for use with it's TFT hardware ST7735.
I know it sounds cumbersome and a waste of memory but thats what we get when we buy sub-standard hardware.

Error=
Code:
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:59: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(uint8_t*)':
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:272: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:276: error: 'SPI_CLOCK_DIV4' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:279: error: 'SPI_MODE0' was not declared in this scope
Logged

Pennsylvania
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry i lost this.
The goofy reason is that SEED is using the TFT library from Adafruit which calls for the SPI for use with it's TFT hardware ST7735.
I know it sounds cumbersome and a waste of memory but thats what we get when we buy sub-standard hardware.

Error=
Code:
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:59: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(uint8_t*)':
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:272: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:276: error: 'SPI_CLOCK_DIV4' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:279: error: 'SPI_MODE0' was not declared in this scope

The files the OP downloaded do not have the SPI references you quote. Did you get your files from Adafruit directly?  Also, the device in the Seeed V1 LCD is an ST7781, not an ST7735.  Seeed's V1 library works fine as it is (or as it was when I d/l'ed it).

However, for your situation, I agree you had to include the SPI specifics since you are using a different library.


I do wish that Artie (original poster) had replied as to whether or not he got the display working, though I still think it was a defective LCD based on the color description of the screen.

Regards,
-__-
Logged

Software's good, software's impressive, but it's hardware that does the work.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For anyone still having this issue with the version 1 shield (red board, no SD card).  Got this working on Arduino UNO today.  On the Wiki for this device:

http://www.seeedstudio.com/wiki/2.8%27%27_TFT_Touch_Shield_V1.0

There is a link at the bottom (the first link in a list of many) that leads to a library (https://github.com/Seeed-Studio/TFT_Touch_Shield_V1) that works.

One minor issue, sketches that refer to a class 'Point' and generate an error.  Replace 'Point' with 'TSPoint'.

All examples are working, when previously we had numerous compile errors and a white screen.  Also, you must calibrate the touch screen using the touchscreendemo example to find the raw values of xmin, xmax, ymin, and ymax.

I'm glad this actually works as this is an affordable screen.
Logged

Pages: [1]   Go Up
Jump to: