source: azure_iot_hub_f767zi/trunk/asp_baseplatform/gdic/stts_ft5336/stts_ft5336.c@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 19.9 KB
Line 
1/*
2 * TOPPERS BASE PLATFORM MIDDLEWARE
3 *
4 * Copyright (C) 2017-2018 by TOPPERS PROJECT
5 * Educational Working Group.
6 *
7 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
8 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12 * スコード中に含まれていること.
13 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16 * の無保証規定を掲載すること.
17 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19 * と.
20 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
22 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23 * 報告すること.
24 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28 * 免責すること.
29 *
30 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34 * の責任を負わない.
35 *
36 * @(#) $Id$
37 */
38/**
39 ******************************************************************************
40 * @attention
41 *
42 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
43 *
44 * Redistribution and use in source and binary forms, with or without modification,
45 * are permitted provided that the following conditions are met:
46 * 1. Redistributions of source code must retain the above copyright notice,
47 * this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright notice,
49 * this list of conditions and the following disclaimer in the documentation
50 * and/or other materials provided with the distribution.
51 * 3. Neither the name of STMicroelectronics nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
56 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
58 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
61 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
62 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
63 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65 *
66 ******************************************************************************
67 */
68
69#include <string.h>
70#include "stts_ft5336.h"
71
72/**
73 * @brief Reads a single data.
74 * @param Addr: I2C address
75 * @param Reg: Reg address
76 * @retval Data to be read
77 */
78static uint8_t
79ft5336_IO_Read(TouchScreen_Handle_t *hts, uint8_t Reg)
80{
81 I2C_Init_t Init;
82 uint8_t read_value = 0;
83 ER ercd = E_OK;
84
85 ercd = i2c_memread(hts->hi2c, hts->I2C_Address, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &read_value, 1, 1000);
86
87 /* Check the communication status */
88 if(ercd != E_OK){
89 /* De-initialize the I2C communication bus */
90 i2c_deinit(hts->hi2c);
91
92 /* Re-Initialize the I2C communication bus */
93 memcpy(&Init, &hts->hi2c->Init, sizeof(I2C_Init_t));
94 i2c_init(hts->hi2c->i2cid, &Init);
95 }
96 return read_value;
97}
98
99/**
100 * @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
101 * able to read the FT5336 device ID, and verify this is a FT5336.
102 * @param DeviceAddr: I2C FT5336 Slave address.
103 * @retval The Device ID (two bytes).
104 */
105static uint16_t
106ft5336_ReadID(TouchScreen_Handle_t *hts, uint16_t DeviceAddr)
107{
108 volatile uint8_t ucReadId = 0;
109 uint8_t nbReadAttempts = 0;
110 uint8_t bFoundDevice = 0; /* Device not found by default */
111
112 hts->I2C_Address = DeviceAddr;
113 /* At maximum 4 attempts to read ID : exit at first finding of the searched device ID */
114 for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++){
115 /* Read register FT5336_CHIP_ID_REG as DeviceID detection */
116 ucReadId = ft5336_IO_Read(hts, FT5336_CHIP_ID_REG);
117
118 /* Found the searched device ID ? */
119 if(ucReadId == FT5336_ID_VALUE){
120 /* Set device as found */
121 bFoundDevice = 1;
122 }
123 }
124 return (ucReadId);
125}
126
127/**
128 * @brief Configure the FT5336 device to stop generating IT on the given INT pin
129 * connected to MCU as EXTI.
130 * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
131 * @retval None
132 */
133static void
134ft5336_TS_DisableIT(TouchScreen_Handle_t *hts)
135{
136 ER ercd = E_OK;
137 uint8_t regValue = 0;
138 regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
139
140 /* Set interrupt polling mode in FT5336_GMODE_REG */
141 ercd = i2c_memwrite(hts->hi2c, hts->I2C_Address, FT5336_GMODE_REG, I2C_MEMADD_SIZE_8BIT, &regValue, 1, 1000);
142 if(ercd != E_OK)
143 syslog_1(LOG_ERROR, "ft5336_TS_DisableIT I2C write error(%d) !", ercd);
144}
145
146/**
147 * @brief Return if there is touches detected or not.
148 * Try to detect new touches and forget the old ones (reset internal global
149 * variables).
150 * @param DeviceAddr: Device address on communication Bus.
151 * @retval : Number of active touches detected (can be 0, 1 or 2).
152 */
153static uint8_t
154ft5336_TS_DetectTouch(TouchScreen_Handle_t *hts)
155{
156 volatile uint8_t nbTouch = 0;
157
158 /* Read register FT5336_TD_STAT_REG to check number of touches detection */
159 nbTouch = ft5336_IO_Read(hts, FT5336_TD_STAT_REG);
160 nbTouch &= FT5336_TD_STAT_MASK;
161
162 if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH){
163 /* If invalid number of touch detected, set it to zero */
164 nbTouch = 0;
165 }
166
167 /* Update ft5336 driver internal global : current number of active touches */
168 hts->currActiveTouchNb = nbTouch;
169
170 /* Reset current active touch index on which to work on */
171 hts->currActiveTouchIdx = 0;
172 return(nbTouch);
173}
174
175/**
176 * @brief Get the touch screen X and Y positions values
177 * Manage multi touch thanks to touch Index global
178 * variable 'TouchScreen_Handle.currActiveTouchIdx'.
179 * @param DeviceAddr: Device address on communication Bus.
180 * @param X: Pointer to X position value
181 * @param Y: Pointer to Y position value
182 * @retval None.
183 */
184static void
185ft5336_TS_GetXY(TouchScreen_Handle_t *hts, uint16_t *X, uint16_t *Y)
186{
187 volatile uint8_t ucReadData = 0;
188 static uint16_t coord;
189 uint8_t regAddressXLow = 0;
190 uint8_t regAddressXHigh = 0;
191 uint8_t regAddressYLow = 0;
192 uint8_t regAddressYHigh = 0;
193
194 if(hts->currActiveTouchIdx < hts->currActiveTouchNb){
195 switch(hts->currActiveTouchIdx){
196 case 0:
197 regAddressXLow = FT5336_P1_XL_REG;
198 regAddressXHigh = FT5336_P1_XH_REG;
199 regAddressYLow = FT5336_P1_YL_REG;
200 regAddressYHigh = FT5336_P1_YH_REG;
201 break;
202 case 1:
203 regAddressXLow = FT5336_P2_XL_REG;
204 regAddressXHigh = FT5336_P2_XH_REG;
205 regAddressYLow = FT5336_P2_YL_REG;
206 regAddressYHigh = FT5336_P2_YH_REG;
207 break;
208 case 2:
209 regAddressXLow = FT5336_P3_XL_REG;
210 regAddressXHigh = FT5336_P3_XH_REG;
211 regAddressYLow = FT5336_P3_YL_REG;
212 regAddressYHigh = FT5336_P3_YH_REG;
213 break;
214 case 3:
215 regAddressXLow = FT5336_P4_XL_REG;
216 regAddressXHigh = FT5336_P4_XH_REG;
217 regAddressYLow = FT5336_P4_YL_REG;
218 regAddressYHigh = FT5336_P4_YH_REG;
219 break;
220 case 4:
221 regAddressXLow = FT5336_P5_XL_REG;
222 regAddressXHigh = FT5336_P5_XH_REG;
223 regAddressYLow = FT5336_P5_YL_REG;
224 regAddressYHigh = FT5336_P5_YH_REG;
225 break;
226 case 5:
227 regAddressXLow = FT5336_P6_XL_REG;
228 regAddressXHigh = FT5336_P6_XH_REG;
229 regAddressYLow = FT5336_P6_YL_REG;
230 regAddressYHigh = FT5336_P6_YH_REG;
231 break;
232 case 6:
233 regAddressXLow = FT5336_P7_XL_REG;
234 regAddressXHigh = FT5336_P7_XH_REG;
235 regAddressYLow = FT5336_P7_YL_REG;
236 regAddressYHigh = FT5336_P7_YH_REG;
237 break;
238 case 7:
239 regAddressXLow = FT5336_P8_XL_REG;
240 regAddressXHigh = FT5336_P8_XH_REG;
241 regAddressYLow = FT5336_P8_YL_REG;
242 regAddressYHigh = FT5336_P8_YH_REG;
243 break;
244 case 8:
245 regAddressXLow = FT5336_P9_XL_REG;
246 regAddressXHigh = FT5336_P9_XH_REG;
247 regAddressYLow = FT5336_P9_YL_REG;
248 regAddressYHigh = FT5336_P9_YH_REG;
249 break;
250 case 9:
251 regAddressXLow = FT5336_P10_XL_REG;
252 regAddressXHigh = FT5336_P10_XH_REG;
253 regAddressYLow = FT5336_P10_YL_REG;
254 regAddressYHigh = FT5336_P10_YH_REG;
255 break;
256 default:
257 break;
258
259 } /* end switch(TouchScreen_Handle.currActiveTouchIdx) */
260
261 /* Read low part of X position */
262 ucReadData = ft5336_IO_Read(hts, regAddressXLow);
263 coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
264
265 /* Read high part of X position */
266 ucReadData = ft5336_IO_Read(hts, regAddressXHigh);
267 coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
268
269 /* Send back ready X position to caller */
270 *X = coord;
271
272 /* Read low part of Y position */
273 ucReadData = ft5336_IO_Read(hts, regAddressYLow);
274 coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
275
276 /* Read high part of Y position */
277 ucReadData = ft5336_IO_Read(hts, regAddressYHigh);
278 coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
279
280 /* Send back ready Y position to caller */
281 *Y = coord;
282
283 hts->currActiveTouchIdx++; /* next call will work on next touch */
284 } /* of if(TouchScreen_Handle.currActiveTouchIdx < TouchScreen_Handle.currActiveTouchNb) */
285}
286
287
288/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
289
290#if (TS_MULTI_TOUCH_SUPPORTED == 1)
291/**
292 * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
293 * This touch detailed information contains :
294 * - weight that was applied to this touch
295 * - sub-area of the touch in the touch panel
296 * - event of linked to the touch (press down, lift up, ...)
297 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
298 * @param touchIdx : Passed index of the touch (0..1) on which we want to get the
299 * detailed information.
300 * @param pWeight : Pointer to to get the weight information of 'touchIdx'.
301 * @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
302 * @param pEvent : Pointer to to get the event information of 'touchIdx'.
303
304 * @retval None.
305 */
306static void
307ft5336_TS_GetTouchInfo(TouchScreen_Handle_t *hts, uint32_t touchIdx, uint32_t *pWeight, uint32_t *pArea, uint32_t *pEvent)
308{
309 volatile uint8_t ucReadData = 0;
310 uint8_t regAddressXHigh = 0;
311 uint8_t regAddressPWeight = 0;
312 uint8_t regAddressPMisc = 0;
313
314 if(touchIdx < hts->currActiveTouchNb){
315 switch(touchIdx){
316 case 0:
317 regAddressXHigh = FT5336_P1_XH_REG;
318 regAddressPWeight = FT5336_P1_WEIGHT_REG;
319 regAddressPMisc = FT5336_P1_MISC_REG;
320 break;
321 case 1:
322 regAddressXHigh = FT5336_P2_XH_REG;
323 regAddressPWeight = FT5336_P2_WEIGHT_REG;
324 regAddressPMisc = FT5336_P2_MISC_REG;
325 break;
326 case 2:
327 regAddressXHigh = FT5336_P3_XH_REG;
328 regAddressPWeight = FT5336_P3_WEIGHT_REG;
329 regAddressPMisc = FT5336_P3_MISC_REG;
330 break;
331 case 3:
332 regAddressXHigh = FT5336_P4_XH_REG;
333 regAddressPWeight = FT5336_P4_WEIGHT_REG;
334 regAddressPMisc = FT5336_P4_MISC_REG;
335 break;
336 case 4:
337 regAddressXHigh = FT5336_P5_XH_REG;
338 regAddressPWeight = FT5336_P5_WEIGHT_REG;
339 regAddressPMisc = FT5336_P5_MISC_REG;
340 break;
341 case 5:
342 regAddressXHigh = FT5336_P6_XH_REG;
343 regAddressPWeight = FT5336_P6_WEIGHT_REG;
344 regAddressPMisc = FT5336_P6_MISC_REG;
345 break;
346 case 6:
347 regAddressXHigh = FT5336_P7_XH_REG;
348 regAddressPWeight = FT5336_P7_WEIGHT_REG;
349 regAddressPMisc = FT5336_P7_MISC_REG;
350 break;
351 case 7:
352 regAddressXHigh = FT5336_P8_XH_REG;
353 regAddressPWeight = FT5336_P8_WEIGHT_REG;
354 regAddressPMisc = FT5336_P8_MISC_REG;
355 break;
356 case 8:
357 regAddressXHigh = FT5336_P9_XH_REG;
358 regAddressPWeight = FT5336_P9_WEIGHT_REG;
359 regAddressPMisc = FT5336_P9_MISC_REG;
360 break;
361 case 9:
362 regAddressXHigh = FT5336_P10_XH_REG;
363 regAddressPWeight = FT5336_P10_WEIGHT_REG;
364 regAddressPMisc = FT5336_P10_MISC_REG;
365 break;
366 default:
367 break;
368 } /* end switch(touchIdx) */
369
370 /* Read Event Id of touch index */
371 ucReadData = ft5336_IO_Read(hts, regAddressXHigh);
372 *pEvent = (ucReadData & FT5336_TOUCH_EVT_FLAG_MASK) >> FT5336_TOUCH_EVT_FLAG_SHIFT;
373
374 /* Read weight of touch index */
375 ucReadData = ft5336_IO_Read(hts, regAddressPWeight);
376 *pWeight = (ucReadData & FT5336_TOUCH_WEIGHT_MASK) >> FT5336_TOUCH_WEIGHT_SHIFT;
377
378 /* Read area of touch index */
379 ucReadData = ft5336_IO_Read(hts, regAddressPMisc);
380 *pArea = (ucReadData & FT5336_TOUCH_AREA_MASK) >> FT5336_TOUCH_AREA_SHIFT;
381 } /* of if(touchIdx < TouchScreen_Handle.currActiveTouchNb) */
382}
383#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
384
385
386/**
387 * @brief Initializes and configures the touch screen functionalities and
388 * configures all necessary hardware resources (GPIOs, I2C, clocks..).
389 * @param ts_SizeX: Maximum X size of the TS area on LCD
390 * @param ts_SizeY: Maximum Y size of the TS area on LCD
391 * @param orientation : TS_ORIENTATION_LANDSCAPE or TS_ORIENTATION_PORTRAIT
392 * @retval E_OK if all initializations are OK. Other value if error.
393 */
394ER
395touchscreen_init(TouchScreen_Handle_t *hts, uint16_t ts_SizeX, uint16_t ts_SizeY, uint8_t orientation)
396{
397 ER ercd = E_OK;
398 hts->tsXBoundary = ts_SizeX;
399 hts->tsYBoundary = ts_SizeY;
400
401 /* Read ID and verify if the touch screen driver is ready */
402 if(ft5336_ReadID(hts, FT5336_I2C_SLAVE_ADDRESS) == FT5336_ID_VALUE){
403 /* Initialize the TS driver structure */
404 hts->I2C_Address = FT5336_I2C_SLAVE_ADDRESS;
405 hts->tsOrientation = TS_SWAP_XY;
406
407 /* Initialize the TS driver */
408 ft5336_TS_DisableIT(hts);
409 }
410 else
411 ercd = E_NOSPT;
412 return ercd;
413}
414
415/**
416 * @brief Returns status and positions of the touch screen.
417 * @param TS_State: Pointer to touch screen current state structure
418 * @retval E_OK if all initializations are OK. Other value if error.
419 */
420ER
421touchscreen_getstate(TouchScreen_Handle_t *hts, TS_StateTypeDef *TS_State)
422{
423 static uint32_t _x[TS_MAX_NB_TOUCH] = {0, 0};
424 static uint32_t _y[TS_MAX_NB_TOUCH] = {0, 0};
425 ER ercd = E_OK;
426 uint16_t x[TS_MAX_NB_TOUCH];
427 uint16_t y[TS_MAX_NB_TOUCH];
428 uint16_t brute_x[TS_MAX_NB_TOUCH];
429 uint16_t brute_y[TS_MAX_NB_TOUCH];
430 uint16_t x_diff;
431 uint16_t y_diff;
432 uint32_t index;
433#if (TS_MULTI_TOUCH_SUPPORTED == 1)
434 uint32_t weight = 0;
435 uint32_t area = 0;
436 uint32_t event = 0;
437 uint32_t gestureId = 0;
438#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
439
440 /* Check and update the number of touches active detected */
441 TS_State->touchDetected = ft5336_TS_DetectTouch(hts);
442
443 if(TS_State->touchDetected){
444 for(index=0; index < TS_State->touchDetected; index++){
445 /* Get each touch coordinates */
446 ft5336_TS_GetXY(hts, &(brute_x[index]), &(brute_y[index]));
447
448 if(hts->tsOrientation == TS_SWAP_NONE){
449 x[index] = brute_x[index];
450 y[index] = brute_y[index];
451 }
452 if(hts->tsOrientation & TS_SWAP_X){
453 x[index] = 4096 - brute_x[index];
454 }
455 if(hts->tsOrientation & TS_SWAP_Y){
456 y[index] = 4096 - brute_y[index];
457 }
458 if(hts->tsOrientation & TS_SWAP_XY){
459 y[index] = brute_x[index];
460 x[index] = brute_y[index];
461 }
462
463 x_diff = x[index] > _x[index]? (x[index] - _x[index]): (_x[index] - x[index]);
464 y_diff = y[index] > _y[index]? (y[index] - _y[index]): (_y[index] - y[index]);
465
466 if((x_diff + y_diff) > 5){
467 _x[index] = x[index];
468 _y[index] = y[index];
469 }
470 if(hts->I2C_Address == FT5336_I2C_SLAVE_ADDRESS){
471 TS_State->touchX[index] = x[index];
472 TS_State->touchY[index] = y[index];
473 }
474 else{
475 /* 2^12 = 4096 : indexes are expressed on a dynamic of 4096 */
476 TS_State->touchX[index] = (hts->tsXBoundary * _x[index]) >> 12;
477 TS_State->touchY[index] = (hts->tsYBoundary * _y[index]) >> 12;
478 }
479
480#if (TS_MULTI_TOUCH_SUPPORTED == 1)
481 /* Get touch info related to the current touch */
482 ft5336_TS_GetTouchInfo(hts, index, &weight, &area, &event);
483
484 /* Update TS_State structure */
485 TS_State->touchWeight[index] = weight;
486 TS_State->touchArea[index] = area;
487
488 /* Remap touch event */
489 switch(event){
490 case FT5336_TOUCH_EVT_FLAG_PRESS_DOWN :
491 TS_State->touchEventId[index] = TOUCH_EVENT_PRESS_DOWN;
492 break;
493 case FT5336_TOUCH_EVT_FLAG_LIFT_UP :
494 TS_State->touchEventId[index] = TOUCH_EVENT_LIFT_UP;
495 break;
496 case FT5336_TOUCH_EVT_FLAG_CONTACT :
497 TS_State->touchEventId[index] = TOUCH_EVENT_CONTACT;
498 break;
499 case FT5336_TOUCH_EVT_FLAG_NO_EVENT :
500 TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT;
501 break;
502 default:
503 ercd = E_SYS;
504 break;
505 } /* of switch(event) */
506#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
507
508 } /* of for(index=0; index < TS_State->touchDetected; index++) */
509
510#if (TS_MULTI_TOUCH_SUPPORTED == 1)
511 /* Get gesture Id */
512 gestureId = ft5336_IO_Read(hts, FT5336_GEST_ID_REG);
513
514 /* Remap gesture Id to a TS_GestureIdTypeDef value */
515 switch(gestureId){
516 case FT5336_GEST_ID_NO_GESTURE :
517 TS_State->gestureId = GEST_ID_NO_GESTURE;
518 break;
519 case FT5336_GEST_ID_MOVE_UP :
520 TS_State->gestureId = GEST_ID_MOVE_UP;
521 break;
522 case FT5336_GEST_ID_MOVE_RIGHT :
523 TS_State->gestureId = GEST_ID_MOVE_RIGHT;
524 break;
525 case FT5336_GEST_ID_MOVE_DOWN :
526 TS_State->gestureId = GEST_ID_MOVE_DOWN;
527 break;
528 case FT5336_GEST_ID_MOVE_LEFT :
529 TS_State->gestureId = GEST_ID_MOVE_LEFT;
530 break;
531 case FT5336_GEST_ID_ZOOM_IN :
532 TS_State->gestureId = GEST_ID_ZOOM_IN;
533 break;
534 case FT5336_GEST_ID_ZOOM_OUT :
535 TS_State->gestureId = GEST_ID_ZOOM_OUT;
536 break;
537 default:
538 ercd = E_SYS;
539 break;
540 } /* of switch(gestureId) */
541#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
542
543 } /* end of if(TS_State->touchDetected != 0) */
544 return ercd;
545}
546
547/**
548 * @brief Function used to reset all touch data before a new acquisition
549 * of touch information.
550 * @param TS_State: Pointer to touch screen current state structure
551 * @retval E_OK if OK, TE_ERROR if problem found.
552 */
553ER
554touchscreen_reset_data(TS_StateTypeDef *TS_State)
555{
556 ER ercd = E_PAR;
557 uint32_t index;
558
559 if(TS_State != (TS_StateTypeDef *)NULL){
560 TS_State->gestureId = GEST_ID_NO_GESTURE;
561 TS_State->touchDetected = 0;
562
563 for(index = 0; index < TS_MAX_NB_TOUCH; index++){
564 TS_State->touchX[index] = 0;
565 TS_State->touchY[index] = 0;
566 TS_State->touchArea[index] = 0;
567 TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT;
568 TS_State->touchWeight[index] = 0;
569 }
570 ercd = E_OK;
571 } /* of if (TS_State != (TS_StateTypeDef *)NULL) */
572 return ercd;
573}
574
Note: See TracBrowser for help on using the repository browser.