Go Down

Topic: ITDB02-3.2WD -Touch Not Working (Read 4596 times) previous topic - next topic

Firefox

I have a ITDB02-3.2WD - 3.2" Widescreen TFT LCD Screen Module with SD and touch screen & the ITDB02 Arduino MEGA Shield.

I have programmed it to do all the things I want except the Touch functions. I thought I would start with the the Touch calibration.

I have made the required changes to the calibration code & the libraries, the code compiles, uploads & displays the startup screen as per the picture. It says "Touch Screen to Continue" I do that but nothing happens, nothing at all. I have search through the forum but cannot find any clues to what might be wrong.

Can anyone help me?



Code: [Select]
// ITDB02_Touch_Calibration (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program can be used to calibrate the touchscreen
// of the ITDB02 modules.
// This program requires the ITDB02_Graph library (8bit mode)
// or ITDB02_Graph16 (16bit mode).
//
// It is assumed that the ITDB02 module is connected to a
// ITDB02 Shield, a ITDB02 Mega Shield or that you know how
// to change the pin numbers in the setup.
//
// Instructions will be given on the display.
//

// Remember to change the next line if you are using as 16bit module!
#include <UTFT.h>
#include <ITDB02_Touch.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

UTFT myGLCD(ITDB32WD,38,39,40,41);
ITDB02_Touch  myTouch(6,5,4,3,2);

int cx, cy;
int rx[10], ry[10];
float px, py;
int ox, oy;

void setup()
{
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);

  myTouch.InitTouch(PORTRAIT);
  myTouch.setPrecision(PREC_LOW);
}

void drawCrossHair(int x, int y)
{
  myGLCD.drawRect(x-10, y-10, x+10, y+10);
  myGLCD.drawLine(x-5, y, x+5, y);
  myGLCD.drawLine(x, y-5, x, y+5);
}

void readCoordinates()
{
  int iter = 2000;
  int cnt = 0;
  unsigned long tx=0;
  unsigned long ty=0;
  boolean OK = false;
 
  while (OK == false)
  {
    while (myTouch.dataAvailable() == false) {}
    while ((myTouch.dataAvailable() == true) && (cnt<iter))
    {
      myTouch.read();
      tx += myTouch.TP_X;
      ty += myTouch.TP_Y;
      cnt++;
    }
    if (cnt>=iter)
    {
      OK = true;
    }
    else
    {
      tx = 0;
      ty = 0;
      cnt = 0;
    }
  }

  cx = tx / iter;
  cy = ty / iter;

}

void calibrate(int x, int y, int i)
{
  myGLCD.setColor(255, 255, 255);
  drawCrossHair(x,y);
  readCoordinates();
  myGLCD.setColor(80, 80, 80);
  drawCrossHair(x,y);
 
  rx[i]=cx;
  ry[i]=cy;
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
  }
}

void waitForTouch()
{
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
  }
  while (myTouch.dataAvailable() == false) {}
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
  }
}

void startup()
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 239, 13);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.drawLine(0, 14, 239, 14);
  myGLCD.print("ITDB02 TOUCH CALIBRATION", CENTER, 1);
  myGLCD.setBackColor(0, 0, 0);
 
  myGLCD.print("INSTRUCTIONS", CENTER, 30);
  myGLCD.print("Use a stylus or something", LEFT, 50);
  myGLCD.print("similar to touch as close to", LEFT, 62);
  myGLCD.print("the center of the highlighted", LEFT, 74);
  myGLCD.print("crosshair as possible. Keep as", LEFT, 86);
  myGLCD.print("still as possible and keep", LEFT, 98);
  myGLCD.print("holding until the highlight is", LEFT, 110);
  myGLCD.print("removed. Repeat for all", LEFT, 122);
  myGLCD.print("crosshairs in sequence.", LEFT, 134);
  myGLCD.print("Further instructions will be", LEFT, 158);
  myGLCD.print("displayed when the calibration", LEFT, 170);
  myGLCD.print("is complete.", LEFT, 182);
  myGLCD.print("Do NOT use your finger as a", LEFT, 206);
  myGLCD.print("calibration stylus or the", LEFT, 218);
  myGLCD.print("result WILL BE very imprecise.", LEFT, 230);
  myGLCD.print("Touch screen to continue", CENTER, 305);

  waitForTouch();
  myGLCD.clrScr();
}

void done()
{
  myGLCD.clrScr();
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 239, 13);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.drawLine(0, 14, 239, 14);
  myGLCD.print("ITDB02 TOUCH CALIBRATION", CENTER, 1);
  myGLCD.setBackColor(0, 0, 0);
 
  myGLCD.print("CALIBRATION COMPLETE", CENTER, 30);
  myGLCD.print("To use the new calibration", LEFT, 50);
  myGLCD.print("settings you must edit the", LEFT, 62);
  myGLCD.setColor(160, 160, 255);
  myGLCD.print("ITDB02_Touch.cpp", LEFT, 74);
  myGLCD.setColor(255, 255, 255);
  myGLCD.print("file and", 136, 74);
  myGLCD.print("change the following values.", LEFT, 86);
  myGLCD.print("The values are located right", LEFT, 98);
  myGLCD.print("below the opening comment in", LEFT, 110);
  myGLCD.print("the file.", LEFT, 122);
  myGLCD.print("PixSizeX", LEFT, 158);
  myGLCD.print("PixOffsX", LEFT, 170);
  myGLCD.print("PixSizeY", LEFT, 182);
  myGLCD.print("PixOffsY", LEFT, 194);
  myGLCD.print("Connected module:", LEFT, 250);
  myGLCD.drawLine(0, 155, 239, 155);
  myGLCD.drawLine(0, 209, 239, 209);

  myGLCD.printNumF(px, 2, 100, 158);
  myGLCD.printNumI(ox, 100, 170);
  myGLCD.printNumF(py, 2, 100, 182);
  myGLCD.printNumI(oy, 100, 194);
  if (px>=0)
    myGLCD.print("2.4\"", 144, 250);
  else
  {
    if (py>=0)
    {
      myGLCD.print("3.2\"", 144, 250);
      myGLCD.print("Negative numbers for PixSizeX", LEFT, 270);
      myGLCD.print("is expected :)", LEFT, 282);
    }
    else
    {
      myGLCD.print("3.2\" Wide", 144, 250);
      myGLCD.print("Negative numbers for PixSizeX", LEFT, 270);
      myGLCD.print("and PixSizeY are expected :)", LEFT, 282);
    }
  }
}

void loop()
{
  startup();
 
  myGLCD.setColor(80, 80, 80);
  drawCrossHair(10,10);
  drawCrossHair(10,160);
  drawCrossHair(10,309);
  drawCrossHair(120,10);
  drawCrossHair(120,160);
  drawCrossHair(120,309);
  drawCrossHair(229,10);
  drawCrossHair(229,160);
  drawCrossHair(229,309);
 
  calibrate(10, 10, 0);
  calibrate(10, 160, 1);
  calibrate(10, 309, 2);
  calibrate(120, 10, 3);
  calibrate(120, 160, 4);
  calibrate(120, 309, 5);
  calibrate(229, 10, 6);
  calibrate(229, 160, 7);
  calibrate(229, 309, 8);
 
  px = ((float(rx[0]+rx[1]+rx[2])/3)-(float(rx[6]+rx[7]+rx[8])/3))/220;
  if (px>=0)
    ox = (((rx[6]+rx[7]+rx[8])/3))-(px*10);
  else
    ox = (((rx[0]+rx[1]+rx[2])/3))+(px*10);

  py = ((float(ry[0]+ry[3]+ry[6])/3)-(float(ry[2]+ry[5]+ry[8])/3))/300;
  if (py>=0)
    oy = (((ry[2]+ry[5]+ry[8])/3))-(py*10);
  else
    oy = (((ry[0]+ry[3]+ry[6])/3))+(py*10);
   

  done();
  while(true) {}
}


Firefox

It appears the Touch screen works as I stumbled on  a file (_16_9LCDTest) that has code to demonstrate handwriting on the screen. The code sets all the parameters within the code & doesn't use "#include", so at least the hardware seems fine, when you touch the screen the dots appear.

I still have no idea what is stopping the other code from working.





mitch1793

Hi there,

Im sorry i can't help but im just wondering where you got that handwriting sketch from and libraries for it?

Thanks alot
Mitch

Firefox

You got my hopes up there for a while, seems nobody knows the answer to my problem.

The libraries etc come from http://henningkarlsen.com/electronics/library.php?id=35.

I cannot find where I got the he sketch that actually works from, I think is is an old version as it has no libraries, if you want this version send me your email address and I will send it to you.

Docedison

Those displays are marketed by Itead studios. You Might go to their website and look about.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Magicj

Hi Firefox

Did you get this sorted as I am having the exact same problem. The sketch you referred to earlier works OK so, I agree, that the hardware is fine.

I have also been able to get the sketch referred to in this post working : http://arduino.cc/forum/index.php/topic,119000.0.html although there is a small error in the sketch were he displays the X axis both times - just change the last print line to display the Y co-ordinate rather than the X co-ordinate again.

My plan now is to review the sketches provided by Henning Karlsen to see if I can identify what the problem is - should be easy because the sketch in the linked post uses the same libraries  :~

Magicj

It is getting late but I think I have the answer - change the precision to PREC-MEDIUM.

It appears that PREC_LOW does not work too well  :D

I will do some further testing tomorrow night.

Firefox

Magicj

Sorry I have been asleep on the job :)

I haven't got it working, I'm pretty sure my setting is Prec_Medium. I have given up for the moment but if you have found solution I would love to know what it is.

I think there may be a conflict software wise with a Remote Control library I am using but as I am software challenged I have no idea how to test or rectify it.

Magicj

Firefox

It looks we we have the same hardware with the same problems :D

Can you try this for me...

Load the 16_9 sketch you referred to above and then load the calibration sketch - I have found that the touch panel will now work.

Assuming you have the same result, I suspect that there is something lacking in the ITDB02-Touch library initialization section. I will see if I can identify what it is, although I am still in the learning phase with some of this stuff :smiley-slim:

Firefox

Hi MagicJ

I have also found that I can get the Touch to work but only when I load as you mentioned. As soon as I try reload my code with all of the Touch coding in it nothing happens. It's too big a mental challenge for me, as far as I can tell everything is as it should be in my code.

David

Hello,

Please read another thread for this problem, it seems that I solved the issue;)
It was related to SPI reading... some delay added to give  time for settling of lines.

Hi,
I have similar problem... I have made the required changes to the calibration and changed values in UTouchCD.h.  Now the touch panel has stopped working. I restored the original file and still not working. I have a rather correct settings:
Code: [Select]
UTFT        myGLCD(ITDB32WD,38,39,40,41); 
UTouch      myTouch(6,5,4,3,2);

Is it possible that so suddenly broke?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy