Touch panel library for GR-PEACH LCD Shield.
Dependents: GR-PEACH_LCD_shield_touch_sample LCD_shield_config
TouchKey.h@1:538027089976, 2016-09-27 (annotated)
- Committer:
- dkato
- Date:
- Tue Sep 27 12:36:07 2016 +0000
- Revision:
- 1:538027089976
- Parent:
- 0:da3d7ba2674b
Add LCD type RSK TFT.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:da3d7ba2674b | 1 | /* mbed Microcontroller Library |
dkato | 0:da3d7ba2674b | 2 | * Copyright (C) 2016 Renesas Electronics Corporation. All rights reserved. |
dkato | 0:da3d7ba2674b | 3 | * |
dkato | 0:da3d7ba2674b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
dkato | 0:da3d7ba2674b | 5 | * you may not use this file except in compliance with the License. |
dkato | 0:da3d7ba2674b | 6 | * You may obtain a copy of the License at |
dkato | 0:da3d7ba2674b | 7 | * |
dkato | 0:da3d7ba2674b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
dkato | 0:da3d7ba2674b | 9 | * |
dkato | 0:da3d7ba2674b | 10 | * Unless required by applicable law or agreed to in writing, software |
dkato | 0:da3d7ba2674b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
dkato | 0:da3d7ba2674b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
dkato | 0:da3d7ba2674b | 13 | * See the License for the specific language governing permissions and |
dkato | 0:da3d7ba2674b | 14 | * limitations under the License. |
dkato | 0:da3d7ba2674b | 15 | */ |
dkato | 0:da3d7ba2674b | 16 | /**************************************************************************//** |
dkato | 0:da3d7ba2674b | 17 | * @file TouchKey.h |
dkato | 0:da3d7ba2674b | 18 | * @brief TouchKey API |
dkato | 0:da3d7ba2674b | 19 | ******************************************************************************/ |
dkato | 0:da3d7ba2674b | 20 | |
dkato | 0:da3d7ba2674b | 21 | #ifndef TOUCH_KEY_H |
dkato | 0:da3d7ba2674b | 22 | #define TOUCH_KEY_H |
dkato | 0:da3d7ba2674b | 23 | |
dkato | 0:da3d7ba2674b | 24 | #include "mbed.h" |
dkato | 0:da3d7ba2674b | 25 | |
dkato | 0:da3d7ba2674b | 26 | /** |
dkato | 0:da3d7ba2674b | 27 | * The class to acquire touch coordinates |
dkato | 0:da3d7ba2674b | 28 | */ |
dkato | 0:da3d7ba2674b | 29 | class TouchKey { |
dkato | 0:da3d7ba2674b | 30 | |
dkato | 0:da3d7ba2674b | 31 | public: |
dkato | 0:da3d7ba2674b | 32 | /** Touch position structure */ |
dkato | 0:da3d7ba2674b | 33 | typedef struct { |
dkato | 0:da3d7ba2674b | 34 | uint32_t x; /**< The position of the x-coordinate. */ |
dkato | 0:da3d7ba2674b | 35 | uint32_t y; /**< The position of the y-coordinate. */ |
dkato | 0:da3d7ba2674b | 36 | bool valid; /**< Whether a valid data.. */ |
dkato | 0:da3d7ba2674b | 37 | } touch_pos_t; |
dkato | 0:da3d7ba2674b | 38 | |
dkato | 0:da3d7ba2674b | 39 | |
dkato | 0:da3d7ba2674b | 40 | /** Create a TouchKey object |
dkato | 0:da3d7ba2674b | 41 | * |
dkato | 0:da3d7ba2674b | 42 | * @param tprst tprst pin |
dkato | 0:da3d7ba2674b | 43 | * @param tpint tpint pin |
dkato | 0:da3d7ba2674b | 44 | */ |
dkato | 0:da3d7ba2674b | 45 | TouchKey(PinName tprst, PinName tpint) : touch_reset(tprst), touch_int(tpint) { |
dkato | 0:da3d7ba2674b | 46 | } |
dkato | 0:da3d7ba2674b | 47 | |
dkato | 0:da3d7ba2674b | 48 | /** Initialization of touch panel IC |
dkato | 0:da3d7ba2674b | 49 | * |
dkato | 0:da3d7ba2674b | 50 | */ |
dkato | 0:da3d7ba2674b | 51 | void Reset(void) { |
dkato | 0:da3d7ba2674b | 52 | touch_reset = 0; |
dkato | 0:da3d7ba2674b | 53 | wait_ms(1); |
dkato | 0:da3d7ba2674b | 54 | touch_reset = 1; |
dkato | 0:da3d7ba2674b | 55 | } |
dkato | 0:da3d7ba2674b | 56 | |
dkato | 0:da3d7ba2674b | 57 | /** Attach a function to call when touch panel int |
dkato | 0:da3d7ba2674b | 58 | * |
dkato | 0:da3d7ba2674b | 59 | * @param fptr A pointer to a void function, or 0 to set as none |
dkato | 0:da3d7ba2674b | 60 | */ |
dkato | 0:da3d7ba2674b | 61 | void SetCallback(void (*fptr)(void)) { |
dkato | 0:da3d7ba2674b | 62 | touch_int.fall(fptr); |
dkato | 0:da3d7ba2674b | 63 | } |
dkato | 0:da3d7ba2674b | 64 | |
dkato | 0:da3d7ba2674b | 65 | /** Attach a member function to call when touch panel int |
dkato | 0:da3d7ba2674b | 66 | * |
dkato | 0:da3d7ba2674b | 67 | * @param tptr pointer to the object to call the member function on |
dkato | 0:da3d7ba2674b | 68 | * @param mptr pointer to the member function to be called |
dkato | 0:da3d7ba2674b | 69 | */ |
dkato | 0:da3d7ba2674b | 70 | template<typename T> |
dkato | 0:da3d7ba2674b | 71 | void SetCallback(T* tptr, void (T::*mptr)(void)) { |
dkato | 0:da3d7ba2674b | 72 | touch_int.fall(tptr, mptr); |
dkato | 0:da3d7ba2674b | 73 | } |
dkato | 0:da3d7ba2674b | 74 | |
dkato | 0:da3d7ba2674b | 75 | /** Get the maximum number of simultaneous touches |
dkato | 0:da3d7ba2674b | 76 | * |
dkato | 0:da3d7ba2674b | 77 | * @return The maximum number of simultaneous touches. |
dkato | 0:da3d7ba2674b | 78 | */ |
dkato | 0:da3d7ba2674b | 79 | virtual int GetMaxTouchNum(void) = 0; |
dkato | 0:da3d7ba2674b | 80 | |
dkato | 0:da3d7ba2674b | 81 | /** Get the coordinates |
dkato | 0:da3d7ba2674b | 82 | * |
dkato | 0:da3d7ba2674b | 83 | * @param touch_buff_num The number of structure p_touch. |
dkato | 0:da3d7ba2674b | 84 | * @param p_touch Touch position information. |
dkato | 0:da3d7ba2674b | 85 | * @return The number of touch points. |
dkato | 0:da3d7ba2674b | 86 | */ |
dkato | 0:da3d7ba2674b | 87 | virtual int GetCoordinates(int touch_buff_num, touch_pos_t * p_touch) = 0; |
dkato | 0:da3d7ba2674b | 88 | |
dkato | 0:da3d7ba2674b | 89 | private: |
dkato | 0:da3d7ba2674b | 90 | DigitalOut touch_reset; |
dkato | 0:da3d7ba2674b | 91 | InterruptIn touch_int; |
dkato | 0:da3d7ba2674b | 92 | }; |
dkato | 0:da3d7ba2674b | 93 | |
dkato | 0:da3d7ba2674b | 94 | #endif |