Merge pull request #84 from ropg/fix_ft6x36

FT6X36 touch: fixed axis-swap, Kconfig defaults.
This commit is contained in:
Carlos Diaz 2021-07-07 15:47:07 -05:00 committed by GitHub
commit 8f1370d1c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View file

@ -242,7 +242,7 @@ menu "LVGL Touch controller"
config LV_FT6X36_SWAPXY
bool
prompt "Swap X with Y coordinate."
default y
default n
config LV_FT6X36_INVERT_X
bool
@ -252,7 +252,7 @@ menu "LVGL Touch controller"
config LV_FT6X36_INVERT_Y
bool
prompt "Invert Y coordinate value."
default y
default n
endmenu

View file

@ -182,20 +182,20 @@ bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
last_x = ((data_xy[0] & FT6X36_MSB_MASK) << 8) | (data_xy[1] & FT6X36_LSB_MASK);
last_y = ((data_xy[2] & FT6X36_MSB_MASK) << 8) | (data_xy[3] & 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;
data->state = LV_INDEV_STATE_PR;
ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y);
ESP_LOGD(TAG, "X=%u Y=%u", data->point.x, data->point.y);
return false;
}