Skip to content

Commit

Permalink
FT6X36: Fix coordinates invesion
Browse files Browse the repository at this point in the history
The coordinates need to be swapped before inveting them when swapping is enabled.

Suggested in #118 by @wreyford
  • Loading branch information
C47D committed Sep 29, 2021
1 parent dd09b4d commit 8862804
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lvgl_touch/ft6x36.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
last_x = ((data_buf[1] & FT6X36_MSB_MASK) << 8) | (data_buf[2] & FT6X36_LSB_MASK);
last_y = ((data_buf[3] & FT6X36_MSB_MASK) << 8) | (data_buf[4] & FT6X36_LSB_MASK);

#if CONFIG_LV_FT6X36_SWAPXY
int16_t swap_buf = last_x;
last_x = last_y;
last_y = swap_buf;
#endif
#if CONFIG_LV_FT6X36_INVERT_X
last_x = LV_HOR_RES - last_x;
#endif
#if CONFIG_LV_FT6X36_INVERT_Y
last_y = LV_VER_RES - last_y;
#endif
#if CONFIG_LV_FT6X36_SWAPXY
int16_t swap_buf = last_x;
last_x = last_y;
last_y = swap_buf;
#endif
data->point.x = last_x;
data->point.y = last_y;
Expand Down

1 comment on commit 8862804

@wreyford
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx a lot. Yip this works for me.

Please sign in to comment.