Is it possible to have 2 TFT screens (parallel) on a MEGA ?

Hello,
I'm building a display for my Netatmo weather station like this one. I'm not a power user, more a beginer :slight_smile:

For a cost problem, I bought two Kuman Ecran Tactile UNO R3 3.5 TFT (Photos at the bottom of the post)

I'm using an ELEGOO Carte Mega 2560 R3 ATmega2560 ATMEGA . (and I succed to have WeMOS Mega + WiFi R3 ATmega2560 + ESP8266 working to grab Netatmo data using a php script, this works great, but I don't have yet connected the TFT on it, juste on the Elegoo Mega).

In Shield mode, one TFT works fine, I wired it to a breadboard using shield mode for Pin connexion.
I'm using a test example found in the mini dvd provided with the screen.
Here the code :

#include <SPI.h>          // f.k. for Arduino-1.5.2
#include "Adafruit_GFX.h"// Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
//#include <Adafruit_TFTLCD.h>
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// 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

#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif


void setup(void);
void loop(void);
unsigned long testText();


uint16_t g_identifier;



void setup(void) {
  Serial.begin(9600);
  Serial.println(F("TFT LCD test"));

  tft.reset();

  uint16_t identifier = tft.readID();
  if (identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if (identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if (identifier == 0x4535) {
    Serial.println(F("Found LGDP4535 LCD driver"));
  } else if (identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if (identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  } else if (identifier == 0x7783) {
    Serial.println(F("Found ST7781 LCD driver"));
  } else if (identifier == 0x8230) {
    Serial.println(F("Found UC8230 LCD driver"));
  }
  else if (identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else if (identifier == 0x0101)
  {
    identifier = 0x9341;
    Serial.println(F("Found 0x9341 LCD driver"));
  } else if (identifier == 0x9481)
  {
    Serial.println(F("Found 0x9481 LCD driver"));
  }
  else if (identifier == 0x9486)
  {
    Serial.println(F("Found 0x9486 LCD driver"));
  }
  else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
    Serial.println(F("  #define USE_ADAFRUIT_SHIELD_PINOUT"));
    Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
    Serial.println(F("If using the breakout board, it should NOT be #defined!"));
    Serial.println(F("Also if using the breakout, double-check that all wiring"));
    Serial.println(F("matches the tutorial."));
    identifier = 0x9486;

  }

  tft.begin(identifier);
  Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
}


#if defined(MCUFRIEND_KBV_H_)
uint16_t scrollbuf[320];    // my biggest screen is 320x480
#define READGRAM(x, y, buf, w, h)  tft.readGRAM(x, y, buf, w, h)
#else
uint16_t scrollbuf[320];    // Adafruit only does 240x320
// Adafruit can read a block by one pixel at a time
int16_t  READGRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h)
{
  uint16_t *p;
  for (int row = 0; row < h; row++) {
    p = block + row * w;
    for (int col = 0; col < w; col++) {
      *p++ = tft.readPixel(x + col, y + row);
    }
  }
}
#endif

void windowScroll(int16_t x, int16_t y, int16_t wid, int16_t ht, int16_t dx, int16_t dy, uint16_t *buf)
{
  if (dx) for (int16_t row = 0; row < ht; row++) {
      READGRAM(x, y + row, buf, wid, 1);
      tft.setAddrWindow(x, y + row, x + wid - 1, y + row);
      tft.pushColors(buf + dx, wid - dx, 1);
      tft.pushColors(buf + 0, dx, 0);
    }
  if (dy) for (int16_t col = 0; col < wid; col++) {
      READGRAM(x + col, y, buf, 1, ht);
      tft.setAddrWindow(x + col, y, x + col, y + ht - 1);
      tft.pushColors(buf + dy, ht - dy, 1);
      tft.pushColors(buf + 0, dy, 0);
    }
}


void loop() {
  uint8_t aspect;
  uint16_t pixel;
  char *aspectname[] = {
    "PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV"
  };
  char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };
  uint16_t colormask[] = { 0x001F, 0x07E0, 0xF800, 0xFFFF };
  uint16_t dx, rgb, n, wid, ht;
  tft.setRotation(3);
  wid = tft.width();
  ht = tft.height();
  //                tft.print("Width=");
  //                tft.println(wid);
  //                tft.print("Hight=");
  //                tft.println(ht);

  // === Temp color scale ===
  tft.fillScreen(BLACK);
  int bleu = 255;
  int rouge = 0;
  int vert = 0;
  int i = 0;
  for (int i_v = 0; i_v < 40; i_v++)
  {
    tft.fillRect ( i * 3, 0, 3, ht, tft.color565(rouge, vert, bleu));
    vert = vert + 8;
    if (vert > 255)
    {
      vert = 255;
    }
    i++;
  }

  for (int i_b = 0; i_b < 40; i_b++)
  {
    tft.fillRect ( i * 3, 0, 3, ht, tft.color565(rouge, vert, bleu));
    bleu = bleu - 8;
    if (bleu < 0)
    {
      bleu = 0;
    }
    i++;
  }

  for (int i_r = 0; i_r < 40; i_r++)
  {
    tft.fillRect ( i * 3, 0, 3, ht, tft.color565(rouge, vert, bleu));
    rouge = rouge + 8;
    if (rouge > 255)
    {
      rouge = 255;
    }
    i++;
  }

  for (int i_v = 0; i_v < 40; i_v++)
  {
    tft.fillRect ( i * 3, 0, 3, ht, tft.color565(rouge, vert, bleu));
    vert = vert - 8;
    if (vert < 0)
    {
      vert = 0;
    }
    i++;
  }


  delay(2000);
  tft.fillScreen(BLACK);
  tft.setCursor(0, 72);
  tft.setTextSize(4);
  tft.setTextColor(WHITE);
  tft.write('é');
  delay(6000);

  if (tft.height() > 64) {
    aspect = 3;
    tft.setRotation(aspect);
    wid = tft.width();
    ht = tft.height();
    testText();
    dx = wid / 32;
    for (n = 0; n < 32; n++) {
      rgb = n * 8;
      rgb = tft.color565(rgb, rgb, rgb);
      tft.fillRect(n * dx, 48, dx, 64, rgb & colormask[aspect]);
    }
  
  }


  tft.println("INVERT DISPLAY");
  tft.invertDisplay(true);
  delay(5000);
  tft.invertDisplay(false);



}



unsigned long testText() {
  unsigned long start;
  tft.fillScreen(BLACK);
  start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(YELLOW); tft.setTextSize(2);
  tft.println(123.45);
  tft.setTextColor(RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  return micros() - start;
}

The code works fine.
My question is about using 2 TFT screens... is this possible ? If yes, how ?
If not, hmmm... I'll be force to return one of the screens...
Too bad...

Thanks for your help :slight_smile:
Miles