xpt2048 add option for using only touch pressure and ignoring IRQ
This commit is contained in:
parent
0fc057b22c
commit
c445eca696
|
@ -99,7 +99,6 @@ menu "LVGL Touch controller"
|
||||||
range 0 39
|
range 0 39
|
||||||
default 35 if LV_PREDEFINED_PINS_38V1
|
default 35 if LV_PREDEFINED_PINS_38V1
|
||||||
default 19
|
default 19
|
||||||
|
|
||||||
help
|
help
|
||||||
Configure the touchpanel MISO pin here.
|
Configure the touchpanel MISO pin here.
|
||||||
|
|
||||||
|
@ -109,7 +108,6 @@ menu "LVGL Touch controller"
|
||||||
range 0 39
|
range 0 39
|
||||||
default 32 if LV_PREDEFINED_PINS_38V1
|
default 32 if LV_PREDEFINED_PINS_38V1
|
||||||
default 23
|
default 23
|
||||||
|
|
||||||
help
|
help
|
||||||
Configure the touchpanel MOSI pin here.
|
Configure the touchpanel MOSI pin here.
|
||||||
|
|
||||||
|
@ -135,7 +133,7 @@ menu "LVGL Touch controller"
|
||||||
default 27 if LV_PREDEFINED_PINS_38V4
|
default 27 if LV_PREDEFINED_PINS_38V4
|
||||||
default 25
|
default 25
|
||||||
help
|
help
|
||||||
Configure the touchpanel CS pin here.
|
Configure the touchpanel IRQ pin here.
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Touchpanel Configuration (XPT2046)"
|
menu "Touchpanel Configuration (XPT2046)"
|
||||||
|
@ -180,10 +178,17 @@ menu "LVGL Touch controller"
|
||||||
prompt "Invert Y coordinate value."
|
prompt "Invert Y coordinate value."
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
|
||||||
config LV_TOUCH_CHECK
|
config LV_TOUCH_CHECK
|
||||||
bool
|
bool
|
||||||
prompt "Check touch pressure to validate LV_TOUCH_PIN_IRQ"
|
prompt "Check touch pressure to validate LV_TOUCH_PIN_IRQ"
|
||||||
default n
|
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
|
endmenu
|
||||||
|
|
||||||
menu "Touchpanel (FT6X06) Pin Assignments"
|
menu "Touchpanel (FT6X06) Pin Assignments"
|
||||||
|
|
|
@ -55,6 +55,9 @@ uint8_t avg_last;
|
||||||
*/
|
*/
|
||||||
void xpt2046_init(void)
|
void xpt2046_init(void)
|
||||||
{
|
{
|
||||||
|
ESP_LOGI(TAG, "XPT2046 Initialization");
|
||||||
|
|
||||||
|
#if XPT2046_TOUCH_ONLY == 0
|
||||||
gpio_config_t irq_config = {
|
gpio_config_t irq_config = {
|
||||||
.pin_bit_mask = BIT64(XPT2046_IRQ),
|
.pin_bit_mask = BIT64(XPT2046_IRQ),
|
||||||
.mode = GPIO_MODE_INPUT,
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
@ -63,10 +66,9 @@ void xpt2046_init(void)
|
||||||
.intr_type = GPIO_INTR_DISABLE,
|
.intr_type = GPIO_INTR_DISABLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_LOGI(TAG, "XPT2046 Initialization");
|
|
||||||
|
|
||||||
esp_err_t ret = gpio_config(&irq_config);
|
esp_err_t ret = gpio_config(&irq_config);
|
||||||
assert(ret == ESP_OK);
|
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 x = last_x;
|
||||||
int16_t y = last_y;
|
int16_t y = last_y;
|
||||||
|
#if XPT2046_TOUCH_ONLY == 0
|
||||||
uint8_t irq = gpio_get_level(XPT2046_IRQ);
|
uint8_t irq = gpio_get_level(XPT2046_IRQ);
|
||||||
|
|
||||||
if (irq == 0) {
|
if (irq == 0) {
|
||||||
|
#endif
|
||||||
#if XPT2046_TOUCH_CHECK != 0
|
#if XPT2046_TOUCH_CHECK != 0
|
||||||
int16_t z1 = xpt2046_cmd(CMD_Z1_READ) >> 3;
|
int16_t z1 = xpt2046_cmd(CMD_Z1_READ) >> 3;
|
||||||
int16_t z2 = xpt2046_cmd(CMD_Z2_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
|
#if XPT2046_TOUCH_CHECK != 0
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if XPT2046_TOUCH_ONLY == 0
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
avg_last = 0;
|
avg_last = 0;
|
||||||
|
|
|
@ -36,6 +36,12 @@ extern "C" {
|
||||||
#define XPT2046_Y_INV CONFIG_LV_TOUCH_INVERT_Y
|
#define XPT2046_Y_INV CONFIG_LV_TOUCH_INVERT_Y
|
||||||
#define XPT2046_XY_SWAP CONFIG_LV_TOUCH_XY_SWAP
|
#define XPT2046_XY_SWAP CONFIG_LV_TOUCH_XY_SWAP
|
||||||
#define XPT2046_TOUCH_CHECK CONFIG_LV_TOUCH_CHECK
|
#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
|
* TYPEDEFS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
Loading…
Reference in a new issue