⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 touchpdd.cpp

📁 freescale i.mx31 BSP CE5.0全部源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        return (TouchDriverCalibrationPointGet(ptrCP));

    // Get the number of calibration points used to calibrate the touch screen.
    case TPDC_CALIBRATION_POINT_COUNT_ID:
        ptrCPC = (TPDC_CALIBRATION_POINT_COUNT*)lpOutput;
        ptrCPC->flags = 0;
        ptrCPC->cCalibrationPoints = 5;
        break;

    default:
        return FALSE;
    }

    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelGetDeviceCaps-\r\n")));
    return TRUE;
 }


//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelGetPoint
//
// This function returns the most recently acquired point and its
// associated tip state information.
//
// Parameters:
//      pTipState
//          [out] Pointer to where to return the tip state information in
//          TOUCH_PANEL_SAMPLE_FLAGS.
//
//      pUnCalX
//          [out] Pointer to where to return the x-coordinate.
//
//      pUnCalY
//          [out] Pointer to where to return the y-coordinate.
//
// Returns:
//      None.
//
//-----------------------------------------------------------------------------
void DdsiTouchPanelGetPoint(TOUCH_PANEL_SAMPLE_FLAGS *pTipStateFlags,
                            INT *pUncalX, INT *pUncalY)
{
    UINT32 CurrentDown = 0;

    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelGetPoint+\r\n")));

    // If timer IRQ is pending, we assume a pen down state
    if (BSPTouchTimerIrqQuery())
    {
        // Disable the timer (also clears pending timer interrupt)
        BSPTouchTimerDisable();

        // Signal touch IRQ processing complete
        InterruptDone(gIntrTouch);
    }

    CurrentDown = *pTipStateFlags & TouchSamplePreviousDownFlag;

    // Call TouchGetSampleADS7843 to get sample from touch controller
    *pTipStateFlags = BSPTouchGetSample(pUncalX, pUncalY);

    // Check for pen down condition
    if ((*pTipStateFlags) & TouchSampleDownFlag)
    {
        // enable touch timer (also enables timer IRQ)
        BSPTouchTimerEnable();

        if (CurrentDown)
        {
            // We must restore the TouchSamplePreviousDownFlag here to
            // be able to properly complete the calibration procedure.
            *pTipStateFlags |= TouchSamplePreviousDownFlag;
        }
    }
    // Else this must be pen up condition
    else if (CurrentDown)
    {
        // But we only want to send one pen up indication. All subsequent
        // pen up "noise" should simply be returned with "TouchSampleIgnore"
        // set so that the MDD will silently discard the readings.

        DEBUGMSG(ZONE_TIPSTATE,
            (_T("DdsiTouchPanelGetPoint:  PEN UP\r\n")));

        // Send pen up to mdd (note that we must set the valid flag or the
        // MDD will not update its internal state properly (refer to
        // CurrentDown state in tchmain.c)
        *pTipStateFlags = TouchSampleValidFlag;
    }

    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelGetPoint-\r\n")));

    return;
}


//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelPowerHandler
//
// This function indicates to the driver that the system is entering
// or leaving the suspend state.
//
// Parameters:
//      bOff
//          [in] TRUE indicates that the system is turning off. FALSE
//          indicates that the system is turning on.
//
// Returns:
//      None.
//
//-----------------------------------------------------------------------------
void DdsiTouchPanelPowerHandler(BOOL boff)
{
    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelPowerHandler+\r\n")));

    BSPTouchPowerHandler(boff);

    if (boff == TRUE)
    {
        // Set status pen power off
        gTouchPowerStatus = TouchPowerOff;
    }
    else
    {
        // Set status pen power on
        gTouchPowerStatus = TouchPowerOn;
    }

    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelPowerHandler-\r\n")));

    return;
}


//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelSetMode
//
// This function sets information about the touch screen device.
//
// Parameters:
//      iIndex
//          [in] Mode to set. The following modes can set:
//
//              TPSM_SAMPLERATE_HIGH_ID Sets the sample rate to the high rate.
//
//              TPSM_SAMPLERATE_LOW_ID Sets the sample rate to the low rate.
//
//      lpInput
//          [out] Pointer to one or more memory locations where the update
//          information resides. Points to one or more memory locations to
//          place the queried information.
//
// Returns:
//      TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL DdsiTouchPanelSetMode(INT iIndex, LPVOID  lpInput)
{
    TPDC_SAMPLE_RATE *ptrSR = (TPDC_SAMPLE_RATE*)lpInput;

    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelSetMode+\r\n")));

    if (iIndex == TPSM_SAMPLERATE_LOW_ID)
    {
        gCurSampleRate = TOUCH_SAMPLE_RATE_LOW;
        BSPTouchSetSampleRate(1000/TOUCH_SAMPLE_RATE_LOW);
        gCurSampleRateSetting = 0;
    }
    else if (iIndex == TPSM_SAMPLERATE_HIGH_ID)
    {
        gCurSampleRate = TOUCH_SAMPLE_RATE_HIGH;
        BSPTouchSetSampleRate(1000/TOUCH_SAMPLE_RATE_HIGH);
        gCurSampleRateSetting = 1;
    }
    else
        return FALSE;

    DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelSetMode-\r\n")));

    return TRUE;
}


//-----------------------------------------------------------------------------
//
// Function: TouchDriverCalibrationPointGet
//
// This function is used to get a single calibration point, in screen
// coordinates, when the input system is calibration the touch driver.
// The input system will then draw a target on the screen for the user
// to press on.
//
// Parameters:
//      lpOutput
//          [in/out] Pointer to return the calibration point.
//
// Returns:
//      TRUE indicates success, FALSE if the requested point number is
//      not available.
//
//-----------------------------------------------------------------------------
static BOOL TouchDriverCalibrationPointGet(TPDC_CALIBRATION_POINT *lpOutput)
{
    INT32 cDisplayWidth = lpOutput->cDisplayWidth;
    INT32 cDisplayHeight = lpOutput->cDisplayHeight;

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

    DEBUGMSG(ZONE_FUNCTION, (_T("TouchDriverCalibrationPointGet+")));

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

    case 1:   // Upper Left
        lpOutput->CalibrationX = CalibrationRadiusX * 2;
        lpOutput->CalibrationY = CalibrationRadiusY * 2;
        break;

    case 2:   // Lower Left
        lpOutput->CalibrationX = CalibrationRadiusX * 2;
        lpOutput->CalibrationY = cDisplayHeight - CalibrationRadiusY * 2;
        break;

    case 3:   // Lower Right
        lpOutput->CalibrationX = cDisplayWidth - CalibrationRadiusX * 2;
        lpOutput->CalibrationY = cDisplayHeight - CalibrationRadiusY * 2;
        break;

    case 4:   // Upper Right
        lpOutput->CalibrationX = cDisplayWidth - CalibrationRadiusX * 2;
        lpOutput->CalibrationY = CalibrationRadiusY * 2;
        break;

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

    DEBUGMSG(ZONE_FUNCTION, (_T("TouchDriverCalibrationPoints-\r\n")));

    return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -