touch screen handler for the microchip AR1020
touchpanel.h@6:a6971458d612, 2011-02-24 (annotated)
- Committer:
- hlipka
- Date:
- Thu Feb 24 22:05:04 2011 +0000
- Revision:
- 6:a6971458d612
- Parent:
- 4:510ea5b28a05
calibration works now
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hlipka | 0:cf4dd04052e3 | 1 | /* |
hlipka | 0:cf4dd04052e3 | 2 | * mbed AR1020 library |
hlipka | 0:cf4dd04052e3 | 3 | * Copyright (c) 2010 Hendrik Lipka |
hlipka | 0:cf4dd04052e3 | 4 | * |
hlipka | 0:cf4dd04052e3 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
hlipka | 0:cf4dd04052e3 | 6 | * of this software and associated documentation files (the "Software"), to deal |
hlipka | 0:cf4dd04052e3 | 7 | * in the Software without restriction, including without limitation the rights |
hlipka | 0:cf4dd04052e3 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
hlipka | 0:cf4dd04052e3 | 9 | * copies of the Software, and to permit persons to whom the Software is |
hlipka | 0:cf4dd04052e3 | 10 | * furnished to do so, subject to the following conditions: |
hlipka | 0:cf4dd04052e3 | 11 | * |
hlipka | 0:cf4dd04052e3 | 12 | * The above copyright notice and this permission notice shall be included in |
hlipka | 0:cf4dd04052e3 | 13 | * all copies or substantial portions of the Software. |
hlipka | 0:cf4dd04052e3 | 14 | * |
hlipka | 0:cf4dd04052e3 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
hlipka | 0:cf4dd04052e3 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
hlipka | 0:cf4dd04052e3 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
hlipka | 0:cf4dd04052e3 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
hlipka | 0:cf4dd04052e3 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
hlipka | 0:cf4dd04052e3 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
hlipka | 0:cf4dd04052e3 | 21 | * THE SOFTWARE. |
hlipka | 0:cf4dd04052e3 | 22 | */ |
hlipka | 0:cf4dd04052e3 | 23 | |
hlipka | 0:cf4dd04052e3 | 24 | #ifndef __TOUCHPANEL_H_ |
hlipka | 0:cf4dd04052e3 | 25 | #define __TOUCHPANEL_H_ |
hlipka | 0:cf4dd04052e3 | 26 | |
hlipka | 0:cf4dd04052e3 | 27 | #include "FPointer.h" |
hlipka | 0:cf4dd04052e3 | 28 | |
hlipka | 0:cf4dd04052e3 | 29 | class TouchPanel |
hlipka | 0:cf4dd04052e3 | 30 | { |
hlipka | 0:cf4dd04052e3 | 31 | public: |
hlipka | 4:510ea5b28a05 | 32 | /** |
hlipka | 4:510ea5b28a05 | 33 | initialize the controller |
hlipka | 4:510ea5b28a05 | 34 | */ |
hlipka | 0:cf4dd04052e3 | 35 | virtual void init()=0; |
hlipka | 4:510ea5b28a05 | 36 | |
hlipka | 4:510ea5b28a05 | 37 | /** |
hlipka | 4:510ea5b28a05 | 38 | read X coordinate (from last update) |
hlipka | 4:510ea5b28a05 | 39 | @returns last known X coordinate |
hlipka | 4:510ea5b28a05 | 40 | */ |
hlipka | 0:cf4dd04052e3 | 41 | virtual int x()=0; |
hlipka | 4:510ea5b28a05 | 42 | /** |
hlipka | 4:510ea5b28a05 | 43 | read Y coordinate (from last update) |
hlipka | 4:510ea5b28a05 | 44 | @returns last known Y coordinate |
hlipka | 4:510ea5b28a05 | 45 | */ |
hlipka | 0:cf4dd04052e3 | 46 | virtual int y()=0; |
hlipka | 4:510ea5b28a05 | 47 | |
hlipka | 4:510ea5b28a05 | 48 | /** |
hlipka | 4:510ea5b28a05 | 49 | @return 0 if pen is up, >0 if pen is down (maybe different due to touch pressure, if supported) |
hlipka | 4:510ea5b28a05 | 50 | */ |
hlipka | 0:cf4dd04052e3 | 51 | virtual int pen()=0; |
hlipka | 4:510ea5b28a05 | 52 | |
hlipka | 4:510ea5b28a05 | 53 | /** |
hlipka | 4:510ea5b28a05 | 54 | read coordinates on request |
hlipka | 4:510ea5b28a05 | 55 | */ |
hlipka | 0:cf4dd04052e3 | 56 | virtual void read()=0; |
hlipka | 0:cf4dd04052e3 | 57 | |
hlipka | 0:cf4dd04052e3 | 58 | class T; |
hlipka | 4:510ea5b28a05 | 59 | |
hlipka | 4:510ea5b28a05 | 60 | /** |
hlipka | 4:510ea5b28a05 | 61 | attach listener called on 'pen-down' |
hlipka | 4:510ea5b28a05 | 62 | @params item the callback object |
hlipka | 4:510ea5b28a05 | 63 | @params method the callback method |
hlipka | 4:510ea5b28a05 | 64 | */ |
hlipka | 0:cf4dd04052e3 | 65 | template<class T> |
hlipka | 0:cf4dd04052e3 | 66 | void attachPenDown(T* item, uint32_t (T::*method)(uint32_t)) { _callbackPD.attach(item, method); } |
hlipka | 4:510ea5b28a05 | 67 | /** |
hlipka | 4:510ea5b28a05 | 68 | attach listener called on 'pen-down' |
hlipka | 4:510ea5b28a05 | 69 | @params function the callback function |
hlipka | 4:510ea5b28a05 | 70 | */ |
hlipka | 0:cf4dd04052e3 | 71 | void attachPenDown(uint32_t (*function)(uint32_t)) { _callbackPD.attach(function); } |
hlipka | 4:510ea5b28a05 | 72 | /** |
hlipka | 4:510ea5b28a05 | 73 | attach listener called on 'pen-move' |
hlipka | 4:510ea5b28a05 | 74 | @params item the callback object |
hlipka | 4:510ea5b28a05 | 75 | @params method the callback method |
hlipka | 4:510ea5b28a05 | 76 | */ |
hlipka | 0:cf4dd04052e3 | 77 | template<class T> |
hlipka | 0:cf4dd04052e3 | 78 | void attachPenMove(T* item, uint32_t (T::*method)(uint32_t)) { _callbackPM.attach(item, method); } |
hlipka | 4:510ea5b28a05 | 79 | /** |
hlipka | 4:510ea5b28a05 | 80 | attach listener called on 'pen-move' |
hlipka | 4:510ea5b28a05 | 81 | @params function the callback function |
hlipka | 4:510ea5b28a05 | 82 | */ |
hlipka | 0:cf4dd04052e3 | 83 | void attachPenMove(uint32_t (*function)(uint32_t)) { _callbackPM.attach(function); } |
hlipka | 4:510ea5b28a05 | 84 | /** |
hlipka | 4:510ea5b28a05 | 85 | attach listener called on 'pen-up' |
hlipka | 4:510ea5b28a05 | 86 | @params item the callback object |
hlipka | 4:510ea5b28a05 | 87 | @params method the callback method |
hlipka | 4:510ea5b28a05 | 88 | */ |
hlipka | 0:cf4dd04052e3 | 89 | template<class T> |
hlipka | 0:cf4dd04052e3 | 90 | void attachPenUp(T* item, uint32_t (T::*method)(uint32_t)) { _callbackPU.attach(item, method); } |
hlipka | 4:510ea5b28a05 | 91 | /** |
hlipka | 4:510ea5b28a05 | 92 | attach listener called on 'pen-up' |
hlipka | 4:510ea5b28a05 | 93 | @params function the callback function |
hlipka | 4:510ea5b28a05 | 94 | */ |
hlipka | 0:cf4dd04052e3 | 95 | void attachPenUp(uint32_t (*function)(uint32_t)) { _callbackPU.attach(function); } |
hlipka | 0:cf4dd04052e3 | 96 | |
hlipka | 0:cf4dd04052e3 | 97 | protected: |
hlipka | 0:cf4dd04052e3 | 98 | FPointer _callbackPD; |
hlipka | 0:cf4dd04052e3 | 99 | FPointer _callbackPM; |
hlipka | 0:cf4dd04052e3 | 100 | FPointer _callbackPU; |
hlipka | 0:cf4dd04052e3 | 101 | }; |
hlipka | 0:cf4dd04052e3 | 102 | |
hlipka | 0:cf4dd04052e3 | 103 | |
hlipka | 0:cf4dd04052e3 | 104 | #endif |