tgsuperspec:
The UTouch lIbrary in my view uses a slightly odd method ..
I used a logic analyser to review the Texas Instrument chip used for the screen, this showed the best option seemed to be to attach the IRQ to a pin on arduino as an ege triggered interrupt. rather than use the polll techniues and read while low.
The spec on the chip also highlighted that although its 12 bit resolution to ensure next value availability you should clear the buffer register by clocking 16 bits through, from memory the UTouch library only does 12
You tend to get a ghosting interrupt generated at removal of touch which if your polling will cause extra invalid readings.
4 I run a moving average on data during a touch event.
Calibration is difficult on smaller displays if you google cailibrartion algorithms for TFT touch, the matrix solution always comes out best but
/// a.. On 3,2 its a bit overkill
// b. The maths is difficult to program
The UTouch Library solution is fair, but holding the pointer still whilst sampling for a series of locations I find difficult, my customers founmd impossible.
Rewrote the calibration to cycle defined points round screen to acieve am average Y for TOP, BOTTOM and average x for LEFT, RIGHT with that and some simple maths can scale any touch sample read to be position on screen
Currently can specify down to 8 x 8 Icon on screen and with stylas touch detecy position. With finger touch use 16 x 16 Icon
Happy coding
HazardsMind:
You can subtract 320 from the getX() value you have now.
I tried,
But not thing changed
I don't know how to fix
You can send me a example code that can fix that error, tks all.
HazardsMind:
I was under the impression you had a 240x320 screen, But you have a 240x400 screen. So instead of subtracting 320, you need to subtract 400.
Where did you download your library from, can you provide a link. The values that are shown on screen fit where you touched the screen, but the display is off. I think the screen is set to 240x400, but the touchpad is set to 240x320. This would explain why when you touch the edge of the screen, you see 319, but the dot only goes 4/5 the way.
You need to calibrate your display / touch ratio and fix the CAL_X and CAL_Y values in the UTouchCD.h file.
HazardsMind:
Where did you download your library from, can you provide a link. The values that are shown on screen fit where you touched the screen, but the display is off. I think the screen is set to 240x400, but the touchpad is set to 240x320. This would explain why when you touch the edge of the screen, you see 319, but the dot only goes 4/5 the way.
You need to calibrate your display / touch ratio and fix the CAL_X and CAL_Y values in the UTouchCD.h file.
while (myTouch.dataAvailable() == true)
{
myTouch.read();
test = 310-x;
x = myTouch.getX();
y = myTouch.getY();
if ((x!=-1) and (y!=-1))
{
myGLCD.clrScr();
myGLCD.print("o", 310-x+test/5.5,y-6,0);
myGLCD.printNumI(310-x+test/5.5, CENTER, 0); //X axis
myGLCD.printNumI(y-6, CENTER, 16); //Y axis
}
}
HazardsMind:
You shouldn't have to divide anything by 5.5, if the screen / touch ratio is correct, the code will already do it for you.
I found it
// UTouchCD.h
// ----------
//
// Since there are slight deviations in all touch screens you should run a
// calibration on your display module. Run the UTouch_Calibration sketch
// that came with this library and follow the on-screen instructions to
// update this file.
//
// Remember that is you have multiple display modules they will probably
// require different calibration data so you should run the calibration
// every time you switch to another module.
// You can, of course, store calibration data for all your modules here
// and comment out the ones you dont need at the moment.
//
// These calibration settings works with my ITDB02-3.2S.
// They MIGHT work on your display module, but you should run the
// calibration sketch anyway. #define CAL_X 0x00378F66UL #define CAL_Y 0x03C34155UL #define CAL_S 0x000EF13FUL
Your using the UTFT and UTouch libraries, you should be able to run the calibration sketch. Attached is the calibration sketch, You may need to change a few lines to get it to work, like you pin numbers and model.