use Kconfig choice for IRQ/PRESS/IRQ&PRESS

This commit is contained in:
Christopher Liebman 2020-12-29 14:40:03 -08:00
parent eaf43e40fa
commit 895434a410
3 changed files with 20 additions and 20 deletions

View file

@ -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"

View file

@ -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;

View file

@ -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