avoid divided by zero error
The old code only checks touch->max_x > touch->min_x but not touch->max_x == touch->min_x. Thus may lead to divided by zero error. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1782 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
9de3512c8a
commit
e803640027
|
@ -158,7 +158,7 @@ static void rtgui_touch_calculate()
|
|||
{
|
||||
touch->x = (touch->x - touch->min_x) * X_WIDTH/(touch->max_x - touch->min_x);
|
||||
}
|
||||
else
|
||||
else if (touch->max_x < touch->min_x)
|
||||
{
|
||||
touch->x = (touch->min_x - touch->x) * X_WIDTH/(touch->min_x - touch->max_x);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ static void rtgui_touch_calculate()
|
|||
{
|
||||
touch->y = (touch->y - touch->min_y) * Y_WIDTH /(touch->max_y - touch->min_y);
|
||||
}
|
||||
else
|
||||
else if (touch->max_y < touch->min_y)
|
||||
{
|
||||
touch->y = (touch->min_y - touch->y) * Y_WIDTH /(touch->min_y - touch->max_y);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue