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
This commit is contained in:
chaos.proton@gmail.com 2011-11-02 12:14:57 +00:00
parent e803640027
commit f344f00278
1 changed files with 11 additions and 0 deletions

View File

@ -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;
}
}
}