校正不成功,通常表现为校准界面的五个十字架位置点了之后无法退出系统自带校准应用程序,
一般情况下是校准的误差没有满足系统定义的误差。
BOOL
ErrorAnalysis(
INT32 cCalibrationPoints, //@PARM The number of calibration points
INT32 *pScreenXBuffer, //@PARM List of screen X coords displayed
INT32 *pScreenYBuffer, //@PARM List of screen Y coords displayed
INT32 *pUncalXBuffer, //@PARM List of X coords collected
INT32 *pUncalYBuffer //@PARM List of Y coords collected
)
{
int i;
UINT32 maxErr, err;
INT32 x,y;
INT32 dx,dy;
UINT32 errThreshold = MAX_POINT_ERROR; // Can be overridden by registry entry
UINT32 status, ValType, ValLen;
HKEY regKey;
// See if there is a Maximum Calibration Error specified in the registry
status = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
__TEXT("HARDWARE\\DEVICEMAP\\TOUCH"),
0,
0,
®Key);
if ( status == ERROR_SUCCESS ) {
ValLen = sizeof(errThreshold);
status = RegQueryValueEx(
regKey,
__TEXT("MaxCalError"),
NULL,
&ValType,
(PUCHAR)&errThreshold,
&ValLen);
// We don't care what happened. Either we have a new value or we have the default value.
RegCloseKey(regKey);
}
RETAILMSG(1,(__TEXT("Maximum Allowed Error %d:\r\n"),
errThreshold));
DEBUGMSG(1,(__TEXT("Calibration Results:\r\n")));
maxErr = 0;
DEBUGMSG(1,(__TEXT(" Screen => Mapped\r\n")));
for(i=0; i<cCalibrationPoints; i++){
TouchPanelCalibrateAPoint( pUncalXBuffer[i],
pUncalYBuffer[i],
&x,
&y
);
x /= 4;
y /= 4;
DEBUGMSG(1,(__TEXT("(%4d, %4d) => (%4d, %4d)\r\n"),
pScreenXBuffer[i],
pScreenYBuffer[i],
x,
y
));
dx = x - pScreenXBuffer[i];
dy = y - pScreenYBuffer[i];
err = dx * dx + dy * dy;
if(err > maxErr){
maxErr = err;
}
}
DEBUGMSG(1,(__TEXT("Maximum error (square of Euclidean distance in screen units) = %u\r\n"),
maxErr
));
if( maxErr < (errThreshold * errThreshold) ){
return TRUE;
} else {
RETAILMSG(1,(__TEXT("Maximum error %u exceeds calibration threshold %u\r\n"),
maxErr, errThreshold
));
return FALSE;
}
}
在注册表platform.reg 有
[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\TOUCH]
"DriverName"="touch.dll"
; "MaxCalError"=dword:7
"MaxCalError"=dword:15
如果校准不通过可以把MaxCalError的值改大点试试。