From f726311525474489a409f4cdb1a6a7ae315f2c05 Mon Sep 17 00:00:00 2001 From: C47D Date: Thu, 10 Jun 2021 22:49:56 -0500 Subject: [PATCH] Indev: Add support for GT911 touch driver by @dastarling --- CMakeLists.txt | 2 ++ lvgl_touch/Kconfig | 49 +++++++++++++++++++++++++++++++++++++++ lvgl_touch/touch_driver.c | 4 ++++ lvgl_touch/touch_driver.h | 2 ++ 4 files changed, 57 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5832233..10262c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,8 @@ if(CONFIG_LV_TOUCH_CONTROLLER) list(APPEND SOURCES "lvgl_touch/FT81x.c") elseif(CONFIG_LV_TOUCH_CONTROLLER_RA8875) list(APPEND SOURCES "lvgl_touch/ra8875_touch.c") + elseif(CONFIG_LV_TOUCH_CONTROLLER_GT911) + list(APPEND SOURCES "lvgl_touch/gt911.c") endif() if(CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI) diff --git a/lvgl_touch/Kconfig b/lvgl_touch/Kconfig index 7f6e995..9942e0a 100644 --- a/lvgl_touch/Kconfig +++ b/lvgl_touch/Kconfig @@ -9,6 +9,7 @@ menu "LVGL Touch controller" default 4 if LV_TOUCH_CONTROLLER_ADCRAW default 5 if LV_TOUCH_CONTROLLER_FT81X default 6 if LV_TOUCH_CONTROLLER_RA8875 + default 7 if LV_TOUCH_CONTROLLER_GT911 choice prompt "Select a touch panel controller model." @@ -36,6 +37,9 @@ menu "LVGL Touch controller" config LV_TOUCH_CONTROLLER_RA8875 select LV_TOUCH_DRIVER_DISPLAY bool "RA8875" + config LV_TOUCH_CONTROLLER_GT911 + select LV_TOUCH_DRIVER_PROTOCOL_I2C + bool "GT911" endchoice config LV_TOUCH_DRIVER_PROTOCOL_SPI @@ -498,5 +502,50 @@ menu "LVGL Touch controller" default y endmenu + + menu "Touchpanel (GT911) Pin Assignments" + depends on LV_TOUCH_CONTROLLER_GT911 + + config LV_TOUCH_I2C_SDA + int + prompt "GPIO for SDA (I2C)" + range 0 39 if IDF_TARGET_ESP32 + range 0 43 if IDF_TARGET_ESP32S2 + range 0 21 if IDF_TARGET_ESP32C3 + + default 2 + help + Configure the I2C touchpanel SDA pin here. + + config LV_TOUCH_I2C_SCL + int "GPIO for clock signal SCL (I2C)" + range 0 39 if IDF_TARGET_ESP32 + range 0 43 if IDF_TARGET_ESP32S2 + range 0 21 if IDF_TARGET_ESP32C3 + + default 3 + help + Configure the I2C touchpanel SCL pin here. + endmenu + + menu "Touchpanel Configuration (GT911)" + depends on LV_TOUCH_CONTROLLER_GT911 + + config LV_GT911_SWAPXY + bool + prompt "Swap X with Y coordinate." + default y + + config LV_GT911_INVERT_X + bool + prompt "Invert X coordinate value." + default n + + config LV_GT911_INVERT_Y + bool + prompt "Invert Y coordinate value." + default y + + endmenu endmenu diff --git a/lvgl_touch/touch_driver.c b/lvgl_touch/touch_driver.c index b0aed88..6a7afb3 100644 --- a/lvgl_touch/touch_driver.c +++ b/lvgl_touch/touch_driver.c @@ -21,6 +21,8 @@ void touch_driver_init(void) /* nothing to do */ #elif defined (CONFIG_LV_TOUCH_CONTROLLER_RA8875) ra8875_touch_init(); +#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911) + gt911_init(GT911_I2C_SLAVE_ADDR); #endif } @@ -40,6 +42,8 @@ bool touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data) res = FT81x_read(drv, data); #elif defined (CONFIG_LV_TOUCH_CONTROLLER_RA8875) res = ra8875_touch_read(drv, data); +#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911) + res = gt911_read(drv, data); #endif return res; diff --git a/lvgl_touch/touch_driver.h b/lvgl_touch/touch_driver.h index bc92f4f..44378db 100644 --- a/lvgl_touch/touch_driver.h +++ b/lvgl_touch/touch_driver.h @@ -32,6 +32,8 @@ extern "C" { #include "FT81x.h" #elif defined (CONFIG_LV_TOUCH_CONTROLLER_RA8875) #include "ra8875_touch.h" +#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911) +#include "gt911.h" #endif /*********************