2440+wince+7"屏触摸只有部分区域正常

zhouhongsen   2008-7-20 10:30 楼主
我使用2440配800*480 7"屏,定制系统后触摸存在问题,就是校准笔针后触摸屏只有左边部分触摸效果良好,右边笔针不准并且抖动。排除了硬件问题,因为使用光盘里images/wince5/nk.bin触摸效果完全正常,但再也找不到能达到这种效果的BSP。看起来好像效果良好区域的尺寸约有3.5",再看 smdk2440/drivers/touchp/tchpdd.cpp 中定义了几个参数
       #define TOUCH_MAX_X 960 // 950   
        #define TOUCH_MIN_X 50 // 90
        #define TOUCH_MAX_Y 900 // 960 // 910
        #define TOUCH_MIN_Y 30 // 70 //50

        #define TOUCH_X        320   
        #define TOUCH_Y        240
试着改来改去却都没有效果,请问前辈没可以从哪方面下手

回复评论 (19)

校笔做准备了吗?
点赞  2008-7-21 08:29
由于ADC的分辨率不够,小屏改大屏后,触摸屏有抖动是正常的,但是只能部分触摸应该是驱动中有些参数不对.
点赞  2008-7-21 09:03
ouyangxiu 你好啊,我们是使用相同的开发板和LCD。不知道你有没有留意我之前的帖子,触摸屏的区域问题我通过下面的修改以后已经解决了,但抖动问题仍待解决。
#define TOUCH_MAX_X 953
#define TOUCH_MIN_X 66
#define TOUCH_MAX_Y 856
#define TOUCH_MIN_Y 156

#define TOUCH_X 800    //vencent
#define TOUCH_Y 480
点赞  2008-7-21 09:12
回1楼:笔针校准过的
回cy757:试过了,没用啊
点赞  2008-7-21 09:32

6楼 fan 

触摸区域范围可以全面覆盖,说到底就是笔针不准、抖动问题
点赞  2008-7-21 09:38
在驱动下打印触摸笔的坐标呢?能看出来很乱?抖动非常大?采样值的算法怎么处理的?
点赞  2008-7-21 11:37
我和ouyangxiu使用的开发板和LCD都相同,也遇到同样的问题。我在触摸屏是驱动中的Touch_Pen_filtering函数增加RETAILMSG打印触摸屏的扑捉信息,发现AD转换的过程很正常,没有什么干扰,而且在同一个点按定不放时,打印出来的坐标也是非常相近的。就不是很明白为什么笔下的区域会有抖动。

static BOOL
Touch_Pen_filtering(INT *px, INT *py)
{
        BOOL RetVal = TRUE;
        // TRUE  : Valid pen sample
        // FALSE : Invalid pen sample
        static int count = 0;
        static INT x[2], y[2];
        INT TmpX, TmpY;
        INT dx, dy;
       
        count++;

        if (count > 2)
        { // apply filtering rule

                count = 2;
               
                // average between x,y[0] and *px,y
                TmpX = (x[0] + *px) / 2;
                TmpY = (y[0] + *py) / 2;
               
                // difference between x,y[1] and TmpX,Y
                dx = (x[1] > TmpX) ? (x[1] - TmpX) : (TmpX - x[1]);
                dy = (y[1] > TmpY) ? (y[1] - TmpY) : (TmpY - y[1]);
               
                if ((dx > FILTER_LIMIT) || (dy > FILTER_LIMIT)) {
                        // Invalid pen sample
                        *px = x[1];
                        *py = y[1]; // previous valid sample
                        RETAILMSG(1, (TEXT("Touch_Pen_filtering: Error dx=%d dy=%d\r\n"),dx,dy));                        RetVal = FALSE;
                        count = 0;
                }
                else               
                {                       
                        // Valid pen sample
                        x[0] = x[1]; y[0] = y[1];               
                        x[1] = *px; y[1] = *py; // reserve pen samples
                        //RETAILMSG(1, (TEXT("__Touch_Pen_filtering:x[0]=%d x[1]=%d *px=%d\r\n"),x[0],x[1],*px));
                        RETAILMSG(1, (TEXT("__Touch_Pen_filtering:y[0]=%d y[1]=%d *py=%d\r\n"),y[0],y[1],*py));
                        RetVal = TRUE;
                        RETAILMSG(1, (TEXT("RetVal = TRUE\r\n")));
                }
               
        } else { // till 2 samples, no filtering rule
       
                x[0] = x[1]; y[0] = y[1];               
                x[1] = *px; y[1] = *py; // reserve pen samples
               
                RetVal = FALSE;        // <- TRUE jylee 2003.03.04
        }
       
        //if (RetVal==FALSE) {
        //}
       
        return RetVal;
}
点赞  2008-7-21 11:58
引用: 引用 7 楼 cy757 的回复:
我和ouyangxiu使用的开发板和LCD都相同,也遇到同样的问题。我在触摸屏是驱动中的Touch_Pen_filtering函数增加RETAILMSG打印触摸屏的扑捉信息,发现AD转换的过程很正常,没有什么干扰,而且在同一个点按定不放时,打印出来的坐标也是非常相近的。就不是很明白为什么笔下的区域会有抖动。

static BOOL
Touch_Pen_filtering(INT *px, INT *py)
{
BOOL RetVal = TRUE;
// TRUE  : Valid pen sample
// FALSE : Invali…
点赞  2008-7-21 13:33
不好意思,不晓得怎么实现驱动下打印触摸笔的坐标。
附上touchp.cpp代码:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 2002. Samsung Electronics, co. ltd  All rights reserved.

Module Name:

  tchpdd.cpp

Abstract:

  This module contains the DDSI implementation and PDD support routines
  for the touch panel for the P2 implementation.

Functions:

  TouchDriverCalibrationPointGet
  DdsiTouchPanelGetDeviceCaps
  DdsiTouchPanelSetMode
  DdsiTouchPanelEnable
  DdsiTouchPanelDisable
  DdsiTouchPanelAttach
  DdsiTouchPanelDetach
  DdsiTouchPanelGetPoint
  DdsiTouchPanelPowerHandler

Notes:


Revision History:


--*/

#define DBGPOINTS1 1
#define TRACE_TIP_STATE

#include   
#include       
#include   
#include   
#include   
#include   
#include   
#include   
//#include   

#include   
#include         "reg.h"

#define SYS_TIMER_PRESCALER        24
#define SYS_TIMER_DIVIDER 4 // 2
//#define OEM_CLOCK_FREQ (S2440PCLK / (SYS_TIMER_PRESCALER+1) / SYS_TIMER_DIVIDER)

#define JYLEE_TEST 0
#define JYLEE_TEST1 0


#define ADC_DELAY_TIME        8000        // vencent 原5000


DWORD gIntrTouch = SYSINTR_TOUCH;
DWORD gIntrTouchChanged = SYSINTR_TOUCH_CHANGED;

#ifdef TRACE_TIP_STATE
BOOL PenIsUp = TRUE;
#endif

#if defined(MIPS) || defined(PPC821) || defined(PPC823) || defined(ARM) || defined(SH4)
#define PAGE_MASK 0x0fff
#define PAGE_SIZE 0x1000
volatile static PVOID pTmpRegs;
#endif

static void TouchPanelPowerOff();
static void TouchPanelPowerOn();
static BOOL Touch_Timer0_Setup(void) ;

static BOOL Touch_Pen_filtering(INT *px, INT *py);

// The MDD requires a minimum of MIN_CAL_COUNT consecutive samples before
// it will return a calibration coordinate to GWE.  This value is defined
// in the PDD so that each OEM can control the behaviour of the touch
// panel and still use the Microsoft supplied MDD.  Note that the extern "C"
// is required so that the variable name doesn't get decorated, and
// since we have an initializer the 'extern' is actually ignored and
// space is allocated.
extern "C" const int MIN_CAL_COUNT = 40;

INT                CurrentSampleRateSetting = 0;        //        Low sample rate setting

// @globalvar PTCHAUD_ASIC_REGISTERS | v_pTchAudAsicRegisters | Pointer to Asic regs

PTCHAUD_ASIC_REGISTERS              v_pTchAudAsicRegisters = NULL;

// @globalvar PTOUCHPANEL_POINT_SAMPLE | v_pPenSamples | Pointer to pen samples area
PDRIVER_GLOBALS      v_pDriverGlobals = NULL;

volatile static PVOID v_pCpuRegs = NULL;

TOUCH_PANEL_SAMPLE_FLAGS SampleFlags;

#ifdef CHECK_RATE
    UINT32        tmp_leds = 0x55;
#endif

// Mutex to prevent contention with audio while accessing shared registers
static HANDLE v_hTchAudMutex;

// Global flag to indicate whether we are in power handler routine, so
// we know to avoid system calls.
static BOOL bInPowerHandler = FALSE;


// Macros for aquiring semaphore for shared access to ASIC registers. If
// we are in the power handler routines, we don't need/want to aquire semaphore,
// since we are serialized at that point, and can't make any system calls.
#define TCHAUD_SEM_LOCK()  \
    if (!bInPowerHandler) { \
        DEBUGMSG(ZONE_TIPSTATE,(TEXT("TchPDD Getting semaphore...\r\n"))); \
        TchAudLock(v_hTchAudMutex, &(v_pDriverGlobals->tch.semaphore)); \
    }
#define TCHAUD_SEM_UNLOCK() \
    if (!bInPowerHandler) { \
        DEBUGMSG(ZONE_TIPSTATE,(TEXT("TchPDD Releasing semaphore...\r\n"))); \
        TchAudUnlock(v_hTchAudMutex, &(v_pDriverGlobals->tch.semaphore)); \
    }

// Macros for accessing registers on the touch audio ASIC.  The code for
// these functions is in drvlib so it can be shared between touch and audio.
#define ASIC_READ_REG(reg, pval) \
    TchAudReadReg(reg, pval, v_pTchAudAsicRegisters, bInPowerHandler)
#define ASIC_WRITE_REG(reg, val) \
    TchAudWriteReg(reg, val, v_pTchAudAsicRegisters, bInPowerHandler)
#define ASIC_AND_REG(reg, val) \
    TchAudAndReg(reg, val, v_pTchAudAsicRegisters, bInPowerHandler)
#define ASIC_OR_REG(reg, val) \
    TchAudOrReg(reg, val, v_pTchAudAsicRegisters, bInPowerHandler)


volatile IOPreg *v_pIOPregs;
volatile ADCreg *v_pADCregs;
volatile PWMreg *v_pPWMregs;
volatile INTreg *v_pINTregs;   

volatile unsigned short xbuf[10], ybuf[10];
static unsigned int touch_down = 1;

//#define ADCPRS  49        // 200Mhz
#define ADCPRS  55        // 200Mhz
//#define ADCPRS  65                // 532Mhz

/*++

Routine Description:

    Deallocates the virtual memory reserved for the Touch/Audio Asic registers,
    and the pen samples dma area.

Arguments:

    None.


Return Value:

    None.

Autodoc Information:

    @doc IN_TOUCH_DDSI INTERNAL DRIVERS PDD TOUCH_PANEL

    @func VOID | PddpTouchPanelDeallocateVm |
    Deallocates the virtual memory reserved for the Touch/Audio Asic registers,
    and the pen samples dma area.

--*/
static
void
PddpTouchPanelDeallocateVm(
    VOID
    )
{
    if(v_pIOPregs)
    {
        VirtualFree((void*)v_pIOPregs, sizeof(IOPreg), MEM_RELEASE);
        v_pIOPregs=NULL;
    }
    if(v_pADCregs)
    {   
        VirtualFree((void*)v_pADCregs, sizeof(ADCreg), MEM_RELEASE);
        v_pADCregs = NULL;
    }        
    if ( v_pDriverGlobals )
    {
        VirtualFree( v_pDriverGlobals,
                     DRIVER_GLOBALS_PHYSICAL_MEMORY_SIZE ,
                     MEM_RELEASE
                    );
        v_pDriverGlobals = NULL;
    }   
}

//
// PDD Internal Support Routines
//

/*++
    @doc IN_TOUCH_DDSI INTERNAL DRIVERS PDD TOUCH_PANEL

    @func VOID | PddpTouchPanelGetSamples |
    Copies from the pen dma area the most recent point sample into the location
    pointed to by pPointSamples.  During the copy the sample information is
    adjusted to be consistent with the 12 bit pen data format.
    Has the side effect of reinitializing ioPenPointer if we are near the
    end of the pen sample area.
--*/
static
void
PddpTouchPanelGetSamples(
    PTOUCHPANEL_POINT_SAMPLE pPointSamples //@PARM Pointer to where the samples will be stored.
    )
{
    // ULONG   devDrvPointer;
    ULONG   irg;

    //
    // Copy the samples to our buffer munging the data for the 12 bit
    //  pen data format.
    //

    for ( irg = 0; irg < NUMBER_SAMPLES_PER_POINT; irg++ )
    {
        pPointSamples[ irg ].XSample = xbuf[irg];
        pPointSamples[ irg ].YSample = ybuf[irg];
    }
}
点赞  2008-7-21 14:31
/*++

Routine Description:

    Gathers the most recent sample and evaluates the sample returing
    the determined tip state and the `best guess' for the X and Y coordinates.

    Note: Determined empirically that the variance of the X coordinate of the
          first sample from all other samples is large enough that in order
          to keep the nominal variance small, we discard the first sample.

          Cases of a light touch that locks the ADC into
          seeing X and Y coordinate samples of 0x277 regardless of how the pen
          moves or presses have been seen. XXXXX


Arguments:

    pTipState   Pointer to where the tip state information will be returned.

    pUnCalX     Pointer to where the x coordinate will be returned.

    pUnCalY     Pointer to where the y coordinate will be returned.

Return Value:

    None.

Autodoc Information:

    @doc IN_TOUCH_DDI INTERNAL DRIVERS PDD TOUCH_PANEL

    @func VOID | PddpTouchPanelEvaluateSamples |
    Gathers the most recent sample and evaluates the sample returing
    the determined tip state and the `best guess' for the X and Y coordinates.

--*/
static
void
PddpTouchPanelEvaluateSamples(
    TOUCH_PANEL_SAMPLE_FLAGS        *pSampleFlags, //@PARM Pointer to where the tip state information will be returned.
    INT                                                        *pUncalX,      //@PARM Pointer to where the x coordinate will be returned.
        INT                                                        *pUncalY       //@PARM Pointer to where the y coordinate will be returned.

    )
{
    LONG    dlXDiff0;
    LONG    dlXDiff1;
    LONG    dlXDiff2;
    LONG    dlYDiff0;
    LONG    dlYDiff1;
    LONG    dlYDiff2;

    TOUCHPANEL_POINT_SAMPLES rgPointSamples;

    //
    // Get the sample.
    //

    PddpTouchPanelGetSamples( rgPointSamples );


    //
    // Calcuate the differences for the X samples and insure that
    // the resulting number is positive.
    //

    dlXDiff0 = rgPointSamples[ 0 ].XSample - rgPointSamples[ 1 ].XSample;
    dlXDiff1 = rgPointSamples[ 1 ].XSample - rgPointSamples[ 2 ].XSample;
    dlXDiff2 = rgPointSamples[ 2 ].XSample - rgPointSamples[ 0 ].XSample;
    dlXDiff0 = dlXDiff0 > 0  ? dlXDiff0 : -dlXDiff0;
    dlXDiff1 = dlXDiff1 > 0  ? dlXDiff1 : -dlXDiff1;
    dlXDiff2 = dlXDiff2 > 0  ? dlXDiff2 : -dlXDiff2;

    //
    // Calcuate the differences for the Y samples and insure that
    // the resulting number is positive.
    //

    dlYDiff0 = rgPointSamples[ 0 ].YSample - rgPointSamples[ 1 ].YSample;
    dlYDiff1 = rgPointSamples[ 1 ].YSample - rgPointSamples[ 2 ].YSample;
    dlYDiff2 = rgPointSamples[ 2 ].YSample - rgPointSamples[ 0 ].YSample;
    dlYDiff0 = dlYDiff0 > 0  ? dlYDiff0 : -dlYDiff0;
    dlYDiff1 = dlYDiff1 > 0  ? dlYDiff1 : -dlYDiff1;
    dlYDiff2 = dlYDiff2 > 0  ? dlYDiff2 : -dlYDiff2;

    //
    // The final X coordinate is the average of coordinates of
    // the two MIN of the differences.
    //

    if ( dlXDiff0 < dlXDiff1 )
    {
        if ( dlXDiff2 < dlXDiff0 )
        {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 0 ].XSample + rgPointSamples[ 2 ].XSample ) >> 1 ) );
        }
        else
        {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 0 ].XSample + rgPointSamples[ 1 ].XSample ) >> 1 ) );
        }
    }
    else if ( dlXDiff2 < dlXDiff1 )
    {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 0 ].XSample + rgPointSamples[ 2 ].XSample ) >> 1 ) );
    }
    else
    {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 1 ].XSample + rgPointSamples[ 2 ].XSample ) >> 1 ) );
    }

    //
    //
    // The final Y coordinate is the average of coordinates of
    // the two MIN of the differences.
    //

    if ( dlYDiff0 < dlYDiff1 )
    {
        if ( dlYDiff2 < dlYDiff0 )
        {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
        }
        else
        {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 1 ].YSample ) >> 1 ) );
        }
    }
    else if ( dlYDiff2 < dlYDiff1 )
    {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
    }
    else
    {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 1 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
    }

    //
    // Validate the coordinates and set the tip state accordingly.
    //

    if ( dlXDiff0 > DELTA_X_COORD_VARIANCE ||
         dlXDiff1 > DELTA_X_COORD_VARIANCE ||
         dlXDiff2 > DELTA_X_COORD_VARIANCE ||
         dlYDiff0 > DELTA_Y_COORD_VARIANCE ||
         dlYDiff1 > DELTA_Y_COORD_VARIANCE ||
         dlYDiff2 > DELTA_Y_COORD_VARIANCE )
    {

//#ifdef DBGPOINTS1
        DEBUGMSG( ZONE_SAMPLES, (TEXT("Sample 0: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 0 ].XSample, rgPointSamples[ 0 ].YSample) );
        DEBUGMSG( ZONE_SAMPLES, (TEXT("Sample 1: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 1 ].XSample, rgPointSamples[ 1 ].YSample) );
        DEBUGMSG( ZONE_SAMPLES, (TEXT("Sample 2: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 2 ].XSample, rgPointSamples[ 2 ].YSample) );


        if ( dlXDiff0 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("XDiff0 too large 0x%x\r\n"), dlXDiff0) );
        if ( dlXDiff1 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("XDiff1 too large 0x%x\r\n"), dlXDiff1) );
        if ( dlXDiff2 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("XDiff2 too large 0x%x\r\n"), dlXDiff2) );

        if ( dlYDiff0 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("YDiff0 too large 0x%x\r\n"), dlYDiff0) );
        if ( dlYDiff1 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("YDiff1 too large 0x%x\r\n"), dlYDiff1) );
        if ( dlYDiff2 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("YDiff2 too large 0x%x\r\n"), dlYDiff2) );

//#endif // DBGPOINTS1

    }
    else
    {
        //
        // Sample is valid. Set tip state accordingly.
        //
                *pSampleFlags = TouchSampleValidFlag | TouchSampleDownFlag;
    }

    DEBUGMSG( ZONE_SAMPLES, (TEXT("Filtered - SampleFlags: 0x%x X: 0x%x Y: 0x%x\r\n"),
           *pSampleFlags, *pUncalX, *pUncalY) );

}

//
// PddpSetupPenDownIntr()
//
// Set up the UCB to give pen down interrupts.  If EnableIntr flag is set, enable
// the interrupt, otherwise, leave it disabled.  Note: - Caller must hold semaphore
// when this function is called to protect access to the shared UCB registers.
//
BOOL
PddpSetupPenDownIntr(BOOL EnableIntr)
{
        // USHORT intrMask;

    // I don't know why we enable the interrupt here.
   
   
    //
    // Setup ADC register
    //

        // kang code
    // Enable Prescaler,Prescaler,AIN5/7 fix,Normal,Disable read start,No operation
    // Down,YM:GND,YP:AIN5,XM:Hi-z,XP:AIN7,XP pullup En,Normal,Waiting for interrupt mode
        // kang code end
    // Down Int, YMON:0, nYPON:1, XMON:0;nXPON:1, Pullup:1, Auto Conv.,Waiting.
    v_pADCregs->rADCTSC =(0<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);
    //v_pADCregs->rADCTSC=(1<<3)|(1<<2);
    v_pADCregs->rADCDLY = ADC_DELAY_TIME;//default value for delay.   
    v_pADCregs->rADCCON        = (1<<14)|(ADCPRS<<6)|(7<<3);        //setup channel, ADCPRS, Touch Input

        return TRUE;

}

//
// PddpDisableClearPenDownIntr(void)
//
// Tell the UCB to clear pen down interrupts
//
点赞  2008-7-21 14:33
BOOL
PddpDisableClearPenDownIntr(void)
{
    // Acquire semaphore to prevent contention with audio driver while accessing UCB regs
    TCHAUD_SEM_LOCK();

    // Clear bit 12 in UCB address 3 to disable interrupts on falling tspx (tspx_fal_int)
    // Read data from UCB address 0x03
    if (! ASIC_AND_REG(3, ~((USHORT)0x1000)))
        goto error_return;

    // Clear the pen down interrupt
    // Write UCB address 4 bit 12 to a 0
    if (! ASIC_WRITE_REG(4, 0))
        goto error_return;

    // Write UCB address 4 bit 12 to a 1, to clear tspx interrupts
    if (! ASIC_WRITE_REG(4, 0x1000))
        goto error_return;

    TCHAUD_SEM_UNLOCK();
    return TRUE;

error_return:
    RETAILMSG(1,(TEXT("TchPdd: Error accessing UCB register!\r\n")));
    TCHAUD_SEM_UNLOCK();
    return FALSE;
}

//
// DDSI Implementation
//


//        @DOC        EX_TOUCH_DDSI EXTERNAL DRIVERS TOUCH_DRIVER
/*        @FUNC   BOOL | TouchDriverCalibrationPointGet |

Gives a single calibration point.

        @XREF
               
               
               


        @COMM

This function is called to get a single calibration point, in screen
coordinates, when the input system is calibrating the touch driver.  The input system
will then draw a target on the screen for the user to press on.

The driver may use the cDisplayX and cDisplayY to compute a coordinate.
It does not need to remember this computed value internally since it will
be passed back when the input system has collected all of the points and
calls .

*/

extern "C"
BOOL
TouchDriverCalibrationPointGet(
        TPDC_CALIBRATION_POINT        *pTCP //@PARM pointer to returned calibration point
        )
{
   
        INT32        cDisplayWidth = pTCP -> cDisplayWidth;
        INT32        cDisplayHeight = pTCP -> cDisplayHeight;

        int        CalibrationRadiusX = cDisplayWidth/20;
        int        CalibrationRadiusY = cDisplayHeight/20;

        switch (pTCP -> PointNumber)
                {
                case        0:
                        pTCP -> CalibrationX = cDisplayWidth/2;
                        pTCP -> CalibrationY = cDisplayHeight/2;
                        break;

                case        1:
                        pTCP -> CalibrationX = CalibrationRadiusX*2;
                        pTCP -> CalibrationY = CalibrationRadiusY*2;
                        break;

                case        2:
                        pTCP -> CalibrationX = CalibrationRadiusX*2;
                        pTCP -> CalibrationY = cDisplayHeight - CalibrationRadiusY*2;
                        break;

                case        3:
                        pTCP -> CalibrationX = cDisplayWidth - CalibrationRadiusX*2;
                        pTCP -> CalibrationY = cDisplayHeight - CalibrationRadiusY*2;
                        break;

                case        4:
                        pTCP -> CalibrationX = cDisplayWidth - CalibrationRadiusX*2;
                        pTCP -> CalibrationY = CalibrationRadiusY*2;
                        break;

                default:
                        pTCP -> CalibrationX = cDisplayWidth/2;
                        pTCP -> CalibrationY = cDisplayHeight/2;
                        SetLastError(ERROR_INVALID_PARAMETER);
                        return FALSE;
                       

                }
        RETAILMSG(0,(TEXT("TouchDriverCalibrationPointGet\r\n")));
        RETAILMSG(0,(TEXT("cDisplayWidth : %4X\r\n"),cDisplayWidth));
        RETAILMSG(0,(TEXT("cDisplayHeight : %4X\r\n"),cDisplayHeight));
        RETAILMSG(0,(TEXT("CalibrationRadiusX : %4d\r\n"),CalibrationRadiusX));
        RETAILMSG(0,(TEXT("CalibrationRadiusY : %4d\r\n"),CalibrationRadiusY));
        RETAILMSG(0,(TEXT("pTCP -> PointNumber : %4d\r\n"),pTCP -> PointNumber));
        RETAILMSG(0,(TEXT("pTCP -> CalibrationX : %4d\r\n"),pTCP -> CalibrationX));
        RETAILMSG(0,(TEXT("pTCP -> CalibrationY : %4d\r\n"),pTCP -> CalibrationY));
        return TRUE;
}




// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func ULONG | DdsiTouchPanelGetDeviceCaps |
//
// Queries capabilities about the physical touch panel device.
//
// @parm ULONG | iIndex |
//
// Specifies the capability to query. They are one of the following:
//
// @flag TPDC_SAMPLERATE_ID |
// The sample rate.
// @flag TPDC_CALIBRATIONPOINTS_ID |
// The X and Y coordinates used for calibration.
// @flag TPDC_CALIBRATIONDATA_ID |
// The X and Y coordinates used for calibration mapping.
//
// @parm LPVOID | lpOutput |
// Points to the memory location(s) where the queried information
// will be placed. The format of the memory referenced depends on
// the setting of iIndex. If 0, returns the number of words
// required for the output data.
//
// @rdesc
// The return values is set to the amount of information supplied and depends
// on the setting of the iIndex argument.
//
// @comm
// Implemented in the PDD.
//

extern "C"
BOOL
DdsiTouchPanelGetDeviceCaps(
        INT                iIndex,
    LPVOID  lpOutput
    )
{
        if ( lpOutput == NULL )
                {
                ERRORMSG(1, (__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
                SetLastError(ERROR_INVALID_PARAMETER);
                DebugBreak();
                return FALSE;
                }

        switch        ( iIndex )
                {
                case TPDC_SAMPLE_RATE_ID:
                                {
                                TPDC_SAMPLE_RATE        *pTSR = (TPDC_SAMPLE_RATE*)lpOutput;

                                pTSR -> SamplesPerSecondLow = TOUCHPANEL_SAMPLE_RATE_LOW;
                                pTSR -> SamplesPerSecondHigh = TOUCHPANEL_SAMPLE_RATE_HIGH;
                                pTSR -> CurrentSampleRateSetting = CurrentSampleRateSetting;
                                }
                                break;

                case TPDC_CALIBRATION_POINT_COUNT_ID:
                                {
                                TPDC_CALIBRATION_POINT_COUNT *pTCPC = (TPDC_CALIBRATION_POINT_COUNT*)lpOutput;

                                pTCPC -> flags = 0;
                                pTCPC -> cCalibrationPoints = 5;
                                }
                                break;

                case TPDC_CALIBRATION_POINT_ID:
                                return(TouchDriverCalibrationPointGet((TPDC_CALIBRATION_POINT*)lpOutput));

                default:
                                ERRORMSG(1, (__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
                                SetLastError(ERROR_INVALID_PARAMETER);
                                DebugBreak();
                                return FALSE;

                }

        return TRUE;
}



//
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func BOOL | DdsiTouchPanelSetMode |
// Sets information about the physical touch panel device.
//
// @parm ULONG | iIndex |
// Specifies the mode to set. They are one of the following:
//
// @flag TPSM_SAMPLERATE_HIGH_ID |
// Sets the sample rate to the high rate.
// @flag TPSM_SAMPLERATE_LOW_ID |
// Sets the sample rate to the low rate.
//
// @parm LPVOID | lpInput |
// Points to the memory location(s) where the update information
// resides. The format of the memory referenced depends on the
// Points to the memory location(s) where the queried information
// will be placed.
//
// @rdesc
// If the function succeeds the return value is TRUE, otherwise, it is FALSE.
//
// @comm
// Implemented in the PDD.
//

BOOL
DdsiTouchPanelSetMode(
        INT                iIndex,
    LPVOID  lpInput
    )
{
    BOOL  ReturnCode = FALSE;

    switch ( iIndex )
    {
        case TPSM_SAMPLERATE_LOW_ID:
        case TPSM_SAMPLERATE_HIGH_ID:
            SetLastError( ERROR_SUCCESS );
            ReturnCode = TRUE;
            break;

        default:
            SetLastError( ERROR_INVALID_PARAMETER );
            break;
    }


    return ( ReturnCode );
}

//
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func BOOL | DdsiTouchPanelEnable |
// Powers up and initializes the touch panel hardware for operation.
//
// @rdesc
// If the function succeeds, the return value is TRUE; otherwise, it is FALSE.
//
// @comm
// Implemented in the PDD.
//
点赞  2008-7-21 14:33
小弟刚刚解决这个问题,这是由于原bsp包的产品驱动是为低分辨率设计的,分辨率增加后,AD的抖动被放大,需要在
static BOOL
Touch_Pen_filtering(INT *px, INT *py)
{
函数中的滤波算法增加一个二次滤波就可以了

即定义一个:
#define FILTER_LIMIT2 5 //或者更小
在if ((dx > FILTER_LIMIT) ? ? (dy > FILTER_LIMIT)) {
里面做个二次滤波

具体的内容你先试着找找,
点赞  2008-8-1 22:55
mark。准备玩下QQ2440。收集资料中
点赞  2008-8-2 08:48
swaiwwb 你好,Touch_Pen_filtering函数中的“if ((dx > FILTER_LIMIT) ? ? (dy > FILTER_LIMIT))”不是已经作了过滤吗?
请问你是如何编写过滤函数的,方面把你的代码贴出来吗?
点赞  2008-8-2 09:12
gz
点赞  2008-11-13 11:35
遇到同样的问题,正头痛
点赞  2009-2-11 00:12
也遇到了同样的问题,右边校正不准!
点赞  2009-2-25 16:04
我的是800*480,7寸的;最右边点不动,把网上好心人贴的参数编译进去,结果还是如此?请问,这问题该怎么解决呢?TKS!
点赞  2009-2-25 16:13
问题解决了!
TOUCH_MIN_X 设定的值太小了
点赞  2009-2-27 15:41
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复