Igel_CO2
Embed:
(wiki syntax)
Show/hide line numbers
FT5206.h
00001 // FT5206.h für FT5206.cpp 00002 // Roland Fuchs 00003 00004 #include "mbed.h" 00005 /* 00006 //-- Tastatur 00007 #define Hoch 20 00008 #define Tief 21 00009 #define Rechts 22 00010 #define Links 23 00011 #define Ja 24 00012 #define Weg 25 00013 */ 00014 struct Tip 00015 { 00016 int x[5]; 00017 int y[5]; 00018 }; // 40 Bytes 00019 00020 00021 void init_FT5206(); 00022 int getTip5(Tip*); 00023 int getTip(int *x,int *y); 00024 int getTipPoll(int *x,int *y); 00025 void getTipWait(int ms); 00026 00027 void tip_irq_ein(); 00028 void tip_irq_aus(); 00029 00030 void writeReg8(char reg,char val); 00031 char readReg8(char reg); 00032 int readReg16(char reg); 00033 00034 00035 /** This is a library to handling capacitive multitouch sensors using FT5206. 00036 * FT5206 Capatitive Touch Panel driver for 7 inch BuyDisplay LCD, with 5-point touch 00037 * http://www.buydisplay.com/default/7-inch-lcd-module-capacitive-touch-screen-panel-i2c-spi-serial 00038 * 00039 * Example: 00040 * @code 00041 * // Use of the capacitive touch panel 00042 * #define PIN_SCL_FT5206 D15 00043 * #define PIN_SDA_FT5206 D14 00044 * #define PIN_INT_FT5206 D7 00045 * FT5206 FT5206(PIN_SDA_FT5206, PIN_SCL_FT5206, PIN_INT_FT5206); // sda, scl, int 00046 * FT5206.init(); 00047 * while(1) 00048 * { 00049 * if(FT5206.getPanelTouched()) 00050 * { 00051 * for (int i = 0; i < FT5206.numberOfTouchPoints; i++) 00052 * printf("Coord %d: %d, %d \r\n", i+1, FT5206.touchCoordinatesX[i], FT5206.touchCoordinatesY[i]); 00053 * } 00054 * } 00055 * @endcode 00056 * 00057 */ 00058 00059 /* 00060 #define DEBUG_OUTPUT_ENABLED false 00061 #define FT5206_I2C_FREQUENCY 400000 00062 00063 // FT5206 definitions 00064 #define FT5206_I2C_ADDRESS 0x38 00065 #define FT5206_NUMBER_OF_REGISTERS 31 // there are more registers, but this 00066 // is enought to get all 5 touch coordinates. 00067 00068 #define FT5206_NUMBER_OF_TOTAL_REGISTERS 0xFE 00069 00070 #define FT5206_DEVICE_MODE 0x00 00071 #define FT5206_GEST_ID 0x01 00072 00073 #define TD_STATUS 0x02 // How many points detected (3:0). 1-5 is valid. 00074 00075 #define TOUCH1_XH 0x03 // Event Flag, Touch X Position 00076 #define TOUCH1_XL 0x04 00077 #define TOUCH1_YH 0x05 // Touch ID, Touch Y Position 00078 #define TOUCH1_YL 0x06 00079 00080 #define TOUCH2_XH 0x09 // Event Flag, Touch X Position 00081 #define TOUCH2_XL 0x0a 00082 #define TOUCH2_YH 0x0b // Touch ID, Touch Y Position 00083 #define TOUCH2_YL 0x0c 00084 00085 #define TOUCH3_XH 0x0f // Event Flag, Touch X Position 00086 #define TOUCH3_XL 0x10 00087 #define TOUCH3_YH 0x11 // Touch ID, Touch Y Position 00088 #define TOUCH3_YL 0x12 00089 00090 #define TOUCH4_XH 0x15 // Event Flag, Touch X Position 00091 #define TOUCH4_XL 0x16 00092 #define TOUCH4_YH 0x17 // Touch ID, Touch Y Position 00093 #define TOUCH4_YL 0x18 00094 00095 #define TOUCH5_XH 0x1b // Event Flag, Touch X Position 00096 #define TOUCH5_XL 0x1c 00097 #define TOUCH5_YH 0x1d // Touch ID, Touch Y Position 00098 #define TOUCH5_YL 0x1e 00099 00100 #define FT5206_ID_G_THGROUP 0x80 // Valid touching detect threshold 00101 #define FT5206_ID_G_THPEAK 0x81 // Valid touching peak detect threshold 00102 #define FT5206_ID_G_THCAL 0x82 // The threshold when calculating the focus of touching 00103 #define FT5206_ID_G_THWATER 0x83 // The threshold when there is surface water 00104 #define FT5206_ID_G_THTEMP 0x84 // The threshold of temperature compensation 00105 #define FT5206_ID_G_CTRL 0x86 // Power control mode 00106 #define FT5206_ID_G_TIME_ENTER_MONITOR 0x87 // The timer of entering monitor status 00107 #define FT5206_ID_G_PERIODACTIVE 0x88 // Period Active 00108 #define FT5206_ID_G_PERIODMONITOR 0x89 // The timer of entering idle while in monitor status 00109 #define FT5206_ID_G_AUTO_CLB_MODE 0xA0 // Auto calibration mode 00110 00111 #define FT5206_TOUCH_LIB_VERSION_H 0xA1 // Firmware Library Version H byte 00112 #define FT5206_TOUCH_LIB_VERSION_L 0xA2 // Firmware Library Version L byte 00113 #define FT5206_ID_G_CIPHER 0xA3 // Chip vendor ID 00114 #define FT5206_G_MODE 0xA4 // The interrupt status to host 00115 #define FT5206_ID_G_PMODE 0xA5 // Power Consume Mode 00116 #define FT5206_FIRMID 0xA6 // Firmware ID 00117 #define FT5206_ID_G_STATE 0xA7 // Running State 00118 #define FT5206_ID_G_FT5201ID 0xA8 // CTPM Vendor ID 00119 #define FT5206_ID_G_ERR 0xA9 // Error Code 00120 #define FT5206_ID_G_CLB 0xAA // Configure TP module during calibration in Test Mode 00121 #define FT5206_ID_G_B_AREA_TH 0xAE // The threshold of big area 00122 #define FT5206_LOG_MSG_CNT 0xFE // The log MSG count 00123 #define FT5206_LOG_CUR_CHA 0xFF // Current character of log message, will point to the next 00124 // character when one character is read. 00125 00126 #define FT5206_GEST_ID_MOVE_UP 0x10 00127 #define FT5206_GEST_ID_MOVE_LEFT 0x14 00128 #define FT5206_GEST_ID_MOVE_DOWN 0x18 00129 #define FT5206_GEST_ID_MOVE_RIGHT 0x1c 00130 #define FT5206_GEST_ID_ZOOM_IN 0x48 00131 #define FT5206_GEST_ID_ZOOM_OUT 0x49 00132 #define FT5206_GEST_ID_NO_GESTURE 0x00 00133 00134 #define FT5206_EVENT_FLAG_PUT_DOWN 0x00 00135 #define FT5206_EVENT_FLAG_PUT_UP 0x01 00136 #define FT5206_EVENT_FLAG_CONTACT 0x02 00137 #define FT5206_EVENT_FLAG_RESERVED 0x03 00138 00139 #define FT5206_ID_G_POLLING_MODE 0x00 00140 #define FT5206_ID_G_TRIGGER_MODE 0x01 00141 00142 #define FT5206_ID_G_PMODE_ACTIVE 0x00 00143 #define FT5206_ID_G_PMODE_MONITOR 0x01 00144 #define FT5206_ID_G_PMODE_HIBERNATE 0x03 00145 00146 #define FT5206_ID_G_STATE_CONFIGURE 0x00 00147 #define FT5206_ID_G_STATE_WORK 0x01 00148 #define FT5206_ID_G_STATE_CALIBRATION 0x02 00149 #define FT5206_ID_G_STATE_FACTORY 0x03 00150 #define FT5206_ID_G_STATE_AUTO_CALIBRATION 0x04 00151 00152 class FT5206 00153 { 00154 public: 00155 FT5206(PinName sda, PinName scl, PinName interrupt); 00156 00157 void init(); 00158 int getTouchPositions(); 00159 void intPanelTouched(); 00160 bool getPanelTouched(); 00161 00162 int tipanz;//numberOfTouchPoints; 00163 int tipx[5];//touchCoordinatesX[5]; 00164 int tipy[5];//touchCoordinatesY[5]; 00165 00166 private: 00167 InterruptIn m_interrupt; 00168 00169 I2C m_i2c; 00170 //int m_addr; 00171 char data[2]; 00172 00173 bool debug_output_enabled; 00174 bool panelTouched; 00175 void writeRegister8(char reg, char val); 00176 char readRegister8(char reg); 00177 00178 }; 00179 */
Generated on Sun Jul 31 2022 17:58:53 by
1.7.2