From c445eca696ecd2ae376e8cf42fb5ffa7b2ba2690 Mon Sep 17 00:00:00 2001 From: Christopher Liebman Date: Fri, 25 Dec 2020 12:42:01 -0800 Subject: [PATCH] xpt2048 add option for using only touch pressure and ignoring IRQ --- lvgl_touch/Kconfig | 11 ++++++++--- lvgl_touch/xpt2046.c | 12 ++++++++---- lvgl_touch/xpt2046.h | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lvgl_touch/Kconfig b/lvgl_touch/Kconfig index 34d2a0b..b1b5e89 100644 --- a/lvgl_touch/Kconfig +++ b/lvgl_touch/Kconfig @@ -99,7 +99,6 @@ menu "LVGL Touch controller" range 0 39 default 35 if LV_PREDEFINED_PINS_38V1 default 19 - help Configure the touchpanel MISO pin here. @@ -109,7 +108,6 @@ menu "LVGL Touch controller" range 0 39 default 32 if LV_PREDEFINED_PINS_38V1 default 23 - help Configure the touchpanel MOSI pin here. @@ -135,7 +133,7 @@ menu "LVGL Touch controller" default 27 if LV_PREDEFINED_PINS_38V4 default 25 help - Configure the touchpanel CS pin here. + Configure the touchpanel IRQ pin here. endmenu menu "Touchpanel Configuration (XPT2046)" @@ -180,10 +178,17 @@ menu "LVGL Touch controller" prompt "Invert Y coordinate value." default y + config LV_TOUCH_CHECK bool prompt "Check touch pressure to validate LV_TOUCH_PIN_IRQ" default n + + config LV_TOUCH_ONLY + bool + prompt "Only use touch pressure and not IRQ to detect a touch" + depends on LV_TOUCH_CHECK + default n endmenu menu "Touchpanel (FT6X06) Pin Assignments" diff --git a/lvgl_touch/xpt2046.c b/lvgl_touch/xpt2046.c index b8a2617..5815a15 100644 --- a/lvgl_touch/xpt2046.c +++ b/lvgl_touch/xpt2046.c @@ -55,6 +55,9 @@ uint8_t avg_last; */ void xpt2046_init(void) { + ESP_LOGI(TAG, "XPT2046 Initialization"); + +#if XPT2046_TOUCH_ONLY == 0 gpio_config_t irq_config = { .pin_bit_mask = BIT64(XPT2046_IRQ), .mode = GPIO_MODE_INPUT, @@ -63,10 +66,9 @@ void xpt2046_init(void) .intr_type = GPIO_INTR_DISABLE, }; - ESP_LOGI(TAG, "XPT2046 Initialization"); - esp_err_t ret = gpio_config(&irq_config); assert(ret == ESP_OK); +#endif } /** @@ -82,10 +84,11 @@ bool xpt2046_read(lv_indev_drv_t * drv, lv_indev_data_t * data) int16_t x = last_x; int16_t y = last_y; - +#if XPT2046_TOUCH_ONLY == 0 uint8_t irq = gpio_get_level(XPT2046_IRQ); if (irq == 0) { +#endif #if XPT2046_TOUCH_CHECK != 0 int16_t z1 = xpt2046_cmd(CMD_Z1_READ) >> 3; int16_t z2 = xpt2046_cmd(CMD_Z2_READ) >> 3; @@ -119,8 +122,9 @@ bool xpt2046_read(lv_indev_drv_t * drv, lv_indev_data_t * data) #if XPT2046_TOUCH_CHECK != 0 } #endif +#if XPT2046_TOUCH_ONLY == 0 } - +#endif if (!valid) { avg_last = 0; diff --git a/lvgl_touch/xpt2046.h b/lvgl_touch/xpt2046.h index 592ae8d..9a4ccf3 100644 --- a/lvgl_touch/xpt2046.h +++ b/lvgl_touch/xpt2046.h @@ -36,6 +36,12 @@ extern "C" { #define XPT2046_Y_INV CONFIG_LV_TOUCH_INVERT_Y #define XPT2046_XY_SWAP CONFIG_LV_TOUCH_XY_SWAP #define XPT2046_TOUCH_CHECK CONFIG_LV_TOUCH_CHECK +#if defined(CONFIG_LV_TOUCH_ONLY) +#define XPT2046_TOUCH_ONLY CONFIG_LV_TOUCH_ONLY +#else +#define XPT2046_TOUCH_ONLY 0 +#endif + /********************** * TYPEDEFS **********************/