基於Windows CE6.0和 AK4182觸控螢幕驅動實現

來源:互聯網
上載者:User

標籤:

本驅動實現了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.

AK4182A晶片可以感知PEN DOWN事件,並且產生一個中斷訊號給CPU。CPU通過命令啟動AK4182A採樣,它會在啟動後的第4個時鐘後開始串列輸出12位的採樣資料。

3 資料擷取

    X軸或者Y軸每次從AK4182A採樣的時候,都會直接連續採樣3次,以保證每個軸的資料變化不會太劇烈。

同時在X軸採樣的時候,先計算Z軸(壓力資料)是否符合要求,不符合則將點丟棄。經驗證明,壓力值在不大於1500為宜。

 

總體上在採集3個X軸,3個Y軸資料後,送入平滑演算法。根據X軸的Delta和Y軸Delta範圍決定該資料是否符合要求,符合則被當做好點,否則被當做壞點。

 

上述原則也決定了如果我們要根據硬體的實際情況調試,則需要細緻調節:

EADC_GetADCSample 中的dwPressure 數值

TSP_EvaluateSample()演算法中的 DELTA_Y_COORD_VARIANCE/

                            DELTA_X_COORD_VARIANCE



4 SPI 介面的細節 

由於AK4182A的資料只有12位,並且不是標準的SPI介面。要求我們使用IMX51 SPI時注意:

1)可以設定SPI 的資料寬度是24位或者32位,24位比較節省時間,32位有些浪費。

2)要求CPU側發送完8個BIT後,必須不再發送資料

3)CPU側的資料接收,從CPU發送第1個BIT開始,就同步接收中,所以要對接收的資料做移位處理。

4)設定SPI的時鐘不是越高越好,由於本次螢幕解析度較高,觸控螢幕很大,15英寸,這要求一次採樣的時間不能太快,否則會導致資料精度不高。經過實際測量,在1.5ms - 2ms較為妥當。可以通過設定SPI 的時鐘來控制DCLK(即採樣速度)





基於Windows CE6.0和 AK4182觸控螢幕驅動實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.