Hi,
i'm using Arduino DUE with this display: 7"Arduino Touch Screen Shield w/SSD1963,Library for Mega/Due
The libraries provided by the seller are an old version of UTFT and UTouch, which uses Software SPI. There isn't a library to load pictures from SD, and i decided to use the original UTFT_SdRaw. This library uses hardware SPI, so i soldered the jumpers on the screen to use it, and i modified the pin numbers inside the two libraries.
This is the screen schematics: http://www.buydisplay.com/arduino/ER-AS-SSD1963—Arduino-Schematic-Diagram.PDF
Using hardware SPI and thoose libraries, i can use the touch screen OR the SD card succesfully. The problem appears when i try to use them toegether: the SD works, but the touchscreen stops working, the functions getX and getY return always -1.
This is the sketch, i used an example adding the SD card initialization:
// PLEASE READ: i soldered the jumper on the display to use HARDWARE SPI.
// The touchscreen and the sd card work separately, but not in the same sketch
#include <UTFT.h>
#include <UTouch.h>
#include <SdFat.h>
#define SD_CHIP_SELECT 47
#define TOUCH_CHIP_SELECT 42
#define LCD_CHIP_SELECT 40
// Istanze LCD e Touch
UTFT LCD(SSD1963_800480, 38, 39, LCD_CHIP_SELECT, 41);
UTouch Touch(76, TOUCH_CHIP_SELECT, 75, 74, 46);
SdFat sd;
extern uint8_t SmallFont[];
void setup() {
Serial.begin(9600);
// -------------------LCD--------------------------
LCD.InitLCD();
pinMode(8, OUTPUT); //Accendo la
digitalWrite(8, HIGH); //Retroilluminazione
LCD.clrScr(); //Clear LCD
LCD.setFont(SmallFont);//Set font
// ---------------------------------------------------
// -------------------SD---------------------------- // If i use sd.begin, the touch screen
bool mysd = 0; // stops working
while (!mysd) {
if (!sd.begin(SD_CHIP_SELECT, SPI_HALF_SPEED)) {
Serial.println(F("SD failed."));
Serial.println(F("Retry...."));
} else {
mysd = 1;
Serial.println(F("SD initialized."));
}
}
// ----------------------------------------------------
// -------------------Touch------------------------
Touch.InitTouch();
Touch.setPrecision(PREC_MEDIUM);
// ----------------------------------------------------
}
void loop() {
long x, y;
LCD.setColor(255, 255, 255);
LCD.print("* www.buydiplay.com Resistive touchscreen test.Please touch the screen!", CENTER, 1);
while (Touch.dataAvailable() == true) {
Touch.read();
x = Touch.getX();
y = Touch.getY();
LCD.drawPixel (x, y);
Serial.print(x);
Serial.print("\t");
Serial.println(y);
}
}
I think it's a SPI problem, i tried to enable/disable the CS pins with digitalWrite (SPI active low), but it didn't work.
Does anybody used this display? Any ideas?
Thanks
ZeroG