touch screen handler for the microchip AR1020

touchpanel.h

Committer:
hlipka
Date:
2011-02-21
Revision:
0:cf4dd04052e3
Child:
4:510ea5b28a05

File content as of revision 0:cf4dd04052e3:

/*
* mbed AR1020 library
* Copyright (c) 2010 Hendrik Lipka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef __TOUCHPANEL_H_
#define __TOUCHPANEL_H_

#include "FPointer.h"

class TouchPanel
 {
    public:
        virtual void init()=0;
        virtual int x()=0;
        virtual int y()=0;
        virtual int pen()=0;
        virtual void read()=0;
        
        class T;
        template<class T> 
        void attachPenDown(T* item, uint32_t (T::*method)(uint32_t)) { _callbackPD.attach(item, method); }   
        void attachPenDown(uint32_t (*function)(uint32_t)) { _callbackPD.attach(function); }   
        template<class T> 
        void attachPenMove(T* item, uint32_t (T::*method)(uint32_t)) { _callbackPM.attach(item, method); }   
        void attachPenMove(uint32_t (*function)(uint32_t)) { _callbackPM.attach(function); }   
        template<class T> 
        void attachPenUp(T* item, uint32_t (T::*method)(uint32_t)) { _callbackPU.attach(item, method); }   
        void attachPenUp(uint32_t (*function)(uint32_t)) { _callbackPU.attach(function); }   
        
    protected:
        FPointer      _callbackPD;
        FPointer      _callbackPM;
        FPointer      _callbackPU;
 };


#endif