基于Windows CE6.0和 AK4182触摸屏驱动实现

本驱动实现了FreescaleImx515平台下的AK4182A 触摸屏采样功能。通过在WINDOWS CE平台上按照WINDOWS CE TOUCH DDSI 接口标准完成了所有的12 bit精度的数据采样功能。

该驱动实现了一个标准的WINDOWS CE 触摸屏驱动,使用中断(Interrupt)实现PEN DOWN 检测,通过定时器(Timer)中断采集Pen Move数据,并同时判断是否PEN UP状态。在此过程中,会通过点过滤算法和压力检测算法去除杂点和平滑,最后有效的原始位置数据会发给WINDOWS CE 高层接口进行屏幕校正处理。

该驱动完成了如下硬件条件下的采样:

l PEN DOWN中断支持

l IMX515 SPI接口

l 12BIT采样

l 屏幕分辨率1024*768

l 四线电阻式触摸屏

l 压力检测支持

1、Windows CE 6触摸屏驱动模型1.1 整体模型

触摸屏驱动读取用户触摸数据,并将其转换为内部格式发送给windowsce系统的GWES。驱动要负责把采样的原始输入数据(uncalibrated raw coordinates)转换为校正后的输入数据(calibrated coordinates)。

用户点触触摸屏幕,会产生PEN DOWN 中断。该中断激活触摸屏驱动的自动采样例程,该例程可以定时采样数据和用户PENUP事件,并将最后校正好的数据发送给GWES,从而让GWES能够获取用户位置并显示出来。

模型逻辑图示如下。

驱动模型分为MDD层和PDD层。

MDD层负责和GWES接口,并完成校正算法和屏幕校正等相关工作。

PDD层负责具体的PEN DOWN、PEN UP中断响应、数据采样、压力感应和算法平滑等相关工作。

1.2 模型数据接口定义

n 数据有效性说明

enum enumTouchPanelSampleFlags {

TouchSampleValidFlag = 0x01, (该采样点有效)

TouchSampleDownFlag = 0x02, (PEN 状态,与采样点状态“或”上后通知高层)

TouchSampleIsCalibratedFlag = 0x04,

TouchSamplePreviousDownFlag = 0x08,

TouchSampleIgnore = 0x10,(无效点状态)

TouchSampleMouse = 0x40000000

};

n Touch驱动的MDD层接口

Thefollowing table shows the touch screen driver functions.

Programming element

Description

ErrorAnalysis

This function provides information on the accuracy of the touch screen calibration.

TouchCalibrate

This function starts the touch screen calibration sequence.

TouchPanelCalibrateAPoint

This function converts noncalibrated points to calibrated points.

TouchPanelDisable

This function disables the touch screen.

TouchPanelEnable

This function enables and re-enables the touch screen.

TouchPanelGetDeviceCaps

This function returns information about the capabilities of the touch screen.

TouchPanelInitializeCursor

This function provides an opportunity for touch drivers to move the cursor at initialization time.

TouchPanelPowerHandler

This function handles power-state change notifications.

TouchPanelReadCalibrationAbort

This function aborts the currently active call to theTouchPanelCalibrateAPoint function.

TouchPanelReadCalibrationPoint

This function initiates the process of getting a calibration point.

TouchPanelSetCalibration

This function initializes calibration information in a global parametervCalcParam, which you can use to convert noncalibrated points to calibrated points by theTouchPanelCalibrateAPoint function.

TouchPanelSetMode

This function sets mode information for a touch screen device.

n Touch 驱动的PDD层接口

Programming element

Description

DdsiTouchPanelAttach

This function executes when the MDD’s DLL entry point receives a DLL_PROCESS_ATTACH message.

DdsiTouchPanelDetach

This function executes when the MDD’s DLL entry point receives a DLL_PROCESS_DETACH message.

DdsiTouchPanelDisable

This function disables the touch screen device.

DdsiTouchPanelEnable

This function applies power to the touch screen device and initializes it for operation.

DdsiTouchPanelGetDeviceCaps

This function queries capabilities of the touch screen device.

DdsiTouchPanelGetPoint

This function returns the most recently acquired point and its associated tip state information.

DdsiTouchPanelPowerHandler

This function indicates to the driver that the system is entering or leaving the suspend state.

DdsiTouchPanelSetMode

This function sets information about the touch screen device.

n 数据精度要求

值得注意的是Windows CE 要求传递的校验后的坐标信息是最靠近像素点的四分之一像素。

1.3 平滑算法

WINDOWS CE不限制采样点怎么做平滑,由各个OEM厂商去实现。

具体算法可以有:

1)三点平均

2)三点比较,取最近的做平均

。。。。。。

1.4 校正算法

WINDOWS CE实现了最重要的校正算法,该校正算法可以实现屏幕旋转、不同尺寸的非线性处理工作。

具体可以参看如下目录:

iMX51-EVK\SRC\DRIVERS\Touchp\Mdd\Calibrate

2、AK4182A 基本原理

AK4182A芯片是一款四线电阻屏触摸控制器,它最高支持125khz的采样率,输出的数据宽度是12bit.

大海,别为森林的渺小而沮丧,

基于Windows CE6.0和 AK4182触摸屏驱动实现

相关文章:

你感兴趣的文章:

标签云: