1

**TFTs / Re: NHD‐2.4‐240320SF‐CTXL#‐FTN1 touch-screen problem**

« **on:**December 10, 2014, 09:56:37 AM »

Thanks for your reply,

Yes I have a couple of LCDs. And yes I tried changing it. And yes it remains at the same place.

I make 5 point calibration based on TI's "Calibration in Touch Screen Systems" document.

alpha_X = -0.271

beta_X = -0.011

det_X = 268.399

alpha_Y = -0.005

beta_Y = -0.339

det_Y = 349.629

And this is the code while printing the touch points on screen

I also double checked the code.

Is this sth about the product? Or is this a special case for resistive touch screens?

Yes I have a couple of LCDs. And yes I tried changing it. And yes it remains at the same place.

I make 5 point calibration based on TI's "Calibration in Touch Screen Systems" document.

Code: [Select]

`void touch_Screen_Calibrate( void )`

{

... // 5 point calibration

}

void touch_Screen_Calibration_Calculate(int x1, int x2, int x3, int x4, int x5,

int y1, int y2, int y3, int y4, int y5)

{

double a = 0, b = 0, c = 0, d = 0, e = 0, n = 0,

X1 = 0, X2 = 0, X3 = 0, Y1 = 0, Y2 = 0, Y3 = 0,

det = 0, detX1 = 0, detX2 = 0, detX3 = 0, detY1 = 0, detY2 = 0, detY3 = 0;

a = x1*x1 + x2*x2 + x3*x3 + x4*x4 + x5*x5;

b = y1*y1 + y2*y2 + y3*y3 + y4*y4 + y5*y5;

c = x1*y1 + x2*y2+ x3*y3 + x4*y4 + x5*y5;

d = x1 + x2 + x3 + x4 + x5;

e = y1 + y2 + y3 + y4 + y5;

n = 5;

X1 = x1*CAL_POINT_X1 + x2*CAL_POINT_X2 + x3*CAL_POINT_X3 + x4*CAL_POINT_X4 + x5*CAL_POINT_X5;

X2 = y1*CAL_POINT_X1 + y2*CAL_POINT_X2 + y3*CAL_POINT_X3 + y4*CAL_POINT_X4 + y5*CAL_POINT_X5;

X3 = CAL_POINT_X1 + CAL_POINT_X2 + CAL_POINT_X3 + CAL_POINT_X4 + CAL_POINT_X5;

Y1 = x1*CAL_POINT_Y1 + x2*CAL_POINT_Y2 + x3*CAL_POINT_Y3 + x4*CAL_POINT_Y4 + x5*CAL_POINT_Y5;

Y2 = y1*CAL_POINT_Y1 + y2*CAL_POINT_Y2 + y3*CAL_POINT_Y3 + y4*CAL_POINT_Y4 + y5*CAL_POINT_Y5;

Y3 = CAL_POINT_Y1 + CAL_POINT_Y2 + CAL_POINT_Y3 + CAL_POINT_Y4 + CAL_POINT_Y5;

det = n*(a*b-c*c) + 2*c*d*e - a*e*e - b*d*d;

detX1 = n*(X1*b-X2*c) + e*(X2*d-X1*e) + X3*(c*e-b*d);

detX2 = n*(X2*a-X1*c) + d*(X1*e-X2*d) + X3*(c*d-a*e);

detX3 = X3*(a*b-c*c) + X1*(c*e-b*d) + X2*(c*d-a*e);

detY1 = n*(Y1*b-Y2*c) + e*(Y2*d-Y1*e) + Y3*(c*e-b*d);

detY2 = n*(Y2*a-Y1*c) + d*(Y1*e-Y2*d) + Y3*(c*d-a*e);

detY3 = Y3*(a*b-c*c) + Y1*(c*e-b*d) + Y2*(c*d-a*e);

alpha_X = detX1 / det;

beta_X = detX2 / det;

det_X = detX3 / det;

alpha_Y = detY1 / det;

beta_Y = detY2 / det;

det_Y = detY3 / det;

}

Then I get alpha_X = -0.271

beta_X = -0.011

det_X = 268.399

alpha_Y = -0.005

beta_Y = -0.339

det_Y = 349.629

And this is the code while printing the touch points on screen

Code: [Select]

`void debug_print_touch_points(int x_val, int y_val)`

{

...

x = ( alpha_X * (double)x_val ) + ( beta_X * (double)y_val ) + det_X;

y = ( alpha_Y * (double)x_val ) + ( beta_Y * (double)y_val ) + det_Y;

xi = (int)floor(x); yi = (int)floor(y);

Draw_One_Pixel(xi, yi, YELLOW());

}

Things are very smooth outside the "untouchable region". I can write, draw etc.I also double checked the code.

Is this sth about the product? Or is this a special case for resistive touch screens?