From 895434a41080068b4016bf4c7ca44f7f6182c525 Mon Sep 17 00:00:00 2001 From: Christopher Liebman Date: Tue, 29 Dec 2020 14:40:03 -0800 Subject: [PATCH] use Kconfig choice for IRQ/PRESS/IRQ&PRESS --- lvgl_touch/Kconfig | 22 ++++++++++++---------- lvgl_touch/xpt2046.c | 9 +++++---- lvgl_touch/xpt2046.h | 9 +++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lvgl_touch/Kconfig b/lvgl_touch/Kconfig index b1b5e89..659cf02 100644 --- a/lvgl_touch/Kconfig +++ b/lvgl_touch/Kconfig @@ -178,17 +178,19 @@ menu "LVGL Touch controller" prompt "Invert Y coordinate value." default y + choice + prompt "Select touch detection method." + default LV_TOUCH_DETECT_IRQ + help + Select the controller for your touch panel. - 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 + config LV_TOUCH_DETECT_IRQ + bool "IRQ pin only" + config LV_TOUCH_DETECT_IRQ_PRESSURE + bool "IRQ pin and pressure" + config LV_TOUCH_DETECT_PRESSURE + bool "Pressure only" + endchoice endmenu menu "Touchpanel (FT6X06) Pin Assignments" diff --git a/lvgl_touch/xpt2046.c b/lvgl_touch/xpt2046.c index 074cbfc..93b4329 100644 --- a/lvgl_touch/xpt2046.c +++ b/lvgl_touch/xpt2046.c @@ -61,7 +61,7 @@ void xpt2046_init(void) { ESP_LOGI(TAG, "XPT2046 Initialization"); -#if XPT2046_TOUCH_ONLY == 0 +#if XPT2046_TOUCH_IRQ || XPT2046_TOUCH_IRQ_PRESS gpio_config_t irq_config = { .pin_bit_mask = BIT64(XPT2046_IRQ), .mode = GPIO_MODE_INPUT, @@ -125,15 +125,16 @@ bool xpt2046_read(lv_indev_drv_t * drv, lv_indev_data_t * data) **********************/ static xpt2046_touch_detect_t xpt2048_is_touch_detected() { - // check IRQ if we are not touch only OR are not checking touch -#if XPT2046_TOUCH_ONLY == 0 || XPT2046_TOUCH_CHECK == 0 + // check IRQ pin if we IRQ or IRQ and preessure +#if XPT2046_TOUCH_IRQ || XPT2046_TOUCH_IRQ_PRESS uint8_t irq = gpio_get_level(XPT2046_IRQ); if (irq != 0) { return TOUCH_NOT_DETECTED; } #endif -#if XPT2046_TOUCH_CHECK != 0 + // check pressure if we are pressure or IRQ and pressure +#if XPT2046_TOUCH_PRESS || XPT2046_TOUCH_IRQ_PRESS int16_t z1 = xpt2046_cmd(CMD_Z1_READ) >> 3; int16_t z2 = xpt2046_cmd(CMD_Z2_READ) >> 3; diff --git a/lvgl_touch/xpt2046.h b/lvgl_touch/xpt2046.h index bcdf84f..016a351 100644 --- a/lvgl_touch/xpt2046.h +++ b/lvgl_touch/xpt2046.h @@ -35,13 +35,10 @@ extern "C" { #define XPT2046_X_INV CONFIG_LV_TOUCH_INVERT_X #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 #define XPT2046_TOUCH_THRESHOLD 400 // Threshold for touch detection -#if defined(CONFIG_LV_TOUCH_ONLY) -#define XPT2046_TOUCH_ONLY CONFIG_LV_TOUCH_ONLY -#else -#define XPT2046_TOUCH_ONLY 0 -#endif +#define XPT2046_TOUCH_IRQ CONFIG_LV_TOUCH_DETECT_IRQ +#define XPT2046_TOUCH_IRQ_PRESS CONFIG_LV_TOUCH_DETECT_IRQ_PRESSURE +#define XPT2046_TOUCH_PRESS CONFIG_LV_TOUCH_DETECT_PRESSURE /********************** * TYPEDEFS