hello
i have a xpt2046 touch ic on my screen and i am looking for an example that use the utouch libary.
i am looking for an example that send the x and y position from the touch ic to the serial monitor.
that only, no code for drawing things on my screen.
so can any give my an example code for what i want?
reale realy thanks to all!!
#include <UTFT.h>
#include <UTouch.h>
// ILI9325D_16 , TFT 2.8" 320x240 px
UTFT myGLCD(5,38,39,40,41);
UTouch myTouch(6,5,4,3,2);
extern uint8_t BigFont[];
int x, y;
void setup()
{
Serial.begin(9600);
myGLCD.InitLCD(LANDSCAPE);
myGLCD.clrScr();
myGLCD.fillScr(0,0,0);
myGLCD.setFont(BigFont);
myGLCD.setBackColor(0, 0, 0);
myGLCD.setColor(0, 255, 0);
myTouch.InitTouch();
myTouch.setPrecision(PREC_HI);
}
void loop()
{
while (true)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
// TFT-output
myGLCD.print("x= ", 50, 100);
myGLCD.printNumI(x, 85, 100);
myGLCD.print("y= ", 185, 100);
myGLCD.printNumI(y, 220, 100);
// Serial-output
Serial.print("x= ");
Serial.print(x);
Serial.print(" y= ");
Serial.print(y);
Serial.println(" ");
}
}
}
Enjoy your code!
realy thanks!
and can u make it that there nothing will be drawn on the tft?
so that it doesnt use any tft screen?
but thanks for your code!