Touch-Display für UNO und Mega geht nur am UNO_warum?

Hallo Zusammen
Ich habe mir kleine 2,8" Touch-Displays besorgt und bin am
Testen damit.
Ich habe sowohl UNOs als auch MEGAs.
Das Calibration-Test-Programm startet und läuft auf den UNOs einwandfrei, auf den MEGAs aber nicht.
Es bleibt hell erleuchtet und schaltet nicht in den Text-Mode um!
Das Display soll aber definitiv direkt auf beiden Boards laufen.
Es wird direkt auf die Arduinos gesteckt und da kann ich ja auch nichts falsch machen.

Was mach ich falsch?
Muss ich da noch was umstellen am Programm oder wie?

anbei das Programm:


/***********************************************************************************
*This program can be used to calibrate the touchscreen of the display modules.
*Instructions will be given on the display.

*This demo was made for LCD modules with 8bit or 16bit data port.
*This program requires the the LCDKIWI library.

* File                : TouchScreen_Calibr.ino
* Hardware Environment: Arduino UNO&Mega2560
* Build Environment   : Arduino

*Set the pins to the correct ones for your development shield or breakout board.
*This demo use the BREAKOUT BOARD only and use these 8bit data lines to the LCD,
*pin usage as follow:
*                  LCD_CS  LCD_CD  LCD_WR  LCD_RD  LCD_RST  SD_SS  SD_DI  SD_DO  SD_SCK 
*     Arduino Uno    A3      A2      A1      A0      A4      10     11     12      13                            
*Arduino Mega2560    A3      A2      A1      A0      A4      10     11     12      13                           

*                  LCD_D0  LCD_D1  LCD_D2  LCD_D3  LCD_D4  LCD_D5  LCD_D6  LCD_D7  
*     Arduino Uno    8       9       2       3       4       5       6       7
*Arduino Mega2560    8       9       2       3       4       5       6       7 

*Remember to set the pins to suit your display module!
*
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
**********************************************************************************/
#include <TouchScreen.h> //touch library
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_KBV.h> //Hardware-specific library

#define TOUCH_ORIENTATION  0
#define TITLE "TouchScreen.h Calibration"

//if the IC model is known or the modules is unreadable,you can use this constructed function
///LCDWIKI_KBV my_lcd(NV3029C,A3,A2,A1,A0,A4); //model,cs,cd,wr,rd,reset
//if the IC model is not known and the modules is readable,you can use this constructed function
LCDWIKI_KBV my_lcd(240,320,A3,A2,A1,A0,A4);//width,height,cs,cd,wr,rd,reset

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

#define YP A3  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 9   // can be a digital pin
#define XP 8   // can be a digital pin

TouchScreen mytouch(XP, YP, XM, YM, 300);
TSPoint tp;                      //Touchscreen_due branch uses Point

void show_string(uint8_t *str,int16_t x,int16_t y,uint8_t csize,uint16_t fc, uint16_t bc,boolean mode)
{
    my_lcd.Set_Text_Mode(mode);
    my_lcd.Set_Text_Size(csize);
    my_lcd.Set_Text_colour(fc);
    my_lcd.Set_Text_Back_colour(bc);
    my_lcd.Print_String(str,x,y);
}

void Read_Resistive(void)
{
    tp = mytouch.getPoint();
    pinMode(YP, OUTPUT);      //restore shared pins
    pinMode(XM, OUTPUT);
    digitalWrite(YP, HIGH);   //because TFT control pins
    digitalWrite(XM, HIGH);
}

bool is_pressed(void)
{
    bool state;
    Read_Resistive();
    state = (tp.z > 20 && tp.z < 1000);
    return state;
}

void showpoint(void)
{
    Serial.print("\r\nx="); Serial.print(tp.x);
    Serial.print(" y="); Serial.print(tp.y);
    Serial.print(" z="); Serial.print(tp.z);
}

uint32_t cx, cy;
uint32_t rx[8], ry[8];
int32_t clx, crx, cty, cby;
float px, py;
int dispx, dispy, text_y_center, swapxy;
uint32_t calx, caly, cals;
char buf[13];

void setup()
{
    Serial.begin(9600);
    Serial.println(TITLE);
    digitalWrite(A0, HIGH);
    pinMode(A0, OUTPUT);
    my_lcd.Init_LCD();
    my_lcd.Set_Rotation(TOUCH_ORIENTATION);
    my_lcd.Fill_Screen(BLACK);
    dispx = my_lcd.Get_Display_Width();
    dispy = my_lcd.Get_Display_Height();
    text_y_center = (dispy / 2) - 6;
}

void drawCrossHair(int x, int y, unsigned int color)
{
    my_lcd.Set_Draw_color(color);
    my_lcd.Draw_Rectangle(x - 10, y - 10, x + 10, y + 10);
    my_lcd.Draw_Fast_VLine(x, y-5, 11);
    my_lcd.Draw_Fast_HLine(x-5, y, 11);
}

void readCoordinates()
{
    int iter = 5000;
    int failcount = 0;
    int cnt = 0;
    uint32_t tx = 0;
    uint32_t ty = 0;
    boolean OK = false;

    while (OK == false)
    {
        my_lcd.Set_Draw_color(0);
        my_lcd.Fill_Rectangle(my_lcd.Get_Display_Width()/2-33, text_y_center, my_lcd.Get_Display_Width()/2+33, text_y_center+8);
        show_string("*  PRESS  *",CENTER,text_y_center,1,GREEN, BLACK,1);
        while (is_pressed() == false) {}
        my_lcd.Set_Draw_color(0);
        my_lcd.Fill_Rectangle(my_lcd.Get_Display_Width()/2-33, text_y_center, my_lcd.Get_Display_Width()/2+33, text_y_center+8);
        show_string("*  HOLD!  *",CENTER,text_y_center,1,RED, BLACK,1);
        cnt = 0;
        iter = 400;
        do
        {
            Read_Resistive();
            // showpoint(tp);
            if (tp.z > 20 && tp.z < 1000)
            {
                tx += tp.x;
                ty += tp.y;
                cnt++;
            }
            else
                failcount++;
        } while ((cnt < iter) && (failcount < 10000));
        if (cnt >= iter)
        {
            OK = true;
        }
        else
        {
            tx = 0;
            ty = 0;
            cnt = 0;
        }
        if (failcount >= 10000)
            fail();
    }

    cx = tx / iter;
    cy = ty / iter;
}

void calibrate(int x, int y, int i)
{
    drawCrossHair(x, y,WHITE);
    readCoordinates();
    my_lcd.Set_Draw_color(0);
    my_lcd.Fill_Rectangle(my_lcd.Get_Display_Width()/2-33, text_y_center, my_lcd.Get_Display_Width()/2+33, text_y_center+8);
    show_string("* RELEASE *",CENTER,text_y_center,1,BLUE, BLACK,1);
    drawCrossHair(x, y,0x528A);
    rx[i] = cx;
    ry[i] = cy;
    //Serial.print("\r\ncx="); Serial.print(cx);
    //Serial.print(" cy="); Serial.print(cy);
    while (is_pressed() == true) {}
}

void waitForTouch()
{
    while (is_pressed() == true) {}
    while (is_pressed() == false) {}
    while (is_pressed() == true) {}
}

void toHex(uint32_t num)
{
    buf[0] = '0';
    buf[1] = 'x';
    buf[10] = 'U';
    buf[11] = 'L';
    buf[12] = 0;
    for (int zz = 9; zz > 1; zz--)
    {
        if ((num & 0xF) > 9)
            buf[zz] = (num & 0xF) + 55;
        else
            buf[zz] = (num & 0xF) + 48;
        num = num >> 4;
    }
}

void startup()
{
    my_lcd.Set_Draw_color(255, 0, 0);
    my_lcd.Fill_Rectangle(0, 0, dispx - 1, 13);
    my_lcd.Set_Draw_color(255, 255, 255);
    my_lcd.Draw_Line(0, 14, dispx - 1, 14);
    show_string(TITLE,CENTER,1,1,WHITE, BLACK,1);

    my_lcd.Print_String("#define NUMSAMPLES 3 in Library", LEFT, 18);
    my_lcd.Print_String("Use a stylus or something", LEFT, 30);
    my_lcd.Print_String("similar to touch as close", LEFT, 42);
    my_lcd.Print_String("to the center of the", LEFT, 54);
    my_lcd.Print_String("highlighted crosshair as", LEFT, 66);
    my_lcd.Print_String("possible. Keep as still as", LEFT, 78);
    my_lcd.Print_String("possible and keep holding", LEFT, 90);
    my_lcd.Print_String("until the highlight is", LEFT, 102);
    my_lcd.Print_String("removed. Repeat for all", LEFT, 114);
    my_lcd.Print_String("crosshairs in sequence.", LEFT, 126);
    my_lcd.Print_String("Touch screen to continue", CENTER, 162);

    waitForTouch();
    my_lcd.Fill_Screen(BLACK);
}

void showNumI(char *msg, uint32_t val, int x, int y)
{
    show_string(msg,x,y,1,MAGENTA, BLACK,1);
    my_lcd.Set_Text_colour(GREEN);
    my_lcd.Print_Number_Int(val, x+50, y, 0, ' ',10);
}

void done()
{
    uint16_t TS_LEFT, TS_RT, TS_TOP, TS_BOT, TS_WID, TS_HT, TS_SWAP;
    int16_t tmp;
    my_lcd.Fill_Screen(BLACK);
    my_lcd.Set_Draw_color(255, 0, 0);
    my_lcd.Fill_Rectangle(0, 0, dispx - 1, 13);
    my_lcd.Set_Draw_color(255, 255, 255);
    my_lcd.Draw_Line(0, 14, dispx - 1, 14);
    show_string(TITLE,CENTER,1,1,WHITE, BLACK,1);
    my_lcd.Print_String("To use the new calibration", LEFT, 30);
    my_lcd.Print_String("settings you must map the values", LEFT, 42);
    my_lcd.Print_String("from Point p = ts.getPoint() e.g. ", LEFT, 54);
    my_lcd.Print_String("x = map(p.x, LEFT, RT, 0, lcd.width());", LEFT, 66);
    my_lcd.Print_String("y = map(p.y, TOP, BOT, 0, lcd.height());", LEFT, 78);
    my_lcd.Print_String("swap p.x and p.y if diff ORIENTATION", LEFT, 90);

    //.kbv show human values
    TS_LEFT = (calx >> 14) & 0x3FFF;
    TS_RT   = (calx >>  0) & 0x3FFF;
    TS_TOP  = (caly >> 14) & 0x3FFF;
    TS_BOT  = (caly >>  0) & 0x3FFF;
    TS_WID  = ((cals >> 12) & 0x0FFF) + 1;
    TS_HT   = ((cals >>  0) & 0x0FFF) + 1;
    TS_SWAP = (cals >> 31);
    if (TOUCH_ORIENTATION != 0) {
        my_lcd.Print_String("Sketch is LANDSCAPE", 0, 126);
        my_lcd.Print_Number_Int(TS_WID, 150, 126, 0, ' ',10);
        my_lcd.Print_String("x", 174, 126);
        my_lcd.Print_Number_Int(TS_HT, 186, 126, 0, ' ',10);
        showNumI("LEFT ", TS_LEFT, 0, 138);
        showNumI("RT   ", TS_RT, 100, 138);
        showNumI("TOP  ", TS_TOP, 0, 150);
        showNumI("BOT  ", TS_BOT, 100, 150);
        switch (TOUCH_ORIENTATION) {
            case 1:
                tmp = TS_LEFT, TS_LEFT = TS_TOP, TS_TOP = TS_RT, TS_RT = TS_BOT, TS_BOT = tmp;
                tmp = TS_WID, TS_WID = TS_HT, TS_HT = tmp;
                break;
        }
    }
    my_lcd.Print_String("PORTRAIT CALIBRATION", 0, 174);
    my_lcd.Print_Number_Int(TS_WID, 150, 174, 0, ' ',10);
    my_lcd.Print_String("x", 174, 174);
    my_lcd.Print_Number_Int(TS_HT, 186, 174, 0, ' ',10);
    showNumI("LEFT ", TS_LEFT, 0, 186);
    showNumI("RT   ", TS_RT, 100, 186);
    my_lcd.Print_Number_Float(((float)TS_RT - TS_LEFT) / TS_WID, 2, 200, 186, '.', 0, ' ');  
    showNumI("TOP  ", TS_TOP, 0, 198);
    showNumI("BOT  ", TS_BOT, 100, 198);
    my_lcd.Print_Number_Float(((float)TS_BOT - TS_TOP) / TS_HT, 2, 200, 198, '.', 0, ' ');  
    my_lcd.Print_String("Touch Pin Wiring is ", 0, 222);
    my_lcd.Print_String((cals >> 31) ? "SWAPXY" : "PORTRAIT", 170, 222);

}

void fail()
{
    my_lcd.Fill_Screen(BLACK);
    my_lcd.Set_Draw_color(255, 0, 0);
    my_lcd.Fill_Rectangle(0, 0, dispx - 1, 13);
    my_lcd.Set_Draw_color(255, 255, 255);
    my_lcd.Draw_Line(0, 14, dispx - 1, 14);
    show_string("Touch Calibration FAILED",CENTER,1,1,WHITE, BLACK,1);

    my_lcd.Print_String("Unable to read the position", LEFT, 30);
    my_lcd.Print_String("of the press. This is a", LEFT, 42);
    my_lcd.Print_String("hardware issue and can", LEFT, 54);
    my_lcd.Print_String("not be corrected in", LEFT, 66);
    my_lcd.Print_String("software.", LEFT, 78);
    my_lcd.Print_String("check XP, XM pins with a multimeter", LEFT, 102);
    my_lcd.Print_String("check YP, YM pins with a multimeter", LEFT, 114);
    my_lcd.Print_String("should be about 300 ohms", LEFT, 126);

    while (true) {};
}

void loop()
{
    startup();


    drawCrossHair(dispx - 11, 10,0x528A);
    drawCrossHair(dispx / 2, 10,0x528A);
    drawCrossHair(10, 10,0x528A);
    drawCrossHair(dispx - 11, dispy / 2,0x528A);
    drawCrossHair(10, dispy / 2,0x528A);
    drawCrossHair(dispx - 11, dispy - 11,0x528A);
    drawCrossHair(dispx / 2, dispy - 11,0x528A);
    drawCrossHair(10, dispy - 11,0x528A);

    show_string("***********",CENTER,text_y_center - 12,1,WHITE, BLACK,1);
    show_string("***********",CENTER,text_y_center + 12,1,WHITE, BLACK,1);
    
    calibrate(10, 10, 0);
    calibrate(10, dispy / 2, 1);
    calibrate(10, dispy - 11, 2);
    calibrate(dispx / 2, 10, 3);
    calibrate(dispx / 2, dispy - 11, 4);
    calibrate(dispx - 11, 10, 5);
    calibrate(dispx - 11, dispy / 2, 6);
    calibrate(dispx - 11, dispy - 11, 7);

    cals = (long(dispx - 1) << 12) + (dispy - 1);
    if (TOUCH_ORIENTATION == 0) swapxy = rx[2] - rx[0];
    else swapxy = ry[2] - ry[0];
    swapxy = (swapxy < -500 || swapxy > 500);
    if ((TOUCH_ORIENTATION == 0) ^ (swapxy != 0)) {
        clx = (rx[0] + rx[1] + rx[2]) / 3;
        crx = (rx[5] + rx[6] + rx[7]) / 3;
        cty = (ry[0] + ry[3] + ry[5]) / 3;
        cby = (ry[2] + ry[4] + ry[7]) / 3;
    } else {
        clx = (ry[0] + ry[1] + ry[2]) / 3;
        crx = (ry[5] + ry[6] + ry[7]) / 3;
        cty = (rx[0] + rx[3] + rx[5]) / 3;
        cby = (rx[2] + rx[4] + rx[7]) / 3;
    }
    px = float(crx - clx) / (dispx - 20);
    py = float(cby - cty) / (dispy - 20);
    //  px = 0;
    clx -= px * 10;
    crx += px * 10;
    cty -= py * 10;
    cby += py * 10;

    calx = (long(clx) << 14) + long(crx);
    caly = (long(cty) << 14) + long(cby);
    if (swapxy)
        cals |= (1L << 31);

    done();
    while (true) {}
}

Besten Dank im Voraus und schönes WE

Die Pins für den SPI liegen beim MEGA woanders: 50 (MISO), 51 (MOSI), 52 (SCK), Der PIN 53 (SS) kann vernachlässigt werden, da der Mega kein Slave ist.

Deshalb werden diese bei Shields, die wirklich für beide Platinen sind, über den ICSP abgegriffen.
@ardu_1394: Gib uns mal ein Bild von Vorder- und Rückseite des Shields.

Gruß Tommy

Das ist schon falsch wen du schon -LCDWicki nimmst nehme die für deinen Display wen der dan wirklich SPI ist dan ist der nicht für Uno Mega.
Zeig doch was für einer ist das Link reicht

Danke für die schnelle Antwort,
aber die von dir beschriebenen Pins werden bei dem Display
doch garnicht benutzt.
Ich denke du meinst andere Ansteuerungen für Displays als
da bei mir verwendet wird!
Es wird nur über die 8 digitalen Ausgänge angesteuert
(wie auch beschrieben A0-A3 und 10-13).
Nix seriell, oder lieg ich da etwa falsch?
Und wie schon beschrieben sind die verwendeten Pins auf beiden Ardu-Arten gleich beschriftet.
So sollte doch deren Funktionalität auch gleich sein, oder?
Gruß

10-13 sind für die SD mit SPI. Die liegen nur beim UNO dort.
Das wo LCD dran steht, sind die Pins fürs Display.

Gruß Tommy

Warum zeigst du nicht was für einer ist das?
A0 -A4 sind Steuerpins + auch Touch Pins.
10 -13 ist SPI aber nur bei UNO, ja der wird auch auf Mega funktionieren nur nicht direkt streckbar, dafür brauchst du eine zwischen Platine danach geht er auf Mega und Uno,

Nein das Stimmt nicht I2C und SPI sind anders belegt dafür hat sich Adafruit zwischen Schild ausgedacht und auf den kommt das Display drauf.
Jedoch wenn du Nur Display hast funktioniert er Streckbar nur auf UNO

TF028 SPECIFICATION-1.pdf (279.9 KB)

Das ist das Display.
Dort steht auch "direkt nutzbar an beiden" und nix von Adapter-Board.
Und mal allgemein gefragt:
Wenn ein Techniker Pins gleich beschriftet, aber sie
nicht die gleiche Funktionalität haben?
Wer macht denn sowas und das insbesondere in der eigenen
Arduino-Plattform!!!
Oder wurden die beiden Plattformen von verschiedenen Fraktionen entwickelt, die nicht miteinander geredet haben? :smiley:
Also wat nu?
Gruß

So wie ich vermutet habe ist stinknormales 8Bit Display :wink:
Die SPI Pins sind für den Karten Leser, und wie ich schon in post #4 geschrieben habe ist die Adressierung total falsch.
Vermutung den auf den Zettel steht kein Treiber drauf , es ist ein ILI9341
er wird so Angesprochen

LCDWIKI_KBV my_lcd(ILI9341,A3,A2,A1,A0,A4); //model,cs,cd,wr,rd,reset 

Der ILI9341 kann nur 240 x 320 Pixel ansteuern
Und Ja der wird auf Mega auch funktionieren nur muss vernünftig angesteuert werden
mit dem gezeigtem tuts es

hier ist dein Display beschrieben hat doch ILI9341

SD aber nur am UNO ohne Umbau.

Gruß Tommy

Hettest du den Zettel sofort gezeigt kämme nicht zu den Falschaussagen.
Du bist doch seit 30 Sep '18 dabei also solltest wissen das ein Datenblatt, oder Link zum Produkt sehr wichtig ist, auch wen man meint man weis alles ( Unsinnige aussage es ist ein SPI Display )

So is es, habe extra nur erwähnt wo zu die SPI Pins gut sind.
Wo bei dort stecht extra SD_ xxx, da n sollte der TO auch das so interpretieren, oder genauer suchen.

Blockquote

SD aber nur am UNO ohne Umbau.

Gruß Tommy

Blockquote

Hallo Tommy
Kannst du mir genau sagen, was der Umbau bedeutet?
Wie muß der aussehen das es auch am MEGA funktioniert?
Irgendwer redet von nötiger "Zwischen-Platine".
Muß da was aktives drauf oder müssen nur Pins umverteilt werden?
Wie zum Geier komm ich da an verlässliche Informationen dazu?

Alle sagen so gehts nicht, keiner sagt wie es geht.
Ich hoffe es versteht endlich jemand mein Anliegen.

Bisher habe ich das Gefühl wir reden alle aneinander vorbei.
Dank im Voraus

Hast du probiert die Änderung

LCDWIKI_KBV my_lcd(ILI9341,A3,A2,A1,A0,A4); //model,cs,cd,wr,rd,reset 

Damit sollte das Display auf Mega funktionieren, wen du jedoch auch
den Karteleser nutzen willst auf einem Mega dann muss man das Display lose mit dem Mega verbinden (Dupont Kabel )und die mit SD_xx bezeichnete Pins an der Seitlicher Leiste klemmen

Die verlässlichste Quelle sind die Datenblätter der jeweiligen Arduinos und die Pinouts.
Dort kannst Du schauen, welche Pins wie umgelegt werden müssen.
Am universellsten wäre ein Umlegen von MOSI, MISO und SCK auf den Programmieradapter ICSP (hinten Mitte), da der bei beiden gleich ist.

Gruß Tommy

Edit: Ob Du das mit einer Zwischenplatine machst oder die Leiterzüge auf dem Shield unterbrichst und umverdrahtest, ist Dir überlassen.

Nimm diese Bibliothek zu Probe danach Schreiben wir weiter.
Das Beispiel ist unter GLUE_Demo_320x240

we du die KBW runter lädst dann teste das

 // UTFT_Demo_320x240 
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution 
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

//################################################
// GLUE class that implements the UTFT API
// replace UTFT include and constructor statements
// remove UTFT font declaration e.g. SmallFont
//################################################

#include <UTFTGLUE.h>              //use GLUE class and constructor
UTFTGLUE myGLCD(0,A2,A1,A3,A4,A0); //all dummy args

// Declare which fonts we will be using
//extern uint8_t SmallFont[];      //GLUE defines as GFXFont ref

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield            : <display model>,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield        : <display model>,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
 //UTFT myGLCD(ITDB32S,38,39,40,41);

void setup()
{
  randomSeed(analogRead(0));
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop()
{
  int buf[318];
  int x, x2;
  int y, y2;
  int r;

// Clear the screen and draw the frame
  myGLCD.clrScr();

  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 226, 319, 239);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0);
  myGLCD.print("<http://www.RinkyDinkElectronics.com/>", CENTER, 227);

  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 14, 319, 225);

// Draw crosshairs
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.drawLine(159, 15, 159, 224);
  myGLCD.drawLine(1, 119, 318, 119);
  for (int i=9; i<310; i+=10)
    myGLCD.drawLine(i, 117, i, 121);
  for (int i=19; i<220; i+=10)
    myGLCD.drawLine(157, i, 161, i);

// Draw sin-, cos- and tan-lines  
  myGLCD.setColor(0,255,255);
  myGLCD.print("Sin", 5, 15);
  for (int i=1; i<318; i++)
  {
    myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));
  }
  
  myGLCD.setColor(255,0,0);
  myGLCD.print("Cos", 5, 27);
  for (int i=1; i<318; i++)
  {
    myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));
  }

  myGLCD.setColor(255,255,0);
  myGLCD.print("Tan", 5, 39);
  for (int i=1; i<318; i++)
  {
    myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));
  }

  delay(2000);

  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.drawLine(159, 15, 159, 224);
  myGLCD.drawLine(1, 119, 318, 119);

// Draw a moving sinewave
  x=1;
  for (int i=1; i<(318*20); i++) 
  {
    x++;
    if (x==319)
      x=1;
    if (i>319)
    {
      if ((x==159)||(buf[x-1]==119))
        myGLCD.setColor(0,0,255);
      else
        myGLCD.setColor(0,0,0);
      myGLCD.drawPixel(x,buf[x-1]);
    }
    myGLCD.setColor(0,255,255);
    y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100)));
    myGLCD.drawPixel(x,y);
    buf[x-1]=y;
  }

  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some filled rectangles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));
  }

  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some filled, rounded rectangles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillRoundRect(190-(i*20), 30+(i*20), 250-(i*20), 90+(i*20));
  }
  
  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some filled circles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillCircle(100+(i*20),60+(i*20), 30);
  }
  
  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some lines in a pattern
  myGLCD.setColor (255,0,0);
  for (int i=15; i<224; i+=5)
  {
    myGLCD.drawLine(1, i, (i*1.44)-10, 224);
  }
  myGLCD.setColor (255,0,0);
  for (int i=224; i>15; i-=5)
  {
    myGLCD.drawLine(318, i, (i*1.44)-11, 15);
  }
  myGLCD.setColor (0,255,255);
  for (int i=224; i>15; i-=5)
  {
    myGLCD.drawLine(1, i, 331-(i*1.44), 15);
  }
  myGLCD.setColor (0,255,255);
  for (int i=15; i<224; i+=5)
  {
    myGLCD.drawLine(318, i, 330-(i*1.44), 224);
  }
  
  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some random circles
  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=32+random(256);
    y=45+random(146);
    r=random(30);
    myGLCD.drawCircle(x, y, r);
  }

  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some random rectangles
  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=2+random(316);
    y=16+random(207);
    x2=2+random(316);
    y2=16+random(207);
    myGLCD.drawRect(x, y, x2, y2);
  }

  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

// Draw some random rounded rectangles
  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=2+random(316);
    y=16+random(207);
    x2=2+random(316);
    y2=16+random(207);
    myGLCD.drawRoundRect(x, y, x2, y2);
  }

  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=2+random(316);
    y=16+random(209);
    x2=2+random(316);
    y2=16+random(209);
    myGLCD.drawLine(x, y, x2, y2);
  }

  delay(2000);
  
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);

  for (int i=0; i<10000; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    myGLCD.drawPixel(2+random(316), 16+random(209));
  }

  delay(2000);

  myGLCD.fillScr(0, 0, 255);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRoundRect(80, 70, 239, 169);
  
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("That's it!", CENTER, 93);
  myGLCD.print("Restarting in a", CENTER, 119);
  myGLCD.print("few seconds...", CENTER, 132);
  
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 255);
  myGLCD.print("Runtime: (msecs)", CENTER, 210);
  myGLCD.printNumI(millis(), CENTER, 225);
  
  delay (10000);
}

Noch was die LCDWiki will nicht auf keinem vom meinen Mega
Um 100% sicher sein was für Display du hast lade das auf den Mega. Das Display muss aber drauf sein :wink:

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
#define GRAY    0x8410

uint16_t version = MCUFRIEND_KBV_H_;

void setup()
{
    Serial.begin(9600);
    if (!Serial) delay(5000);           //allow some time for Leonardo
    uint16_t ID = tft.readID(); //
    Serial.println(F("Diagnose whether this controller is supported"));
    Serial.println(F("There are FAQs in extras/mcufriend_how_to.txt"));
    Serial.println(F(""));
    Serial.print(F("tft.readID() finds: ID = 0x"));
    Serial.println(ID, HEX);
    Serial.println(F(""));
	Serial.print(F("MCUFRIEND_kbv version: "));
    Serial.print(version/100);
	Serial.print(F("."));
    Serial.print((version / 10) % 10);
	Serial.print(F("."));
    Serial.println(version % 10);
    Serial.println(F(""));
    if (ID == 0x0404) {
        Serial.println(F("Probably a write-only Mega2560 Shield"));
        Serial.println(F("#define USE_SPECIAL in mcufriend_shield.h"));
        Serial.println(F("#define appropriate SPECIAL in mcufriend_special.h"));
        Serial.println(F("e.g. USE_MEGA_16BIT_SHIELD"));
        Serial.println(F("e.g. USE_MEGA_8BIT_SHIELD"));
        Serial.println(F("Hint.  A Mega2560 Shield has a 18x2 male header"));
        Serial.println(F("Often a row of resistor-packs near the 18x2"));
        Serial.println(F("RP1-RP7 implies 16-bit but it might be 8-bit"));
        Serial.println(F("RP1-RP4 or RP1-RP5 can only be 8-bit"));
    }
    if (ID == 0xD3D3) {
        uint16_t guess_ID = 0x9481; // write-only shield
        Serial.println(F("Probably a write-only Mega2560 Shield"));
        Serial.print(F("Try to force ID = 0x"));
        Serial.println(guess_ID, HEX);
        tft.begin(guess_ID);
    }
    else tft.begin(ID);
    Serial.println(F(""));
    if (tft.width() == 0) {
        Serial.println(F("This ID is not supported"));
        Serial.println(F("look up ID in extras/mcufriend_how_to.txt"));
        Serial.println(F("you may need to edit MCUFRIEND_kbv.cpp"));
        Serial.println(F("to enable support for this ID"));
        Serial.println(F("e.g. #define SUPPORT_8347D"));
        Serial.println(F(""));
        Serial.println(F("New controllers appear on Ebay often"));
        Serial.println(F("If your ID is not supported"));
        Serial.println(F("run LCD_ID_readreg.ino from examples/"));
        Serial.println(F("Copy-Paste the output from the Serial Terminal"));
        Serial.println(F("to a message in Displays topic on Arduino Forum"));
        Serial.println(F("or to Issues on GitHub"));
        Serial.println(F(""));
        Serial.println(F("Note that OPEN-SMART boards have diff pinout"));
        Serial.println(F("Edit the pin defines in LCD_ID_readreg to match"));
        Serial.println(F("Edit mcufiend_shield.h for USE_SPECIAL"));
        Serial.println(F("Edit mcufiend_special.h for USE_OPENSMART_SHIELD_PINOUT"));
       while (1);    //just die
    } else {
        Serial.print(F("PORTRAIT is "));
        Serial.print(tft.width());
        Serial.print(F(" x "));
        Serial.println(tft.height());
        Serial.println(F(""));
        Serial.println(F("Run the examples/graphictest_kbv sketch"));
        Serial.println(F("All colours, text, directions, rotations, scrolls"));
        Serial.println(F("should work.  If there is a problem,  make notes on paper"));
        Serial.println(F("Post accurate description of problem to Forum"));
        Serial.println(F("Or post a link to a video (or photos)"));
        Serial.println(F(""));
        Serial.println(F("I rely on good information from remote users"));
    }
}

void loop()
{
    static uint8_t aspect = 0;
    const char *aspectname[] = {
        "PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV"
    };
    const char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };
    uint16_t colormask[] = { BLUE, GREEN, RED, GRAY };
    uint16_t ID = tft.readID(); //
    tft.setRotation(aspect);
    int width = tft.width();
    int height = tft.height();
    tft.fillScreen(colormask[aspect]);
    tft.drawRect(0, 0, width, height, WHITE);
    tft.drawRect(32, 32, width - 64, height - 64, WHITE);
    tft.setTextSize(2);
    tft.setTextColor(BLACK);
    tft.setCursor(40, 40);
    tft.print("ID=0x");
    tft.print(ID, HEX);
    if (ID == 0xD3D3) tft.print(" w/o");
    tft.setCursor(40, 70);
    tft.print(aspectname[aspect]);
    tft.setCursor(40, 100);
    tft.print(width);
    tft.print(" x ");
    tft.print(height);
    tft.setTextColor(WHITE);
    tft.setCursor(40, 130);
    tft.print(colorname[aspect]);
    tft.setCursor(40, 160);
    tft.setTextSize(1);
    tft.print("MCUFRIEND_KBV_H_ = ");
    tft.print(version);
    if (++aspect > 3) aspect = 0;
    delay(5000);
}