[Solved] Pin conflict / Ethernet Shield 2 with Arduino TFT Screen

Hi,

I am currently working on a project in which both an Ethernet Shield 2 (Ethernet Shield 2) and an Arduino TFT Screen (Arduino TFT Screen) are needed. While the Ethernet Shield is stacked on top of an Arduino Uno Rev 3, the screen is attached to a breadboard and wired to the pins of the Ethernet shield (for which see below) - such since it isn’t built to be stacked on top of any shield directly.

Both the Ethernet Shield as the TFT Screen work without problem when used separately, but the problem for which I need to find a solution is that the shield and the screen default both rely on pin 10. I have been trying to find myself a way around by manually declaring all pins needed by the TFT Screen, instead of using the default hardware pins - such by following the approach described at TFTLibrary. However, when doing so the compiler returns the following error message:

no matching function for call to 'TFT::TFT(int, int, int, int, int)'

My interpretation of the error log (for which see) is that I am providing more arguments (5) than the relevant function in the libraries I rely on in my code (which is the native TFT library that is part of IDE 1.8.0 and the ones it refers to, for which see the attached files) can handle (3), and it is here that I am completely lost. I am certainly not educated enough on libraries to meddle with them, and therefore I would much welcome any ideas that help me solve this problem and have the Ethernet Shield and the TFT Screen work nicely together.

To give you a better understanding of what I am doing, the TFT Screen is wired as follows:

+5V: +5V
MISO: pin 12
SCK: pin 13
MOSI: pin 11
LCD CS: pin 7 // pin 10 in use by ethernet shield 2
SD CS: pin 4
D/C: pin 9
RESET: pin 8
BL: +5V
GND: GND

This scheme is mirrored in the following bits of code that are part of my sketch:

#include <Ethernet2.h>
#include <EthernetUdp2.h>
#include <SPI.h>
#include <TFT.h>

#define sd_cs   4
#define mosi   11
#define lcd_cs  7
#define dc       9
#define rst      8

// Initiating an instance of the TFT library named TFTscreen
TFT TFTscreen = TFT(lcd_cs, dc, mosi, sd_cs, rst);

<snip>

void setup()
{

Serial.begin(9600);

Ethernet.begin(mac, ip);
  
TFTscreen.begin();

<snip>

}

Thanks in advance for your time and attention!

TFT.cpp (1.9 KB)

TFT.h (2.22 KB)

Adafruit_GFX.cpp (16.8 KB)

Adafruit_GFX.h (11.4 KB)

Adafruit_ST7735.cpp (21.6 KB)

Adafruit_ST7735.h (4.53 KB)

Error_log.txt (32.1 KB)