I am trying to connect about 5 TFT's to my Arduino Uno and I got to the point of hooking two of them up without any issues. However, after a code upload, they stopped working. I then took all the code out and tested each in isolation and they still function. However, together only one of them displays data. The TFT's I am using are the ST7789v2 found here. https://www.waveshare.com/wiki/1.69inch_LCD_Module#Hardware_Connection_3
I have wired them up according to the schematic with "all" pins being shared except the CS pin. Each display has its own.
The code looks like this;
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#define TFT_CS1 10
#define TFT_CS2 3
#define TFT_RST 8 // Screens shared
#define TFT_DC 7 // Screens shared
#define TFT_BACKLIGHT 9 // Backlight for all screens
Adafruit_ST7789 tftHour1 = Adafruit_ST7789(TFT_CS1, TFT_DC, TFT_RST);
Adafruit_ST7789 tftHour2 = Adafruit_ST7789(TFT_CS2, TFT_DC, TFT_RST);
Adafruit_ST7789 setupScreen (Adafruit_ST7789 tft){
tft.init(240, 280);
tft.fillScreen(ST77XX_BLACK);
return tft;
}
void setup(void) {
tftHour1 = setupScreen(tftHour1);
tftHour2 = setupScreen(tftHour2);
}
void loop(){
tftHour1.print("1");
tftHour2.print("2");
}
When this executes, display 2 shows output but display 1 does not. Weirdly if I take the CS from display 1 and pop it into the same line on the breadboard as CS2, and then put it back into its original position, display 1 and 2 seem to work. But only till the next power cycle or upload.
Also oddly, setting the colour of each screen works even if one is blue and the other is say green. Both change to their respective colours. But when I try to write text to them, only one of them has text.
If I comment the code for tftHour2, then tftHour1 starts showing text. If I swap the setup code for ftfHour1 and tftHour2, then the display that is last to init, is the one that shows the text and the other stays blank.
Like I said, I had all this working and then a simple font change upload and it all stopped working.
Any help on this is really appreciated.
I should mention that I am a programmer and very new to electronics so please keep it simple.
#Update. If I have separate RST pins then it works. But I need 5 screen and will run out of pins in that case. Is there a way to get around that?
tftHour1
andtftHour2
and then you throw in an object nametft
setupScreen()
takes aAdafruit_ST7789
as argument, that is perfect to use the same code. But 1st, why does the function need to return that argument? And 2nd, why do you overwrite the existing objects intftHour1
andtftHour2
with themselves?void setupScreen (Adafruit_ST7789 & tft) { // now changes to tft will be changing original object too