浏览代码

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
chaos.proton@gmail.com 13 年之前
父节点
当前提交
f344f00278
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      bsp/stm32f10x/touch.c

+ 11 - 0
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;
         }
     }
 }