Go Down

Topic: Library error when trying to connect official Arduino TFT on Arduino Mega (Read 243 times) previous topic - next topic

Gloup

Hello,

I'm trying since few hours to connect my official TFT screen on my Arduino Mega 2650 following this page : http://arduino.cc/en/Guide/TFTtoBoards
So I have these pins:
  • MISO : 50
  • SCK : 52
  • MOSI : 51
  • LCD CS : 10
  • SD CS : 4
  • DC : 9
  • RESET : 8


I tried this programm available on the Arduino web site of the library (this is the library of the IDE) :
Code: [Select]
#include <TFT.h> // Hardware-specific library
#include <SPI.h>

#define CS   10
#define DC   9
#define RESET  8 

// pin definition for the Leonardo
// #define CS   7
// #define DC   0
// #define RESET  1

TFT myScreen = TFT(CS, DC, RESET);

// initial position of the point is the middle of the screen
// initial position of the point is the middle of the screen
int xPos = 80;
int yPos = 64;

// direction and speed
int xDir = 1;
int yDir = 1;

// variables to keep track of the point's location
int xPrev = xPos;
int yPrev = yPos;

void setup(){
  myScreen.begin(); 
  myScreen.background(0,0,0); // clear the screen
}

void loop(){
  // update the location of the dot
  xPos = xPos + xDir;
  yPos = yPos + yDir;

  // check if the current location is different than the previous
  if(xPos != xPrev || yPos != yPrev){
    myScreen.stroke(0,0,0); // set the stroke color to black
    myScreen.point(xPrev, yPrev); // color in the previous point
  }

  // draw a point in the current location
  myScreen.stroke(255,255,255);
  myScreen.point(xPos, yPos);

  // if the x or x position is at the screen edges, reverse direction
  if(xPos >= 160 || xPos <= 0){
    xDir = xDir*-1;
  }
  if(yPos >= 128 || yPos <= 0){
    yDir = yDir*-1;
  }

  // update the point's previous location
  xPrev=xPos;
  yPrev=yPos;

  // a 33ms delay means the screen updates 30 times a second
  delay(33);

}


No success, I have some black strip and grey strip... So after reading the library, I saw that for Mega, we have to define other pin. So I add some define and replace the initialization :

Code: [Select]
#define SCLK 2
#define MOSI 51

//New initialization :
TFT myScreen = TFT(CS, DC, MOSI, SCLK, RESET);


But this is not working and I have this error : error: no matching function for call to 'TFT::TFT(int, int, int, int, int)'


I really don't understand, maybe the documentation is out of date, ... So I home someone know this problem and can help me ! Thanks in advance.
Blog électro/DIY : http://www.worldofgz.com

Go Up