I have a Mega2560 with an ITDB02 Arduino MEGA Shield v2.0 and a ITDB02-3.2S. It all works well if I plug in the touch display while the Mega is running and the upload a sketch... But. If I power on the Mega with the display plugged in the touch functionality doesn't work. The display works fine, but the touch is all dead. Any ideas?
#include <UTFT.h>
#include <UTouch.h>
extern uint8_t BigFont[];
UTFT myGLCD(ITDB32S, 38,39,40,41);
UTouch myTouch(6,5,4,3,2);
int CallActive=0;
int x, y;
int red = 0;
int n =0;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";
void setup() {
// Initial setup
delay(100);
myGLCD.InitLCD(LANDSCAPE);
myGLCD.clrScr();
myTouch.InitTouch(LANDSCAPE);
myTouch.setPrecision(PREC_HI);
myGLCD.setFont(BigFont);
myGLCD.fillScr(0, 0, 255);
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10, 130, 310, 210);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10, 130, 310, 210);
myGLCD.setBackColor(0,0,255);
myGLCD.print("TEST2", CENTER, 147);
Serial.begin(9600);
Serial.println("StartUp");
}
void waitForIt(int x1, int y1, int x2, int y2)
{
myGLCD.setColor(255, 0, 0);
myGLCD.drawRoundRect (x1, y1, x2, y2);
while (myTouch.dataAvailable())
myTouch.read();
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (x1, y1, x2, y2);
}
void loop() {
// put your main code here, to run repeatedly:
while (true)
{
if (myTouch.dataAvailable())
{
Serial.println(n);
n=n+1;
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
Serial.println("StartCall");
if ((y>=130) && (y<=210))
{
if ((x>=10) && (x<=310))
{
waitForIt(10, 130, 310, 210);
if (CallActive==0) {
CallActive = 1;
myGLCD.setBackColor(0,0,255);
myGLCD.print("TEST", CENTER, 147);
}
}
}
}
}
}