hello
i want to use utouch with the ili9341 libary from adafruit but it looks like it is not realy good calibrated becouse if i create a simple drawing program that gets the x and y from the tft and then place a pixel on that place it is just drawed not on the place i pressed but ca 10 pixels less!!
code for drawing program:
#include <UTouch.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
int color = ILI9341_GREEN;
#define TFT_DC 9
#define TFT_CS 10
UTouch myTouch(6,5,4,3,2);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int x, y;
void setup()
{
x = 0;
y = 0;
Serial.begin(9600);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
myTouch.InitTouch();
myTouch.setPrecision(PREC_EXTREME);
srl = Serial.read();
}
void loop()
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if (x != 1)
{
//tft.fillCircle(x,y,4,color);
tft.drawPixel(x,y,collor);
}
Serial.print("x= ");
Serial.print(x);
Serial.print(" y= ");
Serial.print(y);
Serial.println(" ");
}
else
{
x = 0;
y = 0;
}
}
when i draw something and go to a corner it says 309 x 232 and when i go further it is outside the touch area.
so the maximum a can press is 309 x 232 and then need to calibrate it.
the thing i tried was draw a + on the screen and i need to press it.
it is placed on 150 x 150 but the screen says 141 x 143 when i press it.
so i did
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
cal_x = 150 - x;
cal_y = 150 - y;
x = 0;
y = 0;
and then every time i want the x and the y i do:
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
x += cal_x;
y += cal_y;
and when i press on x 150 and y 150 with a pencil it works!
but when i press for example on the top it does not work.
so i need to calibrate another way.
but i dont know another ways.
so how can i make a calibration thing with the adafruit ili9341 lib and utouch lib?
thanks everyone