2 //#ifdef TPD_HAVE_CALIBRATION
4 //#ifndef TPD_CUSTOM_CALIBRATION
6 //#if (defined(TPD_WARP_START) && defined(TPD_WARP_END))
9 int tpd_wb_start
[TPD_WARP_CNT
] = {0};
10 int tpd_wb_end
[TPD_WARP_CNT
] = {0};
12 void tpd_warp_calibrate(int *x
, int *y
) {
14 if(wx
<tpd_wb_start
[0] && tpd_wb_start
[0]>0) {
15 wx
= tpd_wb_start
[0]-((tpd_wb_start
[0]-wx
)*(tpd_wb_start
[0]-tpd_wb_end
[0])/(tpd_wb_start
[0]));
16 //wx = wx*(tpd_wb_start[0]-tpd_wb_end[0])/tpd_wb_start[0]+tpd_wb_end[0];
18 else if(wx
>tpd_wb_start
[2])
19 wx
= (wx
-tpd_wb_start
[2])*(tpd_wb_end
[2]-tpd_wb_start
[2])/(TPD_RES_X
-tpd_wb_start
[2])+tpd_wb_start
[2];
21 if(wy
<tpd_wb_start
[1] && tpd_wb_start
[1]>0)
22 wy
= tpd_wb_start
[1]-((tpd_wb_start
[1]-wy
)*(tpd_wb_start
[1]-tpd_wb_end
[1])/(tpd_wb_start
[1]));
23 //wy = wy*(tpd_wb_start[1]-tpd_wb_end[1])/tpd_wb_start[1]+tpd_wb_end[1];
24 else if(wy
>tpd_wb_start
[3] && wy
<=TPD_RES_Y
)
25 wy
= (wy
-tpd_wb_start
[3])*(tpd_wb_end
[3]-tpd_wb_start
[3])/(TPD_RES_Y
-tpd_wb_start
[3])+tpd_wb_start
[3];
31 //#define tpd_warp_calibrate(x,y)
34 void tpd_calibrate(int *x
, int *y
) {
36 if(tpd_calmat
[0]==0) for(i
=0;i
<6;i
++) tpd_calmat
[i
]=tpd_def_calmat
[i
];
37 /* ================ calibrating ================*/
38 tx
= ((tpd_calmat
[0]*(*x
))+(tpd_calmat
[1]*(*y
))+(tpd_calmat
[2]))>>12;
39 *y
= ((tpd_calmat
[3]*(*x
))+(tpd_calmat
[4]*(*y
))+(tpd_calmat
[5]))>>12;
42 if(TPD_DO_WARP
== 1) tpd_warp_calibrate(x
, y
);
43 *x
= (*x
) + ((*y
)*(*x
)*tpd_calmat
[6]/TPD_RES_X
)/TPD_RES_Y
;
44 *y
= (*y
) + ((*y
)*(*x
)*tpd_calmat
[7]/TPD_RES_X
)/TPD_RES_Y
;