Hello again Arduino Community!
Hope everyone's well!
I did not have any responses to my previous post but I managed to hook up 2 screens on my Arduino - these are both ILI9486 TFT Shields, 3.5 Inch each.
I am using the MCUFRIEND library as the ADAFRUIT one does not support ILI9486, however, I have been having issues in declaring the pins so I can control both of them individually, so I believe I am (99%) missing something while using the MCUFRIEND library, therefore I am looking to understand what I have been doing wrong.
I have been using the 2.2.9 version of the library.
As mentioned, I believe the issue is at the declaration. I am using the below code before void setup()
#include <SPI.h> #include <Adafruit_GFX.h> // Core graphics library // #include <Adafruit_TFTLCD.h> // LCD library // #include <TouchScreen.h> // Touchscreen Library #include <MCUFRIEND_kbv.h> // Touchscreen Hardware-specific library #define LCD1_CS A3 #define LCD1_CD A2 #define LCD_WR A1 #define LCD_RD A0 #define LCD1_RESET A4 #define LCD2_CS A5 #define LCD2_CD A6 #define LCD2_RESET A7 #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF MCUFRIEND_kbv tft1(LCD1_CS, LCD1_CD, LCD_WR, LCD_RD, LCD1_RESET); MCUFRIEND_kbv tft2(LCD2_CS, LCD2_CD, LCD_WR, LCD_RD, LCD2_RESET);
When I began experimenting, I only split the CS pin for controlling the displays separately and shared the rest 4 pins.
As it wasn't working I also shared the CD (RS) and RST (Reset) pins as well, to no avail.
I have spent another day looking over the internet for helpful articles and I cannot find anything that is different from what I have done above, however, I have noticed that people who are using 2 constructors with the same library are using the ADFRUIT_TFTLCD library so I am not sure if that is vital as I cannot tet it with my displays.
I have attached an image of the result I am getting with my code. You can see that both screen show as "Screen 2" although these have been coded so Screen 1 should show "Screen 1" and Screen 2, "Screen 2"
// TFT 1 tft1.fillRect(80,200,321,60,BLACK); tft1.fillRect(80,200,321,60,RED); tft1.setCursor(135,215); tft1.setTextColor(WHITE); tft1.setTextSize(4); tft1.print("Screen 1"); delay(1000); // TFT 2 tft2.fillRect(80,200,321,60,BLACK); tft2.fillRect(80,200,321,60,RED); tft2.setCursor(135,215); tft2.setTextColor(BLACK); tft2.setTextSize(4); tft2.print(" Screen 2"); delay(1000);
To my surprise, I have found that the declarations at the beginning of my code, do not seem to have any effect on the rest of the program.
I tried changing them (so I tested my theory) to:
#define LCD1_CS A0 #define LCD1_CD A0 #define LCD_WR A0 #define LCD_RD A0 #define LCD1_RESET A0 #define LCD2_CS A0 #define LCD2_CD A0 #define LCD2_RESET A0
and the results I got were exactly the same. This tells me that there is some override happening in the MCUFRIEND library which I suppose I need to find and change?
I hope I do not sound super naive here, I am only a beginner and it's been only a few months I have started working with Arduino but this is my first encounter with displays.
Many thanks in advance!