From f344f002785b1e7ded48d62282f8a5de9a766dce Mon Sep 17 00:00:00 2001 From: "chaos.proton@gmail.com" Date: Wed, 2 Nov 2011 12:14:57 +0000 Subject: [PATCH] bsp/stm32f10x/touch.c: normalize the calibrated touch position git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1783 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/stm32f10x/touch.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bsp/stm32f10x/touch.c b/bsp/stm32f10x/touch.c index 397f94a2f4..a2d88da9b5 100644 --- a/bsp/stm32f10x/touch.c +++ b/bsp/stm32f10x/touch.c @@ -171,6 +171,17 @@ static void rtgui_touch_calculate() { touch->y = (touch->min_y - touch->y) * Y_WIDTH /(touch->min_y - touch->max_y); } + + // normalize the data + if (touch->x & 0x8000) + touch->x = 0; + else if (touch->x > X_WIDTH) + touch->x = X_WIDTH - 1; + + if (touch->y & 0x8000) + touch->y = 0; + else if (touch->y > Y_WIDTH) + touch->y = Y_WIDTH - 1; } } } -- GitLab