From 5be00e755160ffe900d99617ac1e7325f7265f02 Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Thu, 9 Jan 2025 12:34:26 +0100 Subject: [PATCH] test(esp_lcd_touch): Add CI tests to touch components. --- .../esp_lcd_touch_cst816s/idf_component.yml | 2 +- .../include/esp_lcd_touch_cst816s.h | 19 +++++ .../test_apps/CMakeLists.txt | 6 ++ .../test_apps/main/CMakeLists.txt | 1 + .../test_apps/main/idf_component.yml | 6 ++ .../main/test_esp_lcd_touch_cst816s.c | 69 +++++++++++++++++++ .../test_apps/sdkconfig.defaults | 2 + .../test_apps/CMakeLists.txt | 6 ++ .../test_apps/main/CMakeLists.txt | 1 + .../test_apps/main/idf_component.yml | 6 ++ .../main/test_esp_lcd_touch_ft5x06.c | 69 +++++++++++++++++++ .../test_apps/sdkconfig.defaults | 2 + .../test_apps/CMakeLists.txt | 6 ++ .../test_apps/main/CMakeLists.txt | 1 + .../test_apps/main/idf_component.yml | 6 ++ .../main/test_esp_lcd_touch_gt1151.c | 69 +++++++++++++++++++ .../test_apps/sdkconfig.defaults | 2 + .../test_apps/CMakeLists.txt | 6 ++ .../test_apps/main/CMakeLists.txt | 1 + .../test_apps/main/idf_component.yml | 6 ++ .../test_apps/main/test_esp_lcd_touch_gt911.c | 69 +++++++++++++++++++ .../test_apps/sdkconfig.defaults | 2 + .../test_apps/CMakeLists.txt | 6 ++ .../test_apps/main/CMakeLists.txt | 1 + .../test_apps/main/idf_component.yml | 6 ++ .../main/test_esp_lcd_touch_tt21100.c | 69 +++++++++++++++++++ .../test_apps/sdkconfig.defaults | 2 + 27 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 components/lcd_touch/esp_lcd_touch_cst816s/test_apps/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/idf_component.yml create mode 100644 components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/test_esp_lcd_touch_cst816s.c create mode 100644 components/lcd_touch/esp_lcd_touch_cst816s/test_apps/sdkconfig.defaults create mode 100644 components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/idf_component.yml create mode 100644 components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/test_esp_lcd_touch_ft5x06.c create mode 100644 components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/sdkconfig.defaults create mode 100644 components/lcd_touch/esp_lcd_touch_gt1151/test_apps/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/idf_component.yml create mode 100644 components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/test_esp_lcd_touch_gt1151.c create mode 100644 components/lcd_touch/esp_lcd_touch_gt1151/test_apps/sdkconfig.defaults create mode 100644 components/lcd_touch/esp_lcd_touch_gt911/test_apps/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/idf_component.yml create mode 100644 components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/test_esp_lcd_touch_gt911.c create mode 100644 components/lcd_touch/esp_lcd_touch_gt911/test_apps/sdkconfig.defaults create mode 100644 components/lcd_touch/esp_lcd_touch_tt21100/test_apps/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/CMakeLists.txt create mode 100644 components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/idf_component.yml create mode 100644 components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/test_esp_lcd_touch_tt21100.c create mode 100644 components/lcd_touch/esp_lcd_touch_tt21100/test_apps/sdkconfig.defaults diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml b/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml index 42270e72..8d658a53 100644 --- a/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.4" +version: "1.0.5" description: ESP LCD Touch CST816S - touch controller CST816S url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_cst816s dependencies: diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/include/esp_lcd_touch_cst816s.h b/components/lcd_touch/esp_lcd_touch_cst816s/include/esp_lcd_touch_cst816s.h index 0a2fbf7e..cabba448 100644 --- a/components/lcd_touch/esp_lcd_touch_cst816s/include/esp_lcd_touch_cst816s.h +++ b/components/lcd_touch/esp_lcd_touch_cst816s/include/esp_lcd_touch_cst816s.h @@ -11,6 +11,7 @@ #pragma once +#include "esp_idf_version.h" #include "esp_lcd_touch.h" #ifdef __cplusplus @@ -40,6 +41,23 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons * @brief Touch IO configuration structure * */ +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5, 1, 0) +#define ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG() \ + { \ + .dev_addr = ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS, \ + .on_color_trans_done = 0, \ + .user_ctx = 0, \ + .control_phase_bytes = 1, \ + .dc_bit_offset = 0, \ + .lcd_cmd_bits = 8, \ + .lcd_param_bits = 0, \ + .flags = \ + { \ + .dc_low_on_data = 0, \ + .disable_control_phase = 1, \ + } \ + } +#else #define ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG() \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS, \ @@ -56,6 +74,7 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons }, \ .scl_speed_hz = 0 \ } +#endif #ifdef __cplusplus } diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/CMakeLists.txt new file mode 100644 index 00000000..eb8ee245 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) +set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(test_esp_lcd_touch_cst816s) diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/CMakeLists.txt new file mode 100644 index 00000000..8ffcbc71 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "test_esp_lcd_touch_cst816s.c") diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/idf_component.yml b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/idf_component.yml new file mode 100644 index 00000000..1062b524 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + idf: ">=4.4" + esp_lcd_touch_cst816s: + version: "*" + override_path: "../../../esp_lcd_touch_cst816s" diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/test_esp_lcd_touch_cst816s.c b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/test_esp_lcd_touch_cst816s.c new file mode 100644 index 00000000..92db14f7 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/main/test_esp_lcd_touch_cst816s.c @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include +#include "driver/i2c.h" +#include "driver/gpio.h" +#include "esp_log.h" +#include "unity.h" +#include "unity_test_runner.h" + +#include "esp_lcd_touch_cst816s.h" + +#define TEST_TOUCH_I2C_NUM (0) +#define TEST_TOUCH_I2C_CLK_HZ (400000) + +#define TEST_LCD_H_RES (240) +#define TEST_LCD_V_RES (240) + +/* LCD touch pins */ +#define TEST_TOUCH_I2C_SCL (GPIO_NUM_18) +#define TEST_TOUCH_I2C_SDA (GPIO_NUM_8) +#define TEST_TOUCH_GPIO_INT (GPIO_NUM_3) + +TEST_CASE("test cst816s to initialize touch", "[cst816s][i2c]") +{ + /* Initilize I2C */ + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = TEST_TOUCH_I2C_SDA, + .sda_pullup_en = GPIO_PULLUP_DISABLE, + .scl_io_num = TEST_TOUCH_I2C_SCL, + .scl_pullup_en = GPIO_PULLUP_DISABLE, + .master.clk_speed = TEST_TOUCH_I2C_CLK_HZ + }; + TEST_ESP_OK(i2c_param_config(TEST_TOUCH_I2C_NUM, &i2c_conf)); + TEST_ESP_OK(i2c_driver_install(TEST_TOUCH_I2C_NUM, i2c_conf.mode, 0, 0, 0)); + + /* Initialize touch HW */ + const esp_lcd_touch_config_t tp_cfg = { + .x_max = TEST_LCD_H_RES, + .y_max = TEST_LCD_V_RES, + .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .int_gpio_num = TEST_TOUCH_GPIO_INT, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 1, + .mirror_y = 0, + }, + }; + + esp_lcd_touch_handle_t touch_handle; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG(); + TEST_ESP_OK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TEST_TOUCH_I2C_NUM, &tp_io_config, &tp_io_handle)); + TEST_ESP_OK(esp_lcd_touch_new_i2c_cst816s(tp_io_handle, &tp_cfg, &touch_handle)); +} + +void app_main(void) +{ + printf("CST816S Test\r\n"); + unity_run_menu(); +} diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/sdkconfig.defaults b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/sdkconfig.defaults new file mode 100644 index 00000000..fa8ac618 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_cst816s/test_apps/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/CMakeLists.txt new file mode 100644 index 00000000..08cbf612 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) +set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(test_esp_lcd_touch_ft5x06) diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/CMakeLists.txt new file mode 100644 index 00000000..65d524c7 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "test_esp_lcd_touch_ft5x06.c") diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/idf_component.yml b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/idf_component.yml new file mode 100644 index 00000000..d2d78713 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + idf: ">=4.4" + esp_lcd_touch_ft5x06: + version: "*" + override_path: "../../../esp_lcd_touch_ft5x06" diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/test_esp_lcd_touch_ft5x06.c b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/test_esp_lcd_touch_ft5x06.c new file mode 100644 index 00000000..9c4ffb9d --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/main/test_esp_lcd_touch_ft5x06.c @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include +#include "driver/i2c.h" +#include "driver/gpio.h" +#include "esp_log.h" +#include "unity.h" +#include "unity_test_runner.h" + +#include "esp_lcd_touch_ft5x06.h" + +#define TEST_TOUCH_I2C_NUM (0) +#define TEST_TOUCH_I2C_CLK_HZ (400000) + +#define TEST_LCD_H_RES (240) +#define TEST_LCD_V_RES (240) + +/* LCD touch pins */ +#define TEST_TOUCH_I2C_SCL (GPIO_NUM_18) +#define TEST_TOUCH_I2C_SDA (GPIO_NUM_8) +#define TEST_TOUCH_GPIO_INT (GPIO_NUM_3) + +TEST_CASE("test cst816s to initialize touch", "[cst816s][i2c]") +{ + /* Initilize I2C */ + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = TEST_TOUCH_I2C_SDA, + .sda_pullup_en = GPIO_PULLUP_DISABLE, + .scl_io_num = TEST_TOUCH_I2C_SCL, + .scl_pullup_en = GPIO_PULLUP_DISABLE, + .master.clk_speed = TEST_TOUCH_I2C_CLK_HZ + }; + TEST_ESP_OK(i2c_param_config(TEST_TOUCH_I2C_NUM, &i2c_conf)); + TEST_ESP_OK(i2c_driver_install(TEST_TOUCH_I2C_NUM, i2c_conf.mode, 0, 0, 0)); + + /* Initialize touch HW */ + const esp_lcd_touch_config_t tp_cfg = { + .x_max = TEST_LCD_H_RES, + .y_max = TEST_LCD_V_RES, + .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .int_gpio_num = TEST_TOUCH_GPIO_INT, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 1, + .mirror_y = 0, + }, + }; + + esp_lcd_touch_handle_t touch_handle; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG(); + TEST_ESP_OK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TEST_TOUCH_I2C_NUM, &tp_io_config, &tp_io_handle)); + TEST_ESP_OK(esp_lcd_touch_new_i2c_ft5x06(tp_io_handle, &tp_cfg, &touch_handle)); +} + +void app_main(void) +{ + printf("FT5x06 Test\r\n"); + unity_run_menu(); +} diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/sdkconfig.defaults b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/sdkconfig.defaults new file mode 100644 index 00000000..fa8ac618 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/test_apps/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/CMakeLists.txt new file mode 100644 index 00000000..5792cb24 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) +set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(test_esp_lcd_touch_gt1151) diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/CMakeLists.txt new file mode 100644 index 00000000..1c5515f7 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "test_esp_lcd_touch_gt1151.c") diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/idf_component.yml b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/idf_component.yml new file mode 100644 index 00000000..023be7c5 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + idf: ">=4.4" + esp_lcd_touch_gt1151: + version: "*" + override_path: "../../../esp_lcd_touch_gt1151" diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/test_esp_lcd_touch_gt1151.c b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/test_esp_lcd_touch_gt1151.c new file mode 100644 index 00000000..3d0bf01c --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/main/test_esp_lcd_touch_gt1151.c @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include +#include "driver/i2c.h" +#include "driver/gpio.h" +#include "esp_log.h" +#include "unity.h" +#include "unity_test_runner.h" + +#include "esp_lcd_touch_gt1151.h" + +#define TEST_TOUCH_I2C_NUM (0) +#define TEST_TOUCH_I2C_CLK_HZ (400000) + +#define TEST_LCD_H_RES (240) +#define TEST_LCD_V_RES (240) + +/* LCD touch pins */ +#define TEST_TOUCH_I2C_SCL (GPIO_NUM_18) +#define TEST_TOUCH_I2C_SDA (GPIO_NUM_8) +#define TEST_TOUCH_GPIO_INT (GPIO_NUM_3) + +TEST_CASE("test cst816s to initialize touch", "[cst816s][i2c]") +{ + /* Initilize I2C */ + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = TEST_TOUCH_I2C_SDA, + .sda_pullup_en = GPIO_PULLUP_DISABLE, + .scl_io_num = TEST_TOUCH_I2C_SCL, + .scl_pullup_en = GPIO_PULLUP_DISABLE, + .master.clk_speed = TEST_TOUCH_I2C_CLK_HZ + }; + TEST_ESP_OK(i2c_param_config(TEST_TOUCH_I2C_NUM, &i2c_conf)); + TEST_ESP_OK(i2c_driver_install(TEST_TOUCH_I2C_NUM, i2c_conf.mode, 0, 0, 0)); + + /* Initialize touch HW */ + const esp_lcd_touch_config_t tp_cfg = { + .x_max = TEST_LCD_H_RES, + .y_max = TEST_LCD_V_RES, + .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .int_gpio_num = TEST_TOUCH_GPIO_INT, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 1, + .mirror_y = 0, + }, + }; + + esp_lcd_touch_handle_t touch_handle; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT1151_CONFIG(); + TEST_ESP_OK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TEST_TOUCH_I2C_NUM, &tp_io_config, &tp_io_handle)); + TEST_ESP_OK(esp_lcd_touch_new_i2c_gt1151(tp_io_handle, &tp_cfg, &touch_handle)); +} + +void app_main(void) +{ + printf("GT1151 Test\r\n"); + unity_run_menu(); +} diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/sdkconfig.defaults b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/sdkconfig.defaults new file mode 100644 index 00000000..fa8ac618 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt1151/test_apps/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/lcd_touch/esp_lcd_touch_gt911/test_apps/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/CMakeLists.txt new file mode 100644 index 00000000..41e90a2c --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) +set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(test_esp_lcd_touch_gt911) diff --git a/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/CMakeLists.txt new file mode 100644 index 00000000..97fbdded --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "test_esp_lcd_touch_gt911.c") diff --git a/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/idf_component.yml b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/idf_component.yml new file mode 100644 index 00000000..e2915b27 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + idf: ">=4.4" + esp_lcd_touch_gt911: + version: "*" + override_path: "../../../esp_lcd_touch_gt911" diff --git a/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/test_esp_lcd_touch_gt911.c b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/test_esp_lcd_touch_gt911.c new file mode 100644 index 00000000..dd1ed790 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/main/test_esp_lcd_touch_gt911.c @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include +#include "driver/i2c.h" +#include "driver/gpio.h" +#include "esp_log.h" +#include "unity.h" +#include "unity_test_runner.h" + +#include "esp_lcd_touch_gt911.h" + +#define TEST_TOUCH_I2C_NUM (0) +#define TEST_TOUCH_I2C_CLK_HZ (400000) + +#define TEST_LCD_H_RES (240) +#define TEST_LCD_V_RES (240) + +/* LCD touch pins */ +#define TEST_TOUCH_I2C_SCL (GPIO_NUM_18) +#define TEST_TOUCH_I2C_SDA (GPIO_NUM_8) +#define TEST_TOUCH_GPIO_INT (GPIO_NUM_3) + +TEST_CASE("test cst816s to initialize touch", "[cst816s][i2c]") +{ + /* Initilize I2C */ + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = TEST_TOUCH_I2C_SDA, + .sda_pullup_en = GPIO_PULLUP_DISABLE, + .scl_io_num = TEST_TOUCH_I2C_SCL, + .scl_pullup_en = GPIO_PULLUP_DISABLE, + .master.clk_speed = TEST_TOUCH_I2C_CLK_HZ + }; + TEST_ESP_OK(i2c_param_config(TEST_TOUCH_I2C_NUM, &i2c_conf)); + TEST_ESP_OK(i2c_driver_install(TEST_TOUCH_I2C_NUM, i2c_conf.mode, 0, 0, 0)); + + /* Initialize touch HW */ + const esp_lcd_touch_config_t tp_cfg = { + .x_max = TEST_LCD_H_RES, + .y_max = TEST_LCD_V_RES, + .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .int_gpio_num = TEST_TOUCH_GPIO_INT, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 1, + .mirror_y = 0, + }, + }; + + esp_lcd_touch_handle_t touch_handle; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); + TEST_ESP_OK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TEST_TOUCH_I2C_NUM, &tp_io_config, &tp_io_handle)); + TEST_ESP_OK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &touch_handle)); +} + +void app_main(void) +{ + printf("GT911 Test\r\n"); + unity_run_menu(); +} diff --git a/components/lcd_touch/esp_lcd_touch_gt911/test_apps/sdkconfig.defaults b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/sdkconfig.defaults new file mode 100644 index 00000000..fa8ac618 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_gt911/test_apps/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/CMakeLists.txt new file mode 100644 index 00000000..de9b2623 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) +set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(test_esp_lcd_touch_tt21100) diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/CMakeLists.txt b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/CMakeLists.txt new file mode 100644 index 00000000..a27c3d68 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "test_esp_lcd_touch_tt21100.c") diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/idf_component.yml b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/idf_component.yml new file mode 100644 index 00000000..1175e57d --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + idf: ">=4.4" + esp_lcd_touch_tt21100: + version: "*" + override_path: "../../../esp_lcd_touch_tt21100" diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/test_esp_lcd_touch_tt21100.c b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/test_esp_lcd_touch_tt21100.c new file mode 100644 index 00000000..c2f969c0 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/main/test_esp_lcd_touch_tt21100.c @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include +#include "driver/i2c.h" +#include "driver/gpio.h" +#include "esp_log.h" +#include "unity.h" +#include "unity_test_runner.h" + +#include "esp_lcd_touch_tt21100.h" + +#define TEST_TOUCH_I2C_NUM (0) +#define TEST_TOUCH_I2C_CLK_HZ (400000) + +#define TEST_LCD_H_RES (240) +#define TEST_LCD_V_RES (240) + +/* LCD touch pins */ +#define TEST_TOUCH_I2C_SCL (GPIO_NUM_18) +#define TEST_TOUCH_I2C_SDA (GPIO_NUM_8) +#define TEST_TOUCH_GPIO_INT (GPIO_NUM_3) + +TEST_CASE("test cst816s to initialize touch", "[cst816s][i2c]") +{ + /* Initilize I2C */ + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = TEST_TOUCH_I2C_SDA, + .sda_pullup_en = GPIO_PULLUP_DISABLE, + .scl_io_num = TEST_TOUCH_I2C_SCL, + .scl_pullup_en = GPIO_PULLUP_DISABLE, + .master.clk_speed = TEST_TOUCH_I2C_CLK_HZ + }; + TEST_ESP_OK(i2c_param_config(TEST_TOUCH_I2C_NUM, &i2c_conf)); + TEST_ESP_OK(i2c_driver_install(TEST_TOUCH_I2C_NUM, i2c_conf.mode, 0, 0, 0)); + + /* Initialize touch HW */ + const esp_lcd_touch_config_t tp_cfg = { + .x_max = TEST_LCD_H_RES, + .y_max = TEST_LCD_V_RES, + .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .int_gpio_num = TEST_TOUCH_GPIO_INT, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 0, + .mirror_x = 1, + .mirror_y = 0, + }, + }; + + esp_lcd_touch_handle_t touch_handle; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_TT21100_CONFIG(); + TEST_ESP_OK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TEST_TOUCH_I2C_NUM, &tp_io_config, &tp_io_handle)); + TEST_ESP_OK(esp_lcd_touch_new_i2c_tt21100(tp_io_handle, &tp_cfg, &touch_handle)); +} + +void app_main(void) +{ + printf("TT21100 Test\r\n"); + unity_run_menu(); +} diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/sdkconfig.defaults b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/sdkconfig.defaults new file mode 100644 index 00000000..fa8ac618 --- /dev/null +++ b/components/lcd_touch/esp_lcd_touch_tt21100/test_apps/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n