Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of gr-peach-opencv-project-sd-card by
TouchKey.h
00001 /* mbed Microcontroller Library 00002 * Copyright (C) 2016 Renesas Electronics Corporation. All rights reserved. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 /**************************************************************************//** 00017 * @file TouchKey.h 00018 * @brief TouchKey API 00019 ******************************************************************************/ 00020 00021 #ifndef TOUCH_KEY_H 00022 #define TOUCH_KEY_H 00023 00024 #include "mbed.h" 00025 00026 /** 00027 * The class to acquire touch coordinates 00028 */ 00029 class TouchKey { 00030 00031 public: 00032 /** Touch position structure */ 00033 typedef struct { 00034 uint32_t x; /**< The position of the x-coordinate. */ 00035 uint32_t y; /**< The position of the y-coordinate. */ 00036 bool valid; /**< Whether a valid data.. */ 00037 } touch_pos_t; 00038 00039 00040 /** Create a TouchKey object 00041 * 00042 * @param tprst tprst pin 00043 * @param tpint tpint pin 00044 */ 00045 TouchKey(PinName tprst, PinName tpint) : touch_reset(tprst), touch_int(tpint) { 00046 } 00047 00048 /** Initialization of touch panel IC 00049 * 00050 */ 00051 void Reset(void) { 00052 touch_reset = 0; 00053 wait_ms(1); 00054 touch_reset = 1; 00055 } 00056 00057 /** Attach a function to call when touch panel int 00058 * 00059 * @param fptr A pointer to a void function, or 0 to set as none 00060 */ 00061 void SetCallback(void (*fptr)(void)) { 00062 touch_int.fall(fptr); 00063 } 00064 00065 /** Attach a member function to call when touch panel int 00066 * 00067 * @param tptr pointer to the object to call the member function on 00068 * @param mptr pointer to the member function to be called 00069 */ 00070 template<typename T> 00071 void SetCallback(T* tptr, void (T::*mptr)(void)) { 00072 touch_int.fall(tptr, mptr); 00073 } 00074 00075 /** Get the maximum number of simultaneous touches 00076 * 00077 * @return The maximum number of simultaneous touches. 00078 */ 00079 virtual int GetMaxTouchNum(void) = 0; 00080 00081 /** Get the coordinates 00082 * 00083 * @param touch_buff_num The number of structure p_touch. 00084 * @param p_touch Touch position information. 00085 * @return The number of touch points. 00086 */ 00087 virtual int GetCoordinates(int touch_buff_num, touch_pos_t * p_touch) = 0; 00088 00089 private: 00090 DigitalOut touch_reset; 00091 InterruptIn touch_int; 00092 }; 00093 00094 #endif
Generated on Tue Jul 12 2022 14:47:41 by
1.7.2
