Hi,those codes on our libraries can accomplish the function of “touched” locations :
[code]#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#ifdef SEEEDUINO
#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM 14 // can be a digital pin, this is A0
#define XP 17 // can be a digital pin, this is A3
#endif
#ifdef MEGA
#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM 54 // can be a digital pin, this is A0
#define XP 57 // can be a digital pin, this is A3
#endif
//Measured ADC values for (0,0) and (210-1,320-1)
//TS_MINX corresponds to ADC value when X = 0
//TS_MINY corresponds to ADC value when Y = 0
//TS_MAXX corresponds to ADC value when X = 240 -1
//TS_MAXY corresponds to ADC value when Y = 320 -1
#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940
// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// The 2.8" TFT Touch shield has 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
// a point object holds x y and z coordinates
Point p = ts.getPoint();
if (p.z > ts.pressureThreshhold) {
Serial.print("Raw X = “); Serial.print(p.x);
Serial.print(”\tRaw Y = “); Serial.print(p.y);
Serial.print(”\tPressure = "); Serial.println(p.z);
}
p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);
// we have some minimum pressure we consider ‘valid’
// pressure of 0 means no pressing!
if (p.z > ts.pressureThreshhold) {
Serial.print("X = “); Serial.print(p.x);
Serial.print(”\tY = “); Serial.print(p.y);
Serial.print(”\tPressure = "); Serial.println(p.z);
}
delay(100);
}[/code]
Did you have try it? Did you not compile it right?