Hi all. I'm a bit new to this world but loving it! This is a bit convoluted so props if you hang in there through this explanation.
I purchased a 9" TFT LCD from buydisplays which has a shield for the Mega (I am using a Mega) with an SD card reader and takes a separate 5V power supply.
Turns out you cannot use the touchscreen and the SD card at the same time even though they initially make it seem that way but confirmed through support that's not the case without modification. The link below has a bunch of diagrams.
I found these most helpful (note JP1 & JP2 are references backwards):
The LCD also has it's own sd card reader on board that isn't connected to anything but does get 3.3V when the screen is powered.
I dug through the pinouts of the shield and found that the hardware SPI ports aren't actually used, the screen is using software SPI
Soooo I broke off those pins and wired in to 50, 51, 52, 53 (initially 53, I tried switching to 7 just in case) and was able to get that card reader working (yay)
But now it seems the touchscreen isn't working. I tried using pin 53 as the cs pin but I know the mega can be temperamental about it since it's the ss pin so I tried swapping to another open pin but same outcome.
I have pin 53 set as output just in case. The issue arises when I call "SD.begin()". I have tried setting the cs pin HIGH after that call but no luck.
If it helps diagnose I have noticed that if I remove SD.begin() and push the sketch the touch still doesn't work until I power everything off and back on.
I thought with the LCD and TFT running as software SPIs that the hardware SPI would function without issue but maybe that's not the case?
I've attached what I believe to be the relevant code. Am I trying to do something impossible?
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <UTFT.h>
#include <UTouch.h>
//chip select pin
#define SD_CS 7
//force landscape
#define TOUCH_ORIENTATION LANDSCAPE //PORTRAIT
//LCD pins through shield - Software SPI
UTFT myGLCD(SSD1963_800480, 38, 39, 40, 41); //(byte model, int RS, int WR, int CS, int RST, int SER)
//touchscreen - Software SPI
UTouch myTouch(43, 42, 44, 45, 46); //byte tclk, byte tcs, byte din, byte dout, byte irq
// Declare which fonts we will be using
extern uint8_t BigFont[];
int x, y;
int dispx, dispy, text_y_center;
char stCurrent[20] = "";
int stCurrentLen = 0;
char stLast[20] = "";
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// Setup the LCD
myGLCD.InitLCD();
myGLCD.clrScr();
// -------------------------------------------------------------
pinMode(8, OUTPUT); //backlight
digitalWrite(8, HIGH); //on
// -
//set ss as output
pinMode(53, OUTPUT);
myTouch.InitTouch(TOUCH_ORIENTATION);
myTouch.setPrecision(PREC_MEDIUM);
dispx = myGLCD.getDisplayXSize();
dispy = myGLCD.getDisplayYSize();
text_y_center = (dispy / 2) - 6;
myGLCD.setFont(BigFont);
myGLCD.setBackColor(0, 0, 255);
SD.begin(SD_CS);
digitalWrite(7, HIGH);
//bmpDraw("BMP_1.bmp", 0, 0); //remove for now while troubleshooting
drawButtons();
}