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

📄 lhtouch.hpp

📁 完整的触摸屏驱动源程序
💻 HPP
字号:
/*--------------------------------------------------------------------------*/
// touch.hpp
//
//      Touch Driver for Sharp LH79524 using on-board ADC controller.
//  
// Author: Kenneth G. Maxwell
//
// Copyright (c) 1997-2005 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
/*--------------------------------------------------------------------------*/


typedef struct {

    volatile PEGULONG HiWord;
    volatile PEGULONG LoWord;
    volatile PEGULONG Results;
    volatile PEGULONG IntMask;
    volatile PEGULONG PowerConfig;
    volatile PEGULONG GeneralConfig;
    volatile PEGULONG GeneralStatus;
    volatile PEGULONG IntStatus;
    volatile PEGULONG FifoStatus;
    volatile PEGULONG HiWordBank[16];
    volatile PEGULONG LoWordBank[16];
    volatile PEGULONG IdleHiWord;
    volatile PEGULONG IdleLoWord;
    volatile PEGULONG MaskedIntStatus;
    volatile PEGULONG IntClear;

} ADC_REGS;

#define ADC_REG_BASE    0xfffc3000
#define ADC_CLOCK_SEL   4
#define ADC_SETTLE_TIME (0x80 << 7)
#define INT_ENABLE_CLEAR 0xfffff014
#define ADC_BITS 10
#define MAX_COUNT 1024
#define TOUCH_DETECT_VAL (MAX_COUNT / 2)

/*--------------------------------------------------------------------------*/
// TOUCH_CAL_DATA
//
// Calibration data used to convert raw ATOD values into pixel coords
/*--------------------------------------------------------------------------*/
typedef struct
{
    PEGINT      xRawMin;
    PEGINT      xRawSpan;
    PEGINT      yRawMin;
    PEGINT      yRawSpan;
    PEGINT      ScreenWidth;
    PEGINT      ScreenHeight;
    PEGINT      CenterX;
    PEGINT      CenterY;
    PEGBOOL     IsCalibrated;
    PEGBOOL     SwapAxis;

} TOUCH_CAL_DATA;

/*--------------------------------------------------------------------------*/
// indexes into TOUCH_CAL_DATA
/*--------------------------------------------------------------------------*/

#define TC_UL 0
#define TC_LL 1
#define TC_UR 2
#define TC_LR 3


/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class TouchDevice {

    public:

        TouchDevice(void);
        void Calibrate(void);
        PEGBOOL Poll(void);

    private:
        void Sleep(PEGINT iTime);
        PEGBOOL Scan(PEGINT *pRawX, PEGINT *pRawY);
        PegPoint ScaleRawVals(PEGINT RawX, PEGINT RawY);
        void WaitForTouchState(PEGBOOL WantTouch);

        PEGINT mDummy;
        PegPoint mLastPos;
        PEGBOOL mLastTouched;
        TOUCH_CAL_DATA TouchCal;
};

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class TouchMesgWin : public PegDialog
{
    public:
        TouchMesgWin(PEGINT iLeft, PEGINT iTop);
        void SetText(char *pMesg);

    private:
        PegTextBox *mpTextBox;
};




⌨️ 快捷键说明

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