summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author[email protected] <[email protected]>2011-11-02 12:14:57 +0000
committer[email protected] <[email protected]>2011-11-02 12:14:57 +0000
commitf344f002785b1e7ded48d62282f8a5de9a766dce (patch)
tree50e99b71ad86d73054b5f1af1a95fa9d3a1715dd
parente803640027323b9bacc29bf3d11ee83f4464bd0b (diff)
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
-rw-r--r--bsp/stm32f10x/touch.c11
1 files changed, 11 insertions, 0 deletions
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;
}
}
}