From 93104fb4fc4361d75a3249a804a904db0d54a72a Mon Sep 17 00:00:00 2001 From: "chaos.proton@gmail.com" Date: Tue, 8 Nov 2011 07:52:20 +0000 Subject: [PATCH] bsp/stm32f10x/touch: return early when lost the position Check whether finger is still on the screen. If not, we couldn't determine where the user has touched. It's better to return early rather than give garbage values. A more sensitive solution might be caculate the position once the interrupt occured. But it's not anti-shake friendly. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1789 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/stm32f10x/touch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bsp/stm32f10x/touch.c b/bsp/stm32f10x/touch.c index aeddda599b..b672ccdb4d 100644 --- a/bsp/stm32f10x/touch.c +++ b/bsp/stm32f10x/touch.c @@ -196,6 +196,10 @@ void touch_timeout(void* parameter) rt_uint32_t y; } touch_previous; + /* touch time is too short and we lost the position already. */ + if ((!touch_down) && GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) != 0) + return; + if (GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_1) != 0) { int tmer = RT_TICK_PER_SECOND/8 ; -- GitLab