touch_element: fix unintended integer division

This commit is contained in:
morris 2023-06-19 11:03:15 +08:00
parent 0e68d6fb29
commit b615fd7f8f

View File

@ -628,7 +628,7 @@ static uint32_t slider_filter_average(te_slider_handle_t slider_handle, uint32_t
for (int win_idx = 0; win_idx < TE_SLD_DEFAULT_POS_FILTER_SIZE(s_te_sld_obj); win_idx++) { //Moving average filter
position_average += slider_handle->pos_filter_window[win_idx];
}
position_average = position_average / TE_SLD_DEFAULT_POS_FILTER_SIZE(s_te_sld_obj) + 0.5;
position_average = (uint32_t)((float)position_average / TE_SLD_DEFAULT_POS_FILTER_SIZE(s_te_sld_obj) + 0.5F);
return position_average;
}