Links2004 / XPT2046

XPT2046 Touch SPI driver for Arduino
GNU General Public License v2.0
3 stars 5 forks source link

Touch Calibration #1

Open robertkendrick opened 8 years ago

robertkendrick commented 8 years ago

How do you calibrate a screen using your touch library ? With the example calibration figures the errors get greater as your go from left to right. Also, if I set rotation to same number in touch and ili9341, the touch happens at opposite corner to the TFT. I have to set following to get expected correct operation: TFT.setRotation(3); touch.setRotation(1);

Links2004 commented 8 years ago

simple start with no calibration and print the raw Valus and press at the 4 edges, then use the values for your calibration.

there is a function called readRaw https://github.com/Links2004/XPT2046/blob/master/src/XPT2046.h#L44

void touchEvent(bool press, uint16_t x, uint16_t y, uint16_t z) {
    Serial.print("[Touch] press: ");
    Serial.print(press);
    Serial.print(" X: ");
    Serial.print(x);
    Serial.print(" Y: ");
    Serial.print(y);
    Serial.print(" Z: ");
    Serial.println(z);
   touch.readRaw(&x, &y, &z)
   Serial.print("[Touch] raw: ");
   Serial.print(" X: ");
   Serial.print(x);
   Serial.print(" Y: ");
   Serial.print(y);
   Serial.print(" Z: ");
   Serial.println(z);
}