mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 04:04:31 +02:00
Merge branch 'touch_sensor/update_touch_sensor_examples_v5.0' into 'release/v5.0'
touch: update examples and tests (v5.0) See merge request espressif/esp-idf!19725
This commit is contained in:
@@ -43,3 +43,11 @@ components/driver/test_apps/sdm:
|
|||||||
components/driver/test_apps/temperature_sensor:
|
components/driver/test_apps/temperature_sensor:
|
||||||
disable:
|
disable:
|
||||||
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
|
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
|
||||||
|
|
||||||
|
components/driver/test_apps/touch_sensor_v1:
|
||||||
|
disable:
|
||||||
|
- if: SOC_TOUCH_VERSION_1 != 1
|
||||||
|
|
||||||
|
components/driver/test_apps/touch_sensor_v2:
|
||||||
|
disable:
|
||||||
|
- if: SOC_TOUCH_VERSION_2 != 1
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
esp_timer_handle_t timer;
|
esp_timer_handle_t timer;
|
||||||
uint16_t filtered_val[TOUCH_PAD_MAX];
|
uint16_t filtered_val[TOUCH_PAD_MAX];
|
||||||
|
uint32_t filter_last_val[TOUCH_PAD_MAX];
|
||||||
uint16_t raw_val[TOUCH_PAD_MAX];
|
uint16_t raw_val[TOUCH_PAD_MAX];
|
||||||
uint32_t filter_period;
|
uint32_t filter_period;
|
||||||
uint32_t period;
|
uint32_t period;
|
||||||
@@ -97,9 +98,7 @@ esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb)
|
|||||||
|
|
||||||
static void touch_pad_filter_cb(void *arg)
|
static void touch_pad_filter_cb(void *arg)
|
||||||
{
|
{
|
||||||
static uint32_t s_filtered_temp[TOUCH_PAD_MAX] = {0};
|
if (s_touch_pad_filter == NULL) {
|
||||||
|
|
||||||
if (s_touch_pad_filter == NULL || rtc_touch_mux == NULL) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint16_t val = 0;
|
uint16_t val = 0;
|
||||||
@@ -109,10 +108,12 @@ static void touch_pad_filter_cb(void *arg)
|
|||||||
if ((s_touch_pad_init_bit >> i) & 0x1) {
|
if ((s_touch_pad_init_bit >> i) & 0x1) {
|
||||||
_touch_pad_read(i, &val, mode);
|
_touch_pad_read(i, &val, mode);
|
||||||
s_touch_pad_filter->raw_val[i] = val;
|
s_touch_pad_filter->raw_val[i] = val;
|
||||||
s_filtered_temp[i] = s_filtered_temp[i] == 0 ? ((uint32_t)val << TOUCH_PAD_SHIFT_DEFAULT) : s_filtered_temp[i];
|
s_touch_pad_filter->filter_last_val[i] = s_touch_pad_filter->filter_last_val[i] == 0 ?
|
||||||
s_filtered_temp[i] = _touch_filter_iir((val << TOUCH_PAD_SHIFT_DEFAULT),
|
((uint32_t)val << TOUCH_PAD_SHIFT_DEFAULT) : s_touch_pad_filter->filter_last_val[i];
|
||||||
s_filtered_temp[i], TOUCH_PAD_FILTER_FACTOR_DEFAULT);
|
s_touch_pad_filter->filter_last_val[i] = _touch_filter_iir((val << TOUCH_PAD_SHIFT_DEFAULT),
|
||||||
s_touch_pad_filter->filtered_val[i] = (s_filtered_temp[i] + TOUCH_PAD_SHIFT_ROUND_DEFAULT) >> TOUCH_PAD_SHIFT_DEFAULT;
|
s_touch_pad_filter->filter_last_val[i], TOUCH_PAD_FILTER_FACTOR_DEFAULT);
|
||||||
|
s_touch_pad_filter->filtered_val[i] =
|
||||||
|
(s_touch_pad_filter->filter_last_val[i] + TOUCH_PAD_SHIFT_ROUND_DEFAULT) >> TOUCH_PAD_SHIFT_DEFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_filter_cb) {
|
if (s_filter_cb) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
idf_component_register(SRC_DIRS . param_test touch_sensor_test dac_dma_test
|
idf_component_register(SRC_DIRS . param_test dac_dma_test
|
||||||
PRIV_INCLUDE_DIRS include param_test/include touch_sensor_test/include
|
PRIV_INCLUDE_DIRS include param_test/include
|
||||||
PRIV_REQUIRES cmock test_utils driver nvs_flash
|
PRIV_REQUIRES cmock test_utils driver nvs_flash
|
||||||
esp_timer esp_adc esp_event esp_wifi spi_flash)
|
esp_timer esp_adc esp_event esp_wifi spi_flash)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(touch_sensor_v1_test)
|
2
components/driver/test_apps/touch_sensor_v1/README.md
Normal file
2
components/driver/test_apps/touch_sensor_v1/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32 |
|
||||||
|
| ----------------- | ----- |
|
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "test_app_main.c" "test_touch_v1.c"
|
||||||
|
WHOLE_ARCHIVE
|
||||||
|
)
|
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_runner.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD (-300)
|
||||||
|
|
||||||
|
static size_t before_free_8bit;
|
||||||
|
static size_t before_free_32bit;
|
||||||
|
|
||||||
|
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||||
|
{
|
||||||
|
ssize_t delta = after_free - before_free;
|
||||||
|
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||||
|
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||||
|
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
Tests for the touch sensor device driver for ESP32
|
Tests for the touch sensor device driver for ESP32
|
||||||
*/
|
*/
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "driver/touch_pad.h"
|
#include "driver/touch_pad.h"
|
||||||
@@ -17,8 +16,6 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "nvs_flash.h"
|
|
||||||
#include "test_utils.h"
|
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/rtc_cntl_struct.h"
|
#include "soc/rtc_cntl_struct.h"
|
||||||
#include "soc/sens_reg.h"
|
#include "soc/sens_reg.h"
|
||||||
@@ -28,6 +25,9 @@
|
|||||||
#include "soc/rtc_io_reg.h"
|
#include "soc/rtc_io_reg.h"
|
||||||
#include "soc/rtc_io_struct.h"
|
#include "soc/rtc_io_struct.h"
|
||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
|
#include "esp_pm.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char *TAG = "test_touch";
|
static const char *TAG = "test_touch";
|
||||||
|
|
||||||
@@ -40,9 +40,9 @@ static const char *TAG = "test_touch";
|
|||||||
TEST_ASSERT_EQUAL_UINT32(REG_GET_FIELD(RTC_IO_DATE_REG, RTC_IO_IO_DATE), RTCIO.date.date); \
|
TEST_ASSERT_EQUAL_UINT32(REG_GET_FIELD(RTC_IO_DATE_REG, RTC_IO_IO_DATE), RTCIO.date.date); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define TOUCH_READ_ERROR (100)
|
#define TOUCH_READ_ERROR_THRESH (0.1) // 10% error
|
||||||
#define TEST_TOUCH_COUNT_NUM (10)
|
#define TEST_TOUCH_COUNT_NUM (10)
|
||||||
#define TEST_TOUCH_CHANNEL (3)
|
#define TEST_TOUCH_CHANNEL (3)
|
||||||
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
|
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
|
||||||
// TOUCH_PAD_NUM0,
|
// TOUCH_PAD_NUM0,
|
||||||
// TOUCH_PAD_NUM1 is GPIO0, for download.
|
// TOUCH_PAD_NUM1 is GPIO0, for download.
|
||||||
@@ -158,7 +158,7 @@ static esp_err_t test_touch_timer_read(void)
|
|||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ static esp_err_t test_touch_filtered_read(void)
|
|||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||||
TEST_ESP_OK( touch_pad_read_filtered(touch_list[i], &touch_temp) );
|
TEST_ESP_OK( touch_pad_read_filtered(touch_list[i], &touch_temp) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp);
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp*TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||||
printf("T%d:[%4d] ", touch_list[i], touch_value);
|
printf("T%d:[%4d] ", touch_list[i], touch_value);
|
||||||
}
|
}
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
@@ -207,11 +207,20 @@ static esp_err_t test_touch_filtered_read(void)
|
|||||||
// test the basic configuration function with right parameters and error parameters
|
// test the basic configuration function with right parameters and error parameters
|
||||||
TEST_CASE("Touch Sensor all channel read test", "[touch]")
|
TEST_CASE("Touch Sensor all channel read test", "[touch]")
|
||||||
{
|
{
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_handle_t pm_lock;
|
||||||
|
TEST_ESP_OK(esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "test_touch", &pm_lock));
|
||||||
|
TEST_ESP_OK(esp_pm_lock_acquire(pm_lock));
|
||||||
|
#endif
|
||||||
TOUCH_REG_BASE_TEST();
|
TOUCH_REG_BASE_TEST();
|
||||||
test_touch_sw_read_test_runner();
|
test_touch_sw_read_test_runner();
|
||||||
TEST_ESP_OK( test_touch_sw_read() );
|
TEST_ESP_OK( test_touch_sw_read() );
|
||||||
TEST_ESP_OK( test_touch_timer_read() );
|
TEST_ESP_OK( test_touch_timer_read() );
|
||||||
TEST_ESP_OK( test_touch_filtered_read() );
|
TEST_ESP_OK( test_touch_filtered_read() );
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
|
TEST_ESP_OK(esp_pm_lock_release(pm_lock));
|
||||||
|
TEST_ESP_OK(esp_pm_lock_delete(pm_lock));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_touch_parameter(touch_pad_t pad_num, int meas_time, int slp_time, int vol_h, int vol_l, int vol_a, int slope)
|
static int test_touch_parameter(touch_pad_t pad_num, int meas_time, int slp_time, int vol_h, int vol_l, int vol_a, int slope)
|
||||||
@@ -258,7 +267,7 @@ TEST_CASE("Touch Sensor parameters test", "[touch]")
|
|||||||
touch_val[1] = test_touch_parameter(touch_list[2], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
|
touch_val[1] = test_touch_parameter(touch_list[2], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
|
||||||
TOUCH_HVOLT_2V5, TOUCH_LVOLT_0V6, TOUCH_HVOLT_ATTEN_1V,
|
TOUCH_HVOLT_2V5, TOUCH_LVOLT_0V6, TOUCH_HVOLT_ATTEN_1V,
|
||||||
TOUCH_PAD_SLOPE_DEFAULT);
|
TOUCH_PAD_SLOPE_DEFAULT);
|
||||||
touch_val[2] = test_touch_parameter(touch_list[0], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
|
touch_val[2] = test_touch_parameter(touch_list[2], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
|
||||||
TOUCH_HVOLT_2V4, TOUCH_LVOLT_0V8, TOUCH_HVOLT_ATTEN_1V5,
|
TOUCH_HVOLT_2V4, TOUCH_LVOLT_0V8, TOUCH_HVOLT_ATTEN_1V5,
|
||||||
TOUCH_PAD_SLOPE_DEFAULT);
|
TOUCH_PAD_SLOPE_DEFAULT);
|
||||||
|
|
||||||
@@ -366,5 +375,3 @@ TEST_CASE("Touch Sensor interrupt test", "[touch]")
|
|||||||
{
|
{
|
||||||
TEST_ESP_OK( test_touch_interrupt() );
|
TEST_ESP_OK( test_touch_interrupt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_IDF_TARGET_ESP32
|
|
@@ -0,0 +1,19 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.generic
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'config',
|
||||||
|
[
|
||||||
|
'release',
|
||||||
|
],
|
||||||
|
indirect=True,
|
||||||
|
)
|
||||||
|
def test_touch_sensor_v1(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('Press ENTER to see the list of tests')
|
||||||
|
dut.write('*')
|
||||||
|
dut.expect_unity_test_output(timeout=60)
|
@@ -0,0 +1,5 @@
|
|||||||
|
CONFIG_PM_ENABLE=y
|
||||||
|
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
@@ -0,0 +1,2 @@
|
|||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_ESP_TASK_WDT=n
|
@@ -0,0 +1,5 @@
|
|||||||
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(touch_sensor_v2_test)
|
2
components/driver/test_apps/touch_sensor_v2/README.md
Normal file
2
components/driver/test_apps/touch_sensor_v2/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | -------- | -------- |
|
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "test_app_main.c" "test_touch_v2.c" "touch_scope.c"
|
||||||
|
WHOLE_ARCHIVE
|
||||||
|
)
|
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_runner.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
// que_touch may be created in any case and reused among all cases so we can't free it, the threshold is left for that
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD (-500)
|
||||||
|
|
||||||
|
static size_t before_free_8bit;
|
||||||
|
static size_t before_free_32bit;
|
||||||
|
|
||||||
|
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||||
|
{
|
||||||
|
ssize_t delta = after_free - before_free;
|
||||||
|
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||||
|
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||||
|
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -8,9 +8,9 @@
|
|||||||
Tests for the touch sensor device driver for ESP32-S2 & ESP32-S3
|
Tests for the touch sensor device driver for ESP32-S2 & ESP32-S3
|
||||||
*/
|
*/
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "driver/touch_pad.h"
|
#include "driver/touch_pad.h"
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "test_utils.h"
|
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/rtc_cntl_struct.h"
|
#include "soc/rtc_cntl_struct.h"
|
||||||
#include "soc/sens_reg.h"
|
#include "soc/sens_reg.h"
|
||||||
@@ -59,7 +58,7 @@ void test_pxp_deinit_io(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TOUCH_READ_INVALID_VAL (SOC_TOUCH_PAD_THRESHOLD_MAX)
|
#define TOUCH_READ_INVALID_VAL (SOC_TOUCH_PAD_THRESHOLD_MAX)
|
||||||
#define TOUCH_READ_ERROR (100)
|
#define TOUCH_READ_ERROR_THRESH (0.1) // 10% error
|
||||||
#define TOUCH_INTR_THRESHOLD (0.1)
|
#define TOUCH_INTR_THRESHOLD (0.1)
|
||||||
#define TOUCH_EXCEED_TIME_MS (1000)
|
#define TOUCH_EXCEED_TIME_MS (1000)
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ static void printf_touch_hw_read(const char *str)
|
|||||||
printf("[%s] ", str);
|
printf("[%s] ", str);
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
touch_pad_read_raw_data(touch_list[i], &touch_value);
|
touch_pad_read_raw_data(touch_list[i], &touch_value);
|
||||||
printf("[%d]%d ", touch_list[i], touch_value);
|
printf("[%d]%"PRIu32" ", touch_list[i], touch_value);
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
}
|
}
|
||||||
@@ -125,7 +124,7 @@ static void printf_touch_benchmark_read(const char *str)
|
|||||||
printf("[%s] ", str);
|
printf("[%s] ", str);
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
printf("[%d]%d ", touch_list[i], touch_value);
|
printf("[%d]%"PRIu32" ", touch_list[i], touch_value);
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
}
|
}
|
||||||
@@ -136,7 +135,7 @@ static void printf_touch_smooth_read(const char *str)
|
|||||||
printf("[%s] ", str);
|
printf("[%s] ", str);
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
touch_pad_filter_read_smooth(touch_list[i], &touch_value);
|
touch_pad_filter_read_smooth(touch_list[i], &touch_value);
|
||||||
printf("[%d]%d ", touch_list[i], touch_value);
|
printf("[%d]%"PRIu32" ", touch_list[i], touch_value);
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
}
|
}
|
||||||
@@ -227,14 +226,14 @@ esp_err_t test_touch_sw_read(void)
|
|||||||
TEST_ESP_OK( touch_pad_sw_start() );
|
TEST_ESP_OK( touch_pad_sw_start() );
|
||||||
while (!touch_pad_meas_is_done()) ;
|
while (!touch_pad_meas_is_done()) ;
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
||||||
printf("T%d:[%4d] ", touch_list[i], touch_value[i]);
|
printf("T%d:[%4"PRIu32"] ", touch_list[i], touch_value[i]);
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
/* Check the stable of reading. */
|
/* Check the stable of reading. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
if (touch_temp[i]) {
|
if (touch_temp[i]) {
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
touch_temp[i] = touch_value[i];
|
touch_temp[i] = touch_value[i];
|
||||||
}
|
}
|
||||||
@@ -246,7 +245,7 @@ esp_err_t test_touch_sw_read(void)
|
|||||||
TEST_ESP_OK( touch_pad_sw_start() );
|
TEST_ESP_OK( touch_pad_sw_start() );
|
||||||
while (!touch_pad_meas_is_done()) ;
|
while (!touch_pad_meas_is_done()) ;
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_push[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_push[i]) );
|
||||||
printf("T%d:[%4d] ", touch_list[i], touch_push[i]);
|
printf("T%d:[%4"PRIu32"] ", touch_list[i], touch_push[i]);
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_push[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_push[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -298,12 +297,12 @@ esp_err_t test_touch_timer_read(void)
|
|||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
||||||
printf("T%d:[%4d] ", touch_list[i], touch_value[i]);
|
printf("T%d:[%4"PRIu32"] ", touch_list[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
if (touch_temp[i]) {
|
if (touch_temp[i]) {
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
touch_temp[i] = touch_value[i];
|
touch_temp[i] = touch_value[i];
|
||||||
}
|
}
|
||||||
@@ -314,7 +313,7 @@ esp_err_t test_touch_timer_read(void)
|
|||||||
/* Read the touch sensor raw data in FSM mode. */
|
/* Read the touch sensor raw data in FSM mode. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_push[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_push[i]) );
|
||||||
printf("T%d:[%4d] ", touch_list[i], touch_push[i]);
|
printf("T%d:[%4"PRIu32"] ", touch_list[i], touch_push[i]);
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_push[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_push[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -368,10 +367,10 @@ esp_err_t test_touch_filtered_read(void)
|
|||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
printf("touch filter init value:\n");
|
printf("touch filter init value:\n");
|
||||||
printf_touch_hw_read("raw ");
|
printf_touch_hw_read("raw ");
|
||||||
@@ -385,13 +384,13 @@ esp_err_t test_touch_filtered_read(void)
|
|||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
if (touch_temp[i]) {
|
if (touch_temp[i]) {
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp[i]*TOUCH_READ_ERROR_THRESH), touch_temp[i], touch_value[i]);
|
||||||
}
|
}
|
||||||
touch_temp[i] = touch_value[i];
|
touch_temp[i] = touch_value[i];
|
||||||
}
|
}
|
||||||
@@ -460,19 +459,19 @@ int test_touch_base_parameter(touch_pad_t pad_num, int meas_time, int slp_time,
|
|||||||
/* Correctness of reading. Ideal: benchmark == raw data == smooth data. */
|
/* Correctness of reading. Ideal: benchmark == raw data == smooth data. */
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_read_benchmark(pad_num, &touch_filter) );
|
TEST_ESP_OK( touch_pad_read_benchmark(pad_num, &touch_filter) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_filter, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_filter*TOUCH_READ_ERROR_THRESH), touch_filter, touch_value);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(pad_num, &touch_filter) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(pad_num, &touch_filter) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_filter, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_filter*TOUCH_READ_ERROR_THRESH), touch_filter, touch_value);
|
||||||
|
|
||||||
/* Stable of reading */
|
/* Stable of reading */
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
|
||||||
if (touch_temp) {
|
if (touch_temp) {
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp*TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||||
}
|
}
|
||||||
touch_temp = touch_value;
|
touch_temp = touch_value;
|
||||||
|
|
||||||
printf("T%d:[%4d] ", pad_num, touch_value);
|
printf("T%d:[%4"PRIu32"] ", pad_num, touch_value);
|
||||||
val_sum += touch_value; // For check.
|
val_sum += touch_value; // For check.
|
||||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
@@ -544,7 +543,7 @@ static esp_err_t test_touch_check_ch_touched(uint32_t test_ch_num, uint32_t exce
|
|||||||
while (1) {
|
while (1) {
|
||||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) {
|
||||||
printf("0x%x, ", evt.pad_status);
|
printf("0x%"PRIx32", ", evt.pad_status);
|
||||||
if (test_ch_num == __builtin_popcount(evt.pad_status)) {
|
if (test_ch_num == __builtin_popcount(evt.pad_status)) {
|
||||||
ret = ESP_OK;
|
ret = ESP_OK;
|
||||||
break;
|
break;
|
||||||
@@ -552,7 +551,7 @@ static esp_err_t test_touch_check_ch_touched(uint32_t test_ch_num, uint32_t exce
|
|||||||
} else if (evt.intr_mask & (TOUCH_PAD_INTR_MASK_DONE | TOUCH_PAD_INTR_MASK_SCAN_DONE)) {
|
} else if (evt.intr_mask & (TOUCH_PAD_INTR_MASK_DONE | TOUCH_PAD_INTR_MASK_SCAN_DONE)) {
|
||||||
continue;
|
continue;
|
||||||
} else { // If the interrupt type error, test error.
|
} else { // If the interrupt type error, test error.
|
||||||
ESP_LOGI(TAG, "Touch[%d] intr error, status %d, evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
ESP_LOGI(TAG, "Touch[%"PRIu32"] intr error, status %"PRIx32", evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -575,7 +574,7 @@ static esp_err_t test_touch_check_ch_released(uint32_t test_ch_num, uint32_t exc
|
|||||||
while (1) {
|
while (1) {
|
||||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_INACTIVE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_INACTIVE) {
|
||||||
printf("0x%x, ", evt.pad_status);
|
printf("0x%"PRIx32", ", evt.pad_status);
|
||||||
if ((TEST_TOUCH_CHANNEL - test_ch_num) == __builtin_popcount(evt.pad_status)) {
|
if ((TEST_TOUCH_CHANNEL - test_ch_num) == __builtin_popcount(evt.pad_status)) {
|
||||||
ret = ESP_OK;
|
ret = ESP_OK;
|
||||||
break;
|
break;
|
||||||
@@ -583,7 +582,7 @@ static esp_err_t test_touch_check_ch_released(uint32_t test_ch_num, uint32_t exc
|
|||||||
} else if (evt.intr_mask & (TOUCH_PAD_INTR_MASK_DONE | TOUCH_PAD_INTR_MASK_SCAN_DONE)) {
|
} else if (evt.intr_mask & (TOUCH_PAD_INTR_MASK_DONE | TOUCH_PAD_INTR_MASK_SCAN_DONE)) {
|
||||||
continue;
|
continue;
|
||||||
} else { // If the interrupt type error, test error.
|
} else { // If the interrupt type error, test error.
|
||||||
ESP_LOGI(TAG, "Touch[%d] intr error, status %d, evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
ESP_LOGI(TAG, "Touch[%"PRIu32"] intr error, status %"PRIx32", evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -607,7 +606,7 @@ static esp_err_t test_touch_check_ch_touched_with_proximity(uint32_t test_ch_num
|
|||||||
while (1) {
|
while (1) {
|
||||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) {
|
||||||
printf("0x%x, ", evt.pad_status);
|
printf("0x%"PRIx32", ", evt.pad_status);
|
||||||
if (test_ch_num == __builtin_popcount(evt.pad_status)) {
|
if (test_ch_num == __builtin_popcount(evt.pad_status)) {
|
||||||
ret = ESP_OK;
|
ret = ESP_OK;
|
||||||
break;
|
break;
|
||||||
@@ -618,14 +617,14 @@ static esp_err_t test_touch_check_ch_touched_with_proximity(uint32_t test_ch_num
|
|||||||
if (BIT(i) & ch_mask) {
|
if (BIT(i) & ch_mask) {
|
||||||
if (evt.pad_num == i) {
|
if (evt.pad_num == i) {
|
||||||
if (count == evt.slp_proxi_cnt) {
|
if (count == evt.slp_proxi_cnt) {
|
||||||
esp_rom_printf("priximity base(%d) cnt(%d)\n", evt.slp_proxi_base, evt.slp_proxi_cnt);
|
esp_rom_printf("priximity base(%"PRIu32") cnt(%"PRIu32")\n", evt.slp_proxi_base, evt.slp_proxi_cnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else { // If the interrupt type error, test error.
|
} else { // If the interrupt type error, test error.
|
||||||
ESP_LOGI(TAG, "Touch[%d] intr error, status %d, evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
ESP_LOGI(TAG, "Touch[%"PRIu32"] intr error, status %"PRIx32", evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
||||||
continue;;
|
continue;;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -649,7 +648,7 @@ static esp_err_t test_touch_check_ch_released_with_proximity(uint32_t test_ch_nu
|
|||||||
while (1) {
|
while (1) {
|
||||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_INACTIVE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_INACTIVE) {
|
||||||
printf("0x%x, ", evt.pad_status);
|
printf("0x%"PRIx32", ", evt.pad_status);
|
||||||
if ((TEST_TOUCH_CHANNEL - test_ch_num) == __builtin_popcount(evt.pad_status)) {
|
if ((TEST_TOUCH_CHANNEL - test_ch_num) == __builtin_popcount(evt.pad_status)) {
|
||||||
ret = ESP_OK;
|
ret = ESP_OK;
|
||||||
break;
|
break;
|
||||||
@@ -660,14 +659,14 @@ static esp_err_t test_touch_check_ch_released_with_proximity(uint32_t test_ch_nu
|
|||||||
if (BIT(i) & ch_mask) {
|
if (BIT(i) & ch_mask) {
|
||||||
if (evt.pad_num == i) {
|
if (evt.pad_num == i) {
|
||||||
if (count == evt.slp_proxi_cnt) {
|
if (count == evt.slp_proxi_cnt) {
|
||||||
esp_rom_printf("priximity base(%d) cnt(%d)\n", evt.slp_proxi_base, evt.slp_proxi_cnt);
|
esp_rom_printf("priximity base(%"PRIu32") cnt(%"PRIu32")\n", evt.slp_proxi_base, evt.slp_proxi_cnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else { // If the interrupt type error, test error.
|
} else { // If the interrupt type error, test error.
|
||||||
ESP_LOGI(TAG, "Touch[%d] intr error, status %d, evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
ESP_LOGI(TAG, "Touch[%"PRIu32"] intr error, status %"PRIx32", evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
||||||
continue;;
|
continue;;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -705,7 +704,7 @@ static esp_err_t test_touch_check_ch_intr_scan_done(void)
|
|||||||
} else if (evt.intr_mask & (TOUCH_PAD_INTR_MASK_DONE | TOUCH_PAD_INTR_MASK_SCAN_DONE)) {
|
} else if (evt.intr_mask & (TOUCH_PAD_INTR_MASK_DONE | TOUCH_PAD_INTR_MASK_SCAN_DONE)) {
|
||||||
continue;
|
continue;
|
||||||
} else { // If the interrupt type error, test error.
|
} else { // If the interrupt type error, test error.
|
||||||
ESP_LOGI(TAG, "Touch[%d] intr error, status %d, evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
ESP_LOGI(TAG, "Touch[%"PRIu32"] intr error, status %"PRIx32", evt_msk0x%x", evt.pad_num, evt.pad_status, evt.intr_mask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -737,7 +736,7 @@ static esp_err_t test_touch_check_ch_intr_timeout(touch_pad_t pad_num)
|
|||||||
touch_pad_timeout_resume();
|
touch_pad_timeout_resume();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
esp_rom_printf("-timeout %x T[%d] status %d, evt_msk %x -\n",
|
esp_rom_printf("-timeout %x T[%"PRIu32"] status %"PRIx32", evt_msk %x -\n",
|
||||||
s_touch_timeout_mask, evt.pad_num, evt.pad_status, evt.intr_mask);
|
s_touch_timeout_mask, evt.pad_num, evt.pad_status, evt.intr_mask);
|
||||||
touch_pad_timeout_resume();
|
touch_pad_timeout_resume();
|
||||||
}
|
}
|
||||||
@@ -763,7 +762,6 @@ static void test_touch_intr_cb(void *arg)
|
|||||||
evt.pad_num = touch_pad_get_current_meas_channel();
|
evt.pad_num = touch_pad_get_current_meas_channel();
|
||||||
|
|
||||||
if (!evt.intr_mask) {
|
if (!evt.intr_mask) {
|
||||||
esp_rom_printf(".");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) {
|
||||||
@@ -777,7 +775,6 @@ static void test_touch_intr_cb(void *arg)
|
|||||||
}
|
}
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) {
|
||||||
s_touch_timeout_mask |= (BIT(evt.pad_num));
|
s_touch_timeout_mask |= (BIT(evt.pad_num));
|
||||||
esp_rom_printf("-%dtout-", SENS.sar_touch_status0.touch_scan_curr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xQueueSendFromISR(que_touch, &evt, &task_awoken);
|
xQueueSendFromISR(que_touch, &evt, &task_awoken);
|
||||||
@@ -832,7 +829,7 @@ esp_err_t test_touch_interrupt(void)
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"",
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,7 +897,7 @@ esp_err_t test_touch_scan_done_interrupt(void)
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -965,7 +962,7 @@ esp_err_t test_touch_timeout_interrupt(void)
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"",
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
/* Set timeout parameter */
|
/* Set timeout parameter */
|
||||||
@@ -1011,7 +1008,7 @@ TEST_CASE("Touch Sensor interrupt test (active, inactive, scan_done, timeout)",
|
|||||||
static void test_touch_measure_step(uint32_t step)
|
static void test_touch_measure_step(uint32_t step)
|
||||||
{
|
{
|
||||||
/* Fake the process of debounce. */
|
/* Fake the process of debounce. */
|
||||||
// printf("measure cnt %d: [ ", step);
|
// printf("measure cnt %"PRIu32": [ ", step);
|
||||||
for (int i = 0; i < step; i++) {
|
for (int i = 0; i < step; i++) {
|
||||||
for (int j = 0; j < TEST_TOUCH_CHANNEL; j++) {
|
for (int j = 0; j < TEST_TOUCH_CHANNEL; j++) {
|
||||||
TEST_ESP_OK( touch_pad_sw_start() );
|
TEST_ESP_OK( touch_pad_sw_start() );
|
||||||
@@ -1067,7 +1064,7 @@ esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
|||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1132,7 +1129,7 @@ esp_err_t test_touch_filter_parameter_reset(int reset_cnt)
|
|||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1264,7 @@ esp_err_t test_touch_filter_parameter_jitter(int jitter_step)
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
//set interrupt threshold.
|
//set interrupt threshold.
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1400,7 +1397,7 @@ TEST_CASE("Touch Sensor denoise test (cap, level)", "[touch]")
|
|||||||
} else {
|
} else {
|
||||||
/* If the value of denoise is approximately 0,
|
/* If the value of denoise is approximately 0,
|
||||||
The difference between touch reading is very small. Should skip value test. */
|
The difference between touch reading is very small. Should skip value test. */
|
||||||
ESP_LOGI(TAG, "denoise value is %d", denoise_val[0]);
|
ESP_LOGI(TAG, "denoise value is %"PRIu32"", denoise_val[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "*********** touch filter denoise cap level test ********************");
|
ESP_LOGI(TAG, "*********** touch filter denoise cap level test ********************");
|
||||||
@@ -1416,7 +1413,7 @@ TEST_CASE("Touch Sensor denoise test (cap, level)", "[touch]")
|
|||||||
printf("denoise read: ");
|
printf("denoise read: ");
|
||||||
for (int i = 0; i < TOUCH_PAD_DENOISE_CAP_MAX - 1; i++) {
|
for (int i = 0; i < TOUCH_PAD_DENOISE_CAP_MAX - 1; i++) {
|
||||||
TEST_ASSERT_GREATER_OR_EQUAL(denoise_val[i], denoise_val[i + 1]);
|
TEST_ASSERT_GREATER_OR_EQUAL(denoise_val[i], denoise_val[i + 1]);
|
||||||
printf("%d ", denoise_val[i]);
|
printf("%"PRIu32" ", denoise_val[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
@@ -1557,11 +1554,11 @@ esp_err_t test_touch_proximity(int meas_num)
|
|||||||
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i],
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i],
|
||||||
meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)) );
|
meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)) );
|
||||||
ESP_LOGI(TAG, "proximity pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
ESP_LOGI(TAG, "proximity pad [%d] base %"PRIu32", thresh %"PRIu32"", touch_list[i], touch_value,
|
||||||
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
||||||
} else {
|
} else {
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "touch pad [%d] base %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1653,7 +1650,7 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"",
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1667,13 +1664,13 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
|||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_temp) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_temp) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp*TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_temp) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_temp) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp*TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
if (touch_temp) {
|
if (touch_temp) {
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN((uint32_t)((float)touch_temp*TOUCH_READ_ERROR_THRESH), touch_temp, touch_value);
|
||||||
}
|
}
|
||||||
touch_temp = touch_value;
|
touch_temp = touch_value;
|
||||||
}
|
}
|
||||||
@@ -1754,18 +1751,18 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
|||||||
if (touch_list[i] == sleep_pad) {
|
if (touch_list[i] == sleep_pad) {
|
||||||
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
||||||
touch_pad_sleep_set_threshold(sleep_pad, meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD));
|
touch_pad_sleep_set_threshold(sleep_pad, meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD));
|
||||||
ESP_LOGI(TAG, "Sleep pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
ESP_LOGI(TAG, "Sleep pad [%d] base %"PRIu32", thresh %"PRIu32"", touch_list[i], touch_value,
|
||||||
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
||||||
} else if (touch_list[i] == sleep_pad) {
|
} else if (touch_list[i] == sleep_pad) {
|
||||||
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
||||||
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
||||||
touch_pad_sleep_set_threshold(sleep_pad, meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD));
|
touch_pad_sleep_set_threshold(sleep_pad, meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD));
|
||||||
ESP_LOGI(TAG, "proximity pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
ESP_LOGI(TAG, "proximity pad [%d] base %"PRIu32", thresh %"PRIu32"", touch_list[i], touch_value,
|
||||||
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
||||||
} else {
|
} else {
|
||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "touch pad [%d] base %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1787,7 +1784,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"",
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
/* Sleep channel setting */
|
/* Sleep channel setting */
|
||||||
@@ -1808,7 +1805,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
|||||||
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_get_threshold(sleep_pad, &touch_thres) );
|
TEST_ESP_OK( touch_pad_sleep_get_threshold(sleep_pad, &touch_thres) );
|
||||||
printf("touch slp smooth %d, base %d, proxi %d cnt %d thres%d status 0x%x\n",
|
printf("touch slp smooth %"PRIu32", base %"PRIu32", proxi %"PRIu32" cnt %"PRIu32" thres%"PRIu32" status 0x%"PRIx32"\n",
|
||||||
smooth, touch_value, measure_out, proximity_cnt,
|
smooth, touch_value, measure_out, proximity_cnt,
|
||||||
touch_thres, touch_pad_get_status());
|
touch_thres, touch_pad_get_status());
|
||||||
}
|
}
|
||||||
@@ -1820,7 +1817,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
|||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
||||||
printf("touch slp smooth %d, base %d, proxi %d cnt %d status 0x%x\n",
|
printf("touch slp smooth %"PRIu32", base %"PRIu32", proxi %"PRIu32" cnt %"PRIu32" status 0x%"PRIx32"\n",
|
||||||
smooth, touch_value, measure_out, proximity_cnt, touch_pad_get_status());
|
smooth, touch_value, measure_out, proximity_cnt, touch_pad_get_status());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1899,7 +1896,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"",
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1915,7 +1912,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
|||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
printf("touch slp raw %d, smooth %d, base %d, status 0x%x\n", raw, smooth, touch_value, touch_pad_get_status());
|
printf("touch slp raw %"PRIu32", smooth %"PRIu32", base %"PRIu32", status 0x%"PRIx32"\n", raw, smooth, touch_value, touch_pad_get_status());
|
||||||
|
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
@@ -1923,11 +1920,13 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
|||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
printf("touch slp raw %d, smooth %d, base %d, status 0x%x\n", raw, smooth, touch_value, touch_pad_get_status());
|
printf("touch slp raw %"PRIu32", smooth %"PRIu32", base %"PRIu32", status 0x%"PRIx32"\n", raw, smooth, touch_value, touch_pad_get_status());
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32S3) //TODO: IDF-5218
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
|
|
||||||
@@ -1944,18 +1943,18 @@ static void test_deep_sleep_init(void)
|
|||||||
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
|
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
|
||||||
if (wakeup_pin_mask != 0) {
|
if (wakeup_pin_mask != 0) {
|
||||||
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
|
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
|
||||||
printf("Wake up from GPIO %d\n", pin);
|
printf("Wake up from GPIO %"PRIu32"\n", pin);
|
||||||
} else {
|
} else {
|
||||||
printf("Wake up from GPIO\n");
|
printf("Wake up from GPIO\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESP_SLEEP_WAKEUP_TIMER: {
|
case ESP_SLEEP_WAKEUP_TIMER: {
|
||||||
printf("Wake up from timer. Time spent in deep sleep: %dms\n", sleep_time_ms);
|
printf("Wake up from timer. Time spent in deep sleep: %"PRIu32"ms\n", sleep_time_ms);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESP_SLEEP_WAKEUP_TOUCHPAD: {
|
case ESP_SLEEP_WAKEUP_TOUCHPAD: {
|
||||||
printf("Wake up from touch on pad %d\n", esp_sleep_get_touchpad_wakeup_status());
|
printf("Wake up from touch on pad %"PRIu32"\n", esp_sleep_get_touchpad_wakeup_status());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESP_SLEEP_WAKEUP_UNDEFINED:
|
case ESP_SLEEP_WAKEUP_UNDEFINED:
|
||||||
@@ -1978,10 +1977,6 @@ static void test_deep_sleep_init(void)
|
|||||||
|
|
||||||
TEST_CASE("Touch Sensor sleep pad wakeup deep sleep test", "[touch][ignore]")
|
TEST_CASE("Touch Sensor sleep pad wakeup deep sleep test", "[touch][ignore]")
|
||||||
{
|
{
|
||||||
//TODO: IDF-5218
|
|
||||||
#if TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2)
|
|
||||||
abort();
|
|
||||||
#endif //TEMPORARY_DISABLED_FOR_TARGETS(..)
|
|
||||||
test_deep_sleep_init();
|
test_deep_sleep_init();
|
||||||
|
|
||||||
/* Change the work duty of touch sensor to reduce current. */
|
/* Change the work duty of touch sensor to reduce current. */
|
||||||
@@ -1996,6 +1991,7 @@ TEST_CASE("Touch Sensor sleep pad wakeup deep sleep test", "[touch][ignore]")
|
|||||||
|
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
}
|
}
|
||||||
|
#endif //TEMPORARY_DISABLED_FOR_TARGETS(..)
|
||||||
|
|
||||||
#include "touch_scope.h"
|
#include "touch_scope.h"
|
||||||
/*
|
/*
|
||||||
@@ -2059,7 +2055,7 @@ void test_touch_slope_debug(int pad_num)
|
|||||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %"PRIu32", smooth %"PRIu32", thresh %"PRIu32"", \
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_THRESHOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2139,5 +2135,3 @@ void test_touch_slope_debug(int pad_num)
|
|||||||
#endif
|
#endif
|
||||||
TEST_ESP_OK( touch_pad_deinit() );
|
TEST_ESP_OK( touch_pad_deinit() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
@@ -0,0 +1,20 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32s2
|
||||||
|
@pytest.mark.esp32s3
|
||||||
|
@pytest.mark.generic
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'config',
|
||||||
|
[
|
||||||
|
'release',
|
||||||
|
],
|
||||||
|
indirect=True,
|
||||||
|
)
|
||||||
|
def test_touch_sensor_v2(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('Press ENTER to see the list of tests')
|
||||||
|
dut.write('*')
|
||||||
|
dut.expect_unity_test_output(timeout=120)
|
@@ -0,0 +1,5 @@
|
|||||||
|
CONFIG_PM_ENABLE=y
|
||||||
|
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
@@ -0,0 +1,2 @@
|
|||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_ESP_TASK_WDT=n
|
6
components/touch_element/.build-test-rules.yml
Normal file
6
components/touch_element/.build-test-rules.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/touch_element/test_apps:
|
||||||
|
enable:
|
||||||
|
- if: IDF_TARGET in ["esp32s2", "esp32s3"]
|
||||||
|
reason: only supports esp32s2 and esp32s3
|
@@ -8,5 +8,4 @@ if(IDF_TARGET IN_LIST TOUCH_ELEMENT_COMPATIBLE_TARGETS)
|
|||||||
INCLUDE_DIRS include
|
INCLUDE_DIRS include
|
||||||
REQUIRES driver
|
REQUIRES driver
|
||||||
PRIV_REQUIRES esp_timer)
|
PRIV_REQUIRES esp_timer)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
endif()
|
endif()
|
||||||
|
@@ -1,17 +1,8 @@
|
|||||||
// Copyright 2016-2020 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "touch_element/touch_element.h"
|
#include "touch_element/touch_element.h"
|
||||||
|
@@ -1,16 +1,8 @@
|
|||||||
// Copyright 2016-2020 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
set(TOUCH_ELEMENT_COMPATIBLE_TARGETS "esp32s2" "esp32s3")
|
|
||||||
|
|
||||||
if(IDF_TARGET IN_LIST TOUCH_ELEMENT_COMPATIBLE_TARGETS)
|
|
||||||
idf_component_register(SRCS "test_touch_element.c"
|
|
||||||
"test_touch_button.c"
|
|
||||||
"test_touch_slider.c"
|
|
||||||
"test_touch_matrix.c"
|
|
||||||
PRIV_REQUIRES unity touch_element)
|
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
endif()
|
|
5
components/touch_element/test_apps/CMakeLists.txt
Normal file
5
components/touch_element/test_apps/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(touch_element_test)
|
2
components/touch_element/test_apps/README.md
Normal file
2
components/touch_element/test_apps/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | -------- | -------- |
|
4
components/touch_element/test_apps/main/CMakeLists.txt
Normal file
4
components/touch_element/test_apps/main/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
idf_component_register(SRCS "test_app_main.c" "test_touch_element.c" "test_touch_button.c"
|
||||||
|
"test_touch_slider.c" "test_touch_matrix.c"
|
||||||
|
WHOLE_ARCHIVE
|
||||||
|
)
|
43
components/touch_element/test_apps/main/test_app_main.c
Normal file
43
components/touch_element/test_apps/main/test_app_main.c
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_runner.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
|
// Some resources are lazy allocated in gpio/dedicated_gpio/delta_sigma driver, the threshold is left for that case
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD (-400)
|
||||||
|
|
||||||
|
static size_t before_free_8bit;
|
||||||
|
static size_t before_free_32bit;
|
||||||
|
|
||||||
|
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||||
|
{
|
||||||
|
ssize_t delta = after_free - before_free;
|
||||||
|
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||||
|
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||||
|
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
/* ---------------------------------------------------------- README ------------------------------------------------
|
/* ---------------------------------------------------------- README ------------------------------------------------
|
||||||
* This doc is aimed at explain some important code block and do some records for the test result, if developer or
|
* This doc is aimed at explain some important code block and do some records for the test result, if developer or
|
||||||
* test-owner has some question in reading this code implementation, please read it first.
|
* test-owner has some question in reading this code implementation, please read it first.
|
||||||
@@ -312,22 +317,22 @@ static void test_integrat_btn_sld_mat(void)
|
|||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
printf("Integration test... (%d/30)\n", i + 1);
|
printf("Integration test... (%d/30)\n", i + 1);
|
||||||
touch_elem_message_t valid_message;
|
touch_elem_message_t valid_message;
|
||||||
|
touch_button_message_t button_message;
|
||||||
|
touch_slider_message_t slider_message;
|
||||||
|
touch_matrix_message_t matrix_message;
|
||||||
|
|
||||||
valid_message.element_type = (random() % (TOUCH_ELEM_TYPE_MATRIX + 1));
|
valid_message.element_type = (random() % (TOUCH_ELEM_TYPE_MATRIX + 1));
|
||||||
if (valid_message.element_type == TOUCH_ELEM_TYPE_BUTTON) {
|
if (valid_message.element_type == TOUCH_ELEM_TYPE_BUTTON) {
|
||||||
uint32_t button_index = random() % BUTTON_CHANNEL_NUM;
|
uint32_t button_index = random() % BUTTON_CHANNEL_NUM;
|
||||||
valid_message.handle = button_handle[button_index];
|
valid_message.handle = button_handle[button_index];
|
||||||
touch_button_message_t button_message = {
|
button_message.event = TOUCH_BUTTON_EVT_ON_PRESS;
|
||||||
.event = TOUCH_BUTTON_EVT_ON_PRESS
|
|
||||||
};
|
|
||||||
memcpy(valid_message.child_msg, &button_message, sizeof(button_message)); //Construct child message
|
memcpy(valid_message.child_msg, &button_message, sizeof(button_message)); //Construct child message
|
||||||
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
||||||
test_button_event_simulator(valid_message.handle, button_message.event);
|
test_button_event_simulator(valid_message.handle, button_message.event);
|
||||||
} else if (valid_message.element_type == TOUCH_ELEM_TYPE_SLIDER) {
|
} else if (valid_message.element_type == TOUCH_ELEM_TYPE_SLIDER) {
|
||||||
valid_message.handle = slider_handle;
|
valid_message.handle = slider_handle;
|
||||||
touch_slider_message_t slider_message = {
|
slider_message.event = TOUCH_SLIDER_EVT_ON_PRESS;
|
||||||
.event = TOUCH_SLIDER_EVT_ON_PRESS,
|
slider_message.position = 0; //No check
|
||||||
.position = 0 //No check
|
|
||||||
};
|
|
||||||
memcpy(valid_message.child_msg, &slider_message, sizeof(slider_message)); //Construct child message
|
memcpy(valid_message.child_msg, &slider_message, sizeof(slider_message)); //Construct child message
|
||||||
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
||||||
test_slider_event_simulator(valid_message.handle, slider_message.event, 1);
|
test_slider_event_simulator(valid_message.handle, slider_message.event, 1);
|
||||||
@@ -335,33 +340,30 @@ static void test_integrat_btn_sld_mat(void)
|
|||||||
uint32_t matrix_x_axis_index = random() % MATRIX_CHANNEL_NUM_X;
|
uint32_t matrix_x_axis_index = random() % MATRIX_CHANNEL_NUM_X;
|
||||||
uint32_t matrix_y_axis_index = random() % MATRIX_CHANNEL_NUM_Y;
|
uint32_t matrix_y_axis_index = random() % MATRIX_CHANNEL_NUM_Y;
|
||||||
valid_message.handle = matrix_handle;
|
valid_message.handle = matrix_handle;
|
||||||
touch_matrix_message_t matrix_message = {
|
matrix_message.event = TOUCH_MATRIX_EVT_ON_PRESS;
|
||||||
.event = TOUCH_MATRIX_EVT_ON_PRESS,
|
matrix_message.position.x_axis = matrix_x_axis_index;
|
||||||
.position.x_axis = matrix_x_axis_index,
|
matrix_message.position.y_axis = matrix_y_axis_index;
|
||||||
.position.y_axis = matrix_y_axis_index,
|
matrix_message.position.index = matrix_x_axis_index * MATRIX_CHANNEL_NUM_Y + matrix_y_axis_index;
|
||||||
.position.index = matrix_x_axis_index * MATRIX_CHANNEL_NUM_Y + matrix_y_axis_index
|
|
||||||
};
|
|
||||||
memcpy(valid_message.child_msg, &matrix_message, sizeof(matrix_message)); //Construct child message
|
memcpy(valid_message.child_msg, &matrix_message, sizeof(matrix_message)); //Construct child message
|
||||||
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
||||||
test_matrix_event_simulator(valid_message.handle, matrix_message.event, matrix_message.position.index);
|
test_matrix_event_simulator(valid_message.handle, matrix_message.event, matrix_message.position.index);
|
||||||
|
} else {
|
||||||
|
TEST_ABORT();
|
||||||
}
|
}
|
||||||
os_ret = xSemaphoreTake(monitor.response_sig_handle, pdMS_TO_TICKS(500));
|
os_ret = xSemaphoreTake(monitor.response_sig_handle, pdMS_TO_TICKS(500));
|
||||||
TEST_ASSERT_MESSAGE(os_ret == pdPASS, "response queue timeout (500ms)");
|
TEST_ASSERT_MESSAGE(os_ret == pdPASS, "response queue timeout (500ms)");
|
||||||
|
|
||||||
if (valid_message.element_type == TOUCH_ELEM_TYPE_BUTTON) {
|
if (valid_message.element_type == TOUCH_ELEM_TYPE_BUTTON) {
|
||||||
touch_button_message_t button_message;
|
|
||||||
button_message.event = TOUCH_BUTTON_EVT_ON_RELEASE;
|
button_message.event = TOUCH_BUTTON_EVT_ON_RELEASE;
|
||||||
memcpy(valid_message.child_msg, &button_message, sizeof(button_message));
|
memcpy(valid_message.child_msg, &button_message, sizeof(button_message));
|
||||||
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
||||||
test_button_event_simulator(valid_message.handle, button_message.event);
|
test_button_event_simulator(valid_message.handle, button_message.event);
|
||||||
} else if (valid_message.element_type == TOUCH_ELEM_TYPE_SLIDER) {
|
} else if (valid_message.element_type == TOUCH_ELEM_TYPE_SLIDER) {
|
||||||
touch_slider_message_t slider_message;
|
|
||||||
slider_message.event = TOUCH_SLIDER_EVT_ON_RELEASE;
|
slider_message.event = TOUCH_SLIDER_EVT_ON_RELEASE;
|
||||||
memcpy(valid_message.child_msg, &slider_message, sizeof(slider_message));
|
memcpy(valid_message.child_msg, &slider_message, sizeof(slider_message));
|
||||||
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
||||||
test_slider_event_simulator(valid_message.handle, slider_message.event, 1);
|
test_slider_event_simulator(valid_message.handle, slider_message.event, 1);
|
||||||
} else if (valid_message.element_type == TOUCH_ELEM_TYPE_MATRIX) {
|
} else if (valid_message.element_type == TOUCH_ELEM_TYPE_MATRIX) {
|
||||||
touch_matrix_message_t matrix_message;
|
|
||||||
matrix_message.event = TOUCH_MATRIX_EVT_ON_RELEASE;
|
matrix_message.event = TOUCH_MATRIX_EVT_ON_RELEASE;
|
||||||
memcpy(valid_message.child_msg, &matrix_message, sizeof(matrix_message));
|
memcpy(valid_message.child_msg, &matrix_message, sizeof(matrix_message));
|
||||||
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
xQueueSend(monitor.valid_msg_handle, &valid_message, portMAX_DELAY);
|
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
21
components/touch_element/test_apps/pytest_touch_element.py
Normal file
21
components/touch_element/test_apps/pytest_touch_element.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32s2
|
||||||
|
@pytest.mark.esp32s3
|
||||||
|
@pytest.mark.generic
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'config',
|
||||||
|
[
|
||||||
|
'opt_o0',
|
||||||
|
'opt_o2'
|
||||||
|
],
|
||||||
|
indirect=True,
|
||||||
|
)
|
||||||
|
def test_touch_element(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('Press ENTER to see the list of tests')
|
||||||
|
dut.write('*')
|
||||||
|
dut.expect_unity_test_output(timeout=120)
|
1
components/touch_element/test_apps/sdkconfig.ci.opt_o0
Normal file
1
components/touch_element/test_apps/sdkconfig.ci.opt_o0
Normal file
@@ -0,0 +1 @@
|
|||||||
|
CONFIG_COMPILER_OPTIMIZATION_NONE=y
|
1
components/touch_element/test_apps/sdkconfig.ci.opt_o2
Normal file
1
components/touch_element/test_apps/sdkconfig.ci.opt_o2
Normal file
@@ -0,0 +1 @@
|
|||||||
|
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
3
components/touch_element/test_apps/sdkconfig.defaults
Normal file
3
components/touch_element/test_apps/sdkconfig.defaults
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_ESP_TASK_WDT=n
|
||||||
|
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
@@ -1,17 +1,12 @@
|
|||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
/*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// You may obtain a copy of the License at
|
*
|
||||||
//
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
*/
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
@@ -402,7 +403,7 @@ static void te_proc_timer_cb(void *arg)
|
|||||||
ESP_LOGD(TE_DEBUG_TAG, "Set waterproof shield level");
|
ESP_LOGD(TE_DEBUG_TAG, "Set waterproof shield level");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGD(TE_DEBUG_TAG, "read denoise channel %d", s_te_obj->denoise_channel_raw);
|
ESP_LOGD(TE_DEBUG_TAG, "read denoise channel %"PRIu32, s_te_obj->denoise_channel_raw);
|
||||||
} else if (te_intr_msg.intr_type == TE_INTR_TIMEOUT) { //Timeout processing
|
} else if (te_intr_msg.intr_type == TE_INTR_TIMEOUT) { //Timeout processing
|
||||||
touch_pad_timeout_resume();
|
touch_pad_timeout_resume();
|
||||||
}
|
}
|
||||||
@@ -516,7 +517,7 @@ esp_err_t te_dev_set_threshold(te_dev_t *device)
|
|||||||
{
|
{
|
||||||
uint32_t smo_val = te_read_smooth_signal(device->channel);
|
uint32_t smo_val = te_read_smooth_signal(device->channel);
|
||||||
esp_err_t ret = touch_pad_set_thresh(device->channel, device->sens * smo_val);
|
esp_err_t ret = touch_pad_set_thresh(device->channel, device->sens * smo_val);
|
||||||
ESP_LOGD(TE_DEBUG_TAG, "channel: %d, smo_val: %d", device->channel, smo_val);
|
ESP_LOGD(TE_DEBUG_TAG, "channel: %"PRIu8", smo_val: %"PRIu32, device->channel, smo_val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,14 +813,14 @@ static bool waterproof_channel_check(touch_pad_t channel_num)
|
|||||||
te_waterproof_handle_t waterproof_handle = s_te_obj->waterproof_handle;
|
te_waterproof_handle_t waterproof_handle = s_te_obj->waterproof_handle;
|
||||||
if (waterproof_shield_check_state()) {
|
if (waterproof_shield_check_state()) {
|
||||||
if (channel_num == waterproof_handle->shield_channel) {
|
if (channel_num == waterproof_handle->shield_channel) {
|
||||||
ESP_LOGE(TE_TAG, "TOUCH_PAD_NUM%d has been used for waterproof shield channel,"
|
ESP_LOGE(TE_TAG, "TOUCH_PAD_NUM%"PRIu8" has been used for waterproof shield channel,"
|
||||||
" please change the touch sensor channel or disable waterproof", channel_num);
|
" please change the touch sensor channel or disable waterproof", channel_num);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (waterproof_guard_check_state()) {
|
if (waterproof_guard_check_state()) {
|
||||||
if (channel_num == waterproof_handle->guard_device->channel) {
|
if (channel_num == waterproof_handle->guard_device->channel) {
|
||||||
ESP_LOGE(TE_TAG, "TOUCH_PAD_NUM%d has been used for waterproof guard channel,"
|
ESP_LOGE(TE_TAG, "TOUCH_PAD_NUM%"PRIu8" has been used for waterproof guard channel,"
|
||||||
" please change the touch sensor channel or disable waterproof", channel_num);
|
" please change the touch sensor channel or disable waterproof", channel_num);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,12 @@
|
|||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
/*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// You may obtain a copy of the License at
|
*
|
||||||
//
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
*/
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
@@ -575,7 +570,7 @@ static void matrix_proc_state(te_matrix_handle_t matrix_handle)
|
|||||||
if (matrix_handle->current_state == TE_STATE_PRESS) {
|
if (matrix_handle->current_state == TE_STATE_PRESS) {
|
||||||
if (matrix_handle->last_state == TE_STATE_IDLE) { //IDLE ---> Press = On_Press
|
if (matrix_handle->last_state == TE_STATE_IDLE) { //IDLE ---> Press = On_Press
|
||||||
matrix_update_position(matrix_handle, press_pos);
|
matrix_update_position(matrix_handle, press_pos);
|
||||||
ESP_LOGD(TE_DEBUG_TAG, "matrix press (%d, %d)", matrix_handle->position.x_axis, matrix_handle->position.y_axis);
|
ESP_LOGD(TE_DEBUG_TAG, "matrix press (%"PRIu8", %"PRIu8")", matrix_handle->position.x_axis, matrix_handle->position.y_axis);
|
||||||
if (event_mask & TOUCH_ELEM_EVENT_ON_PRESS) {
|
if (event_mask & TOUCH_ELEM_EVENT_ON_PRESS) {
|
||||||
matrix_handle->event = TOUCH_MATRIX_EVT_ON_PRESS;
|
matrix_handle->event = TOUCH_MATRIX_EVT_ON_PRESS;
|
||||||
matrix_dispatch(matrix_handle, dispatch_method);
|
matrix_dispatch(matrix_handle, dispatch_method);
|
||||||
@@ -583,7 +578,7 @@ static void matrix_proc_state(te_matrix_handle_t matrix_handle)
|
|||||||
} else if (matrix_handle->last_state == TE_STATE_PRESS) { //Press ---> Press = On_LongPress
|
} else if (matrix_handle->last_state == TE_STATE_PRESS) { //Press ---> Press = On_LongPress
|
||||||
if (event_mask & TOUCH_ELEM_EVENT_ON_LONGPRESS) {
|
if (event_mask & TOUCH_ELEM_EVENT_ON_LONGPRESS) {
|
||||||
if (++matrix_handle->trigger_cnt >= matrix_handle->trigger_thr) {
|
if (++matrix_handle->trigger_cnt >= matrix_handle->trigger_thr) {
|
||||||
ESP_LOGD(TE_DEBUG_TAG, "matrix longpress (%d, %d)", matrix_handle->position.x_axis, matrix_handle->position.y_axis);
|
ESP_LOGD(TE_DEBUG_TAG, "matrix longpress (%"PRIu8", %"PRIu8")", matrix_handle->position.x_axis, matrix_handle->position.y_axis);
|
||||||
matrix_handle->event = TOUCH_MATRIX_EVT_ON_LONGPRESS;
|
matrix_handle->event = TOUCH_MATRIX_EVT_ON_LONGPRESS;
|
||||||
matrix_dispatch(matrix_handle, dispatch_method);
|
matrix_dispatch(matrix_handle, dispatch_method);
|
||||||
matrix_handle->trigger_cnt = 0;
|
matrix_handle->trigger_cnt = 0;
|
||||||
@@ -592,7 +587,7 @@ static void matrix_proc_state(te_matrix_handle_t matrix_handle)
|
|||||||
}
|
}
|
||||||
} else if (matrix_handle->current_state == TE_STATE_RELEASE) {
|
} else if (matrix_handle->current_state == TE_STATE_RELEASE) {
|
||||||
if (matrix_handle->last_state == TE_STATE_PRESS) { //Press ---> Release = On_Release
|
if (matrix_handle->last_state == TE_STATE_PRESS) { //Press ---> Release = On_Release
|
||||||
ESP_LOGD(TE_DEBUG_TAG, "matrix release (%d, %d)", matrix_handle->position.x_axis, matrix_handle->position.y_axis);
|
ESP_LOGD(TE_DEBUG_TAG, "matrix release (%"PRIu8", %"PRIu8")", matrix_handle->position.x_axis, matrix_handle->position.y_axis);
|
||||||
if (event_mask & TOUCH_ELEM_EVENT_ON_RELEASE) {
|
if (event_mask & TOUCH_ELEM_EVENT_ON_RELEASE) {
|
||||||
matrix_handle->event = TOUCH_MATRIX_EVT_ON_RELEASE;
|
matrix_handle->event = TOUCH_MATRIX_EVT_ON_RELEASE;
|
||||||
matrix_dispatch(matrix_handle, dispatch_method);
|
matrix_dispatch(matrix_handle, dispatch_method);
|
||||||
|
@@ -1,14 +1,8 @@
|
|||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
/*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// You may obtain a copy of the License at
|
*
|
||||||
//
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
*/
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
idf_component_register(SRCS "touch_button_example_main.c"
|
idf_component_register(SRCS "touch_button_example_main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES touch_element)
|
PRIV_REQUIRES touch_element)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
@@ -66,11 +66,11 @@ static void button_handler_task(void *arg)
|
|||||||
/* Decode message */
|
/* Decode message */
|
||||||
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
||||||
if (button_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
if (button_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Press", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] Press", (int)element_message.arg);
|
||||||
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Release", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] Release", (int)element_message.arg);
|
||||||
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] LongPress", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] LongPress", (int)element_message.arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ static void button_handler(touch_button_handle_t out_handle, touch_button_messag
|
|||||||
{
|
{
|
||||||
(void) out_handle; //Unused
|
(void) out_handle; //Unused
|
||||||
if (out_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
if (out_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Press", (uint32_t)arg);
|
ESP_LOGI(TAG, "Button[%d] Press", (int)arg);
|
||||||
} else if (out_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
} else if (out_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Release", (uint32_t)arg);
|
ESP_LOGI(TAG, "Button[%d] Release", (int)arg);
|
||||||
} else if (out_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
} else if (out_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] LongPress", (uint32_t)arg);
|
ESP_LOGI(TAG, "Button[%d] LongPress", (int)arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -107,8 +107,9 @@ void app_main(void)
|
|||||||
/* Create Touch buttons */
|
/* Create Touch buttons */
|
||||||
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
||||||
/* Subscribe touch button events (On Press, On Release, On LongPress) */
|
/* Subscribe touch button events (On Press, On Release, On LongPress) */
|
||||||
ESP_ERROR_CHECK(touch_button_subscribe_event(button_handle[i], TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS,
|
ESP_ERROR_CHECK(touch_button_subscribe_event(button_handle[i],
|
||||||
(void *)channel_array[i]));
|
TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS,
|
||||||
|
(void *)channel_array[i]));
|
||||||
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
||||||
/* Set EVENT as the dispatch method */
|
/* Set EVENT as the dispatch method */
|
||||||
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
idf_component_register(SRCS "waterproof_example_main.c"
|
idf_component_register(SRCS "waterproof_example_main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES touch_element)
|
PRIV_REQUIRES touch_element)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
@@ -36,11 +36,11 @@ static void button_handler_task(void *arg)
|
|||||||
touch_element_message_receive(&element_message, portMAX_DELAY); //Block take
|
touch_element_message_receive(&element_message, portMAX_DELAY); //Block take
|
||||||
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
||||||
if (button_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
if (button_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Press", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] Press", (int)element_message.arg);
|
||||||
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Release", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] Release", (int)element_message.arg);
|
||||||
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] LongPress", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] LongPress", (int)element_message.arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,9 @@ void app_main(void)
|
|||||||
/* Create touch button */
|
/* Create touch button */
|
||||||
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
||||||
/* Subscribe touch button event(Press, Release, LongPress) */
|
/* Subscribe touch button event(Press, Release, LongPress) */
|
||||||
ESP_ERROR_CHECK(touch_button_subscribe_event(button_handle[i], TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS,
|
ESP_ERROR_CHECK(touch_button_subscribe_event(button_handle[i],
|
||||||
(void *)channel_array[i]));
|
TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS,
|
||||||
|
(void *)channel_array[i]));
|
||||||
/* Button set dispatch method */
|
/* Button set dispatch method */
|
||||||
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
||||||
#ifdef CONFIG_TOUCH_WATERPROOF_GUARD_ENABLE
|
#ifdef CONFIG_TOUCH_WATERPROOF_GUARD_ENABLE
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
idf_component_register(SRCS "touch_elements_example_main.c"
|
idf_component_register(SRCS "touch_elements_example_main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES touch_element)
|
PRIV_REQUIRES touch_element)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "touch_element/touch_button.h"
|
#include "touch_element/touch_button.h"
|
||||||
@@ -53,11 +54,11 @@ static void button_handler(touch_elem_message_t element_message)
|
|||||||
{
|
{
|
||||||
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
||||||
if (button_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
if (button_message->event == TOUCH_BUTTON_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Press", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] Press", (int)element_message.arg);
|
||||||
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Button[%d] Release", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] Release", (int)element_message.arg);
|
||||||
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
} else if (button_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) {
|
||||||
ESP_LOGI(TAG, "Button[%d] LongPress", (uint32_t)element_message.arg);
|
ESP_LOGI(TAG, "Button[%d] LongPress", (int)element_message.arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +66,11 @@ static void slider_handler(touch_elem_message_t element_message)
|
|||||||
{
|
{
|
||||||
const touch_slider_message_t *slider_message = touch_slider_get_message(&element_message);
|
const touch_slider_message_t *slider_message = touch_slider_get_message(&element_message);
|
||||||
if (slider_message->event == TOUCH_SLIDER_EVT_ON_PRESS) {
|
if (slider_message->event == TOUCH_SLIDER_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Slider Press, position: %d", slider_message->position);
|
ESP_LOGI(TAG, "Slider Press, position: %"PRIu32, slider_message->position);
|
||||||
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) {
|
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Slider Release, position: %d", slider_message->position);
|
ESP_LOGI(TAG, "Slider Release, position: %"PRIu32, slider_message->position);
|
||||||
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) {
|
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) {
|
||||||
ESP_LOGI(TAG, "Slider Calculate, position: %d", slider_message->position);
|
ESP_LOGI(TAG, "Slider Calculate, position: %"PRIu32, slider_message->position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +108,8 @@ void button_example_init(void)
|
|||||||
/* Create Touch buttons */
|
/* Create Touch buttons */
|
||||||
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
||||||
/* Subscribe touch button events (On Press, On Release, On LongPress) */
|
/* Subscribe touch button events (On Press, On Release, On LongPress) */
|
||||||
ESP_ERROR_CHECK(touch_button_subscribe_event(button_handle[i], TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS,
|
ESP_ERROR_CHECK(touch_button_subscribe_event(button_handle[i],
|
||||||
|
TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS,
|
||||||
(void *)button_channel_array[i]));
|
(void *)button_channel_array[i]));
|
||||||
/* Set EVENT as the dispatch method */
|
/* Set EVENT as the dispatch method */
|
||||||
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
||||||
@@ -131,7 +133,8 @@ void slider_example_init(void)
|
|||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(touch_slider_create(&slider_config, &slider_handle));
|
ESP_ERROR_CHECK(touch_slider_create(&slider_config, &slider_handle));
|
||||||
/* Subscribe touch slider events (On Press, On Release, On Calculation) */
|
/* Subscribe touch slider events (On Press, On Release, On Calculation) */
|
||||||
ESP_ERROR_CHECK(touch_slider_subscribe_event(slider_handle, TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_CALCULATION, NULL));
|
ESP_ERROR_CHECK(touch_slider_subscribe_event(slider_handle,
|
||||||
|
TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_CALCULATION, NULL));
|
||||||
/* Set EVENT as the dispatch method */
|
/* Set EVENT as the dispatch method */
|
||||||
ESP_ERROR_CHECK(touch_slider_set_dispatch_method(slider_handle, TOUCH_ELEM_DISP_EVENT));
|
ESP_ERROR_CHECK(touch_slider_set_dispatch_method(slider_handle, TOUCH_ELEM_DISP_EVENT));
|
||||||
ESP_LOGI(TAG, "Touch slider created");
|
ESP_LOGI(TAG, "Touch slider created");
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
idf_component_register(SRCS "touch_matrix_example_main.c"
|
idf_component_register(SRCS "touch_matrix_example_main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES touch_element)
|
PRIV_REQUIRES touch_element)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "touch_element/touch_matrix.h"
|
#include "touch_element/touch_matrix.h"
|
||||||
@@ -58,11 +59,14 @@ static void matrix_handler_task(void *arg)
|
|||||||
/* Decode message */
|
/* Decode message */
|
||||||
const touch_matrix_message_t *matrix_message = touch_matrix_get_message(&element_message);
|
const touch_matrix_message_t *matrix_message = touch_matrix_get_message(&element_message);
|
||||||
if (matrix_message->event == TOUCH_MATRIX_EVT_ON_PRESS) {
|
if (matrix_message->event == TOUCH_MATRIX_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Matrix Press, axis: (%d, %d) index: %d", matrix_message->position.x_axis, matrix_message->position.y_axis, matrix_message->position.index);
|
ESP_LOGI(TAG, "Matrix Press, axis: (%"PRIu8", %"PRIu8") index: %"PRIu8, matrix_message->position.x_axis,
|
||||||
|
matrix_message->position.y_axis, matrix_message->position.index);
|
||||||
} else if (matrix_message->event == TOUCH_MATRIX_EVT_ON_RELEASE) {
|
} else if (matrix_message->event == TOUCH_MATRIX_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Matrix Release, axis: (%d, %d) index: %d", matrix_message->position.x_axis, matrix_message->position.y_axis, matrix_message->position.index);
|
ESP_LOGI(TAG, "Matrix Release, axis: (%"PRIu8", %"PRIu8") index: %"PRIu8, matrix_message->position.x_axis,
|
||||||
|
matrix_message->position.y_axis, matrix_message->position.index);
|
||||||
} else if (matrix_message->event == TOUCH_MATRIX_EVT_ON_LONGPRESS) {
|
} else if (matrix_message->event == TOUCH_MATRIX_EVT_ON_LONGPRESS) {
|
||||||
ESP_LOGI(TAG, "Matrix LongPress, axis: (%d, %d) index: %d", matrix_message->position.x_axis, matrix_message->position.y_axis, matrix_message->position.index);
|
ESP_LOGI(TAG, "Matrix LongPress, axis: (%"PRIu8", %"PRIu8") index: %"PRIu8, matrix_message->position.x_axis,
|
||||||
|
matrix_message->position.y_axis, matrix_message->position.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,11 +79,14 @@ void matrix_handler(touch_matrix_handle_t out_handle, touch_matrix_message_t *ou
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (out_message->event == TOUCH_MATRIX_EVT_ON_PRESS) {
|
if (out_message->event == TOUCH_MATRIX_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Matrix Press, axis: (%d, %d) index: %d", out_message->position.x_axis, out_message->position.y_axis, out_message->position.index);
|
ESP_LOGI(TAG, "Matrix Press, axis: (%"PRIu8", %"PRIu8") index: %"PRIu8, out_message->position.x_axis,
|
||||||
|
out_message->position.y_axis, out_message->position.index);
|
||||||
} else if (out_message->event == TOUCH_MATRIX_EVT_ON_RELEASE) {
|
} else if (out_message->event == TOUCH_MATRIX_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Matrix Release, axis: (%d, %d) index: %d", out_message->position.x_axis, out_message->position.y_axis, out_message->position.index);
|
ESP_LOGI(TAG, "Matrix Release, axis: (%"PRIu8", %"PRIu8") index: %"PRIu8, out_message->position.x_axis,
|
||||||
|
out_message->position.y_axis, out_message->position.index);
|
||||||
} else if (out_message->event == TOUCH_MATRIX_EVT_ON_LONGPRESS) {
|
} else if (out_message->event == TOUCH_MATRIX_EVT_ON_LONGPRESS) {
|
||||||
ESP_LOGI(TAG, "Matrix LongPress, axis: (%d, %d) index: %d", out_message->position.x_axis, out_message->position.y_axis, out_message->position.index);
|
ESP_LOGI(TAG, "Matrix LongPress, axis: (%"PRIu8", %"PRIu8") index: %"PRIu8, out_message->position.x_axis,
|
||||||
|
out_message->position.y_axis, out_message->position.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -105,7 +112,8 @@ void app_main(void)
|
|||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(touch_matrix_create(&matrix_config, &matrix_handle));
|
ESP_ERROR_CHECK(touch_matrix_create(&matrix_config, &matrix_handle));
|
||||||
/* Subscribe touch matrix events (On Press, On Release, On LongPress) */
|
/* Subscribe touch matrix events (On Press, On Release, On LongPress) */
|
||||||
ESP_ERROR_CHECK(touch_matrix_subscribe_event(matrix_handle, TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS, NULL));
|
ESP_ERROR_CHECK(touch_matrix_subscribe_event(matrix_handle,
|
||||||
|
TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_LONGPRESS, NULL));
|
||||||
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
||||||
/* Set EVENT as the dispatch method */
|
/* Set EVENT as the dispatch method */
|
||||||
ESP_ERROR_CHECK(touch_matrix_set_dispatch_method(matrix_handle, TOUCH_ELEM_DISP_EVENT));
|
ESP_ERROR_CHECK(touch_matrix_set_dispatch_method(matrix_handle, TOUCH_ELEM_DISP_EVENT));
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
idf_component_register(SRCS "touch_slider_example_main.c"
|
idf_component_register(SRCS "touch_slider_example_main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES touch_element)
|
PRIV_REQUIRES touch_element)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "touch_element/touch_slider.h"
|
#include "touch_element/touch_slider.h"
|
||||||
@@ -51,11 +52,11 @@ static void slider_handler_task(void *arg)
|
|||||||
/* Decode message */
|
/* Decode message */
|
||||||
const touch_slider_message_t *slider_message = touch_slider_get_message(&element_message);
|
const touch_slider_message_t *slider_message = touch_slider_get_message(&element_message);
|
||||||
if (slider_message->event == TOUCH_SLIDER_EVT_ON_PRESS) {
|
if (slider_message->event == TOUCH_SLIDER_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Slider Press, position: %d", slider_message->position);
|
ESP_LOGI(TAG, "Slider Press, position: %"PRIu32, slider_message->position);
|
||||||
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) {
|
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Slider Release, position: %d", slider_message->position);
|
ESP_LOGI(TAG, "Slider Release, position: %"PRIu32, slider_message->position);
|
||||||
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) {
|
} else if (slider_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) {
|
||||||
ESP_LOGI(TAG, "Slider Calculate, position: %d", slider_message->position);
|
ESP_LOGI(TAG, "Slider Calculate, position: %"PRIu32, slider_message->position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,11 +70,11 @@ void slider_handler(touch_slider_handle_t out_handle, touch_slider_message_t *ou
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (out_message->event == TOUCH_SLIDER_EVT_ON_PRESS) {
|
if (out_message->event == TOUCH_SLIDER_EVT_ON_PRESS) {
|
||||||
ESP_LOGI(TAG, "Slider Press, position: %d", out_message->position);
|
ESP_LOGI(TAG, "Slider Press, position: %"PRIu32, out_message->position);
|
||||||
} else if (out_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) {
|
} else if (out_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) {
|
||||||
ESP_LOGI(TAG, "Slider Release, position: %d", out_message->position);
|
ESP_LOGI(TAG, "Slider Release, position: %"PRIu32, out_message->position);
|
||||||
} else if (out_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) {
|
} else if (out_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) {
|
||||||
ESP_LOGI(TAG, "Slider Calculate, position: %d", out_message->position);
|
ESP_LOGI(TAG, "Slider Calculate, position: %"PRIu32, out_message->position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -97,7 +98,8 @@ void app_main(void)
|
|||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(touch_slider_create(&slider_config, &slider_handle));
|
ESP_ERROR_CHECK(touch_slider_create(&slider_config, &slider_handle));
|
||||||
/* Subscribe touch slider events (On Press, On Release, On Calculation) */
|
/* Subscribe touch slider events (On Press, On Release, On Calculation) */
|
||||||
ESP_ERROR_CHECK(touch_slider_subscribe_event(slider_handle, TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_CALCULATION, NULL));
|
ESP_ERROR_CHECK(touch_slider_subscribe_event(slider_handle,
|
||||||
|
TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_ELEM_EVENT_ON_RELEASE | TOUCH_ELEM_EVENT_ON_CALCULATION, NULL));
|
||||||
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
||||||
/* Set EVENT as the dispatch method */
|
/* Set EVENT as the dispatch method */
|
||||||
ESP_ERROR_CHECK(touch_slider_set_dispatch_method(slider_handle, TOUCH_ELEM_DISP_EVENT));
|
ESP_ERROR_CHECK(touch_slider_set_dispatch_method(slider_handle, TOUCH_ELEM_DISP_EVENT));
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
idf_component_register(SRCS "tp_interrupt_main.c"
|
idf_component_register(SRCS "tp_interrupt_main.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
@@ -93,7 +94,7 @@ static void tp_example_read_task(void *pvParameter)
|
|||||||
touch_pad_read_filtered(i, &value);
|
touch_pad_read_filtered(i, &value);
|
||||||
if (value < s_pad_init_val[i] * TOUCH_THRESH_PERCENT / 100) {
|
if (value < s_pad_init_val[i] * TOUCH_THRESH_PERCENT / 100) {
|
||||||
ESP_LOGI(TAG, "T%d activated!", i);
|
ESP_LOGI(TAG, "T%d activated!", i);
|
||||||
ESP_LOGI(TAG, "value: %d; init val: %d", value, s_pad_init_val[i]);
|
ESP_LOGI(TAG, "value: %"PRIu16"; init val: %"PRIu32, value, s_pad_init_val[i]);
|
||||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
// Reset the counter to stop changing mode.
|
// Reset the counter to stop changing mode.
|
||||||
change_mode = 1;
|
change_mode = 1;
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
idf_component_register(SRCS "tp_read_main.c"
|
idf_component_register(SRCS "tp_read_main.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "driver/touch_pad.h"
|
#include "driver/touch_pad.h"
|
||||||
@@ -33,10 +34,10 @@ static void tp_example_read_task(void *pvParameter)
|
|||||||
// If open the filter mode, please use this API to get the touch pad count.
|
// If open the filter mode, please use this API to get the touch pad count.
|
||||||
touch_pad_read_raw_data(i, &touch_value);
|
touch_pad_read_raw_data(i, &touch_value);
|
||||||
touch_pad_read_filtered(i, &touch_filter_value);
|
touch_pad_read_filtered(i, &touch_filter_value);
|
||||||
printf("T%d:[%4d,%4d] ", i, touch_value, touch_filter_value);
|
printf("T%d:[%4"PRIu16",%4"PRIu16"] ", i, touch_value, touch_filter_value);
|
||||||
#else
|
#else
|
||||||
touch_pad_read(i, &touch_value);
|
touch_pad_read(i, &touch_value);
|
||||||
printf("T%d:[%4d] ", i, touch_value);
|
printf("T%d:[%4"PRIu16"] ", i, touch_value);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
idf_component_register(SRCS "tp_interrupt_main.c"
|
idf_component_register(SRCS "tp_interrupt_main.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
@@ -76,7 +77,7 @@ static void tp_example_set_thresholds(void)
|
|||||||
touch_pad_read_benchmark(button[i], &touch_value);
|
touch_pad_read_benchmark(button[i], &touch_value);
|
||||||
//set interrupt threshold.
|
//set interrupt threshold.
|
||||||
touch_pad_set_thresh(button[i], touch_value * button_threshold[i]);
|
touch_pad_set_thresh(button[i], touch_value * button_threshold[i]);
|
||||||
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "touch pad [%d] base %"PRIu32", thresh %"PRIu32, \
|
||||||
button[i], touch_value, (uint32_t)(touch_value * button_threshold[i]));
|
button[i], touch_value, (uint32_t)(touch_value * button_threshold[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,10 +114,10 @@ static void tp_example_read_task(void *pvParameter)
|
|||||||
/* if guard pad be touched, other pads no response. */
|
/* if guard pad be touched, other pads no response. */
|
||||||
if (evt.pad_num == button[3]) {
|
if (evt.pad_num == button[3]) {
|
||||||
guard_mode_flag = 1;
|
guard_mode_flag = 1;
|
||||||
ESP_LOGW(TAG, "TouchSensor [%d] be activated, enter guard mode", evt.pad_num);
|
ESP_LOGW(TAG, "TouchSensor [%"PRIu32"] be activated, enter guard mode", evt.pad_num);
|
||||||
} else {
|
} else {
|
||||||
if (guard_mode_flag == 0) {
|
if (guard_mode_flag == 0) {
|
||||||
ESP_LOGI(TAG, "TouchSensor [%d] be activated, status mask 0x%x", evt.pad_num, evt.pad_status);
|
ESP_LOGI(TAG, "TouchSensor [%"PRIu32"] be activated, status mask 0x%"PRIu32"", evt.pad_num, evt.pad_status);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "In guard mode. No response");
|
ESP_LOGW(TAG, "In guard mode. No response");
|
||||||
}
|
}
|
||||||
@@ -126,19 +127,19 @@ static void tp_example_read_task(void *pvParameter)
|
|||||||
/* if guard pad be touched, other pads no response. */
|
/* if guard pad be touched, other pads no response. */
|
||||||
if (evt.pad_num == button[3]) {
|
if (evt.pad_num == button[3]) {
|
||||||
guard_mode_flag = 0;
|
guard_mode_flag = 0;
|
||||||
ESP_LOGW(TAG, "TouchSensor [%d] be inactivated, exit guard mode", evt.pad_num);
|
ESP_LOGW(TAG, "TouchSensor [%"PRIu32"] be inactivated, exit guard mode", evt.pad_num);
|
||||||
} else {
|
} else {
|
||||||
if (guard_mode_flag == 0) {
|
if (guard_mode_flag == 0) {
|
||||||
ESP_LOGI(TAG, "TouchSensor [%d] be inactivated, status mask 0x%x", evt.pad_num, evt.pad_status);
|
ESP_LOGI(TAG, "TouchSensor [%"PRIu32"] be inactivated, status mask 0x%"PRIu32, evt.pad_num, evt.pad_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) {
|
||||||
ESP_LOGI(TAG, "The touch sensor group measurement is done [%d].", evt.pad_num);
|
ESP_LOGI(TAG, "The touch sensor group measurement is done [%"PRIu32"].", evt.pad_num);
|
||||||
}
|
}
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) {
|
||||||
/* Add your exception handling in here. */
|
/* Add your exception handling in here. */
|
||||||
ESP_LOGI(TAG, "Touch sensor channel %d measure timeout. Skip this exception channel!!", evt.pad_num);
|
ESP_LOGI(TAG, "Touch sensor channel %"PRIu32" measure timeout. Skip this exception channel!!", evt.pad_num);
|
||||||
touch_pad_timeout_resume(); // Point on the next channel to measure.
|
touch_pad_timeout_resume(); // Point on the next channel to measure.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
idf_component_register(SRCS "tp_read_main.c"
|
idf_component_register(SRCS "tp_read_main.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "driver/touch_pad.h"
|
#include "driver/touch_pad.h"
|
||||||
@@ -46,7 +47,7 @@ static void tp_example_read_task(void *pvParameter)
|
|||||||
while (1) {
|
while (1) {
|
||||||
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
|
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
|
||||||
touch_pad_read_raw_data(button[i], &touch_value); // read raw data.
|
touch_pad_read_raw_data(button[i], &touch_value); // read raw data.
|
||||||
printf("T%d: [%4d] ", button[i], touch_value);
|
printf("T%d: [%4"PRIu32"] ", button[i], touch_value);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
|
@@ -1264,15 +1264,6 @@ components/tcp_transport/test/test_transport_basic.c
|
|||||||
components/tcp_transport/test/test_transport_connect.c
|
components/tcp_transport/test/test_transport_connect.c
|
||||||
components/tcp_transport/test/test_transport_fixtures.c
|
components/tcp_transport/test/test_transport_fixtures.c
|
||||||
components/tcp_transport/transport_utils.c
|
components/tcp_transport/transport_utils.c
|
||||||
components/touch_element/include/touch_element/touch_button.h
|
|
||||||
components/touch_element/include/touch_element/touch_element_private.h
|
|
||||||
components/touch_element/test/test_touch_button.c
|
|
||||||
components/touch_element/test/test_touch_element.c
|
|
||||||
components/touch_element/test/test_touch_matrix.c
|
|
||||||
components/touch_element/test/test_touch_slider.c
|
|
||||||
components/touch_element/touch_button.c
|
|
||||||
components/touch_element/touch_matrix.c
|
|
||||||
components/touch_element/touch_slider.c
|
|
||||||
components/ulp/esp32ulp_mapgen.py
|
components/ulp/esp32ulp_mapgen.py
|
||||||
components/ulp/test/esp32/test_ulp_as.c
|
components/ulp/test/esp32/test_ulp_as.c
|
||||||
components/unity/include/priv/setjmp.h
|
components/unity/include/priv/setjmp.h
|
||||||
@@ -1692,15 +1683,6 @@ examples/peripherals/spi_slave_hd/append_mode/master/main/app_main.c
|
|||||||
examples/peripherals/spi_slave_hd/append_mode/slave/main/app_main.c
|
examples/peripherals/spi_slave_hd/append_mode/slave/main/app_main.c
|
||||||
examples/peripherals/spi_slave_hd/segment_mode/seg_master/main/app_main.c
|
examples/peripherals/spi_slave_hd/segment_mode/seg_master/main/app_main.c
|
||||||
examples/peripherals/spi_slave_hd/segment_mode/seg_slave/main/app_main.c
|
examples/peripherals/spi_slave_hd/segment_mode/seg_slave/main/app_main.c
|
||||||
examples/peripherals/touch_element/touch_button/main/touch_button_example_main.c
|
|
||||||
examples/peripherals/touch_element/touch_element_waterproof/main/waterproof_example_main.c
|
|
||||||
examples/peripherals/touch_element/touch_elements_combination/main/touch_elements_example_main.c
|
|
||||||
examples/peripherals/touch_element/touch_matrix/main/touch_matrix_example_main.c
|
|
||||||
examples/peripherals/touch_element/touch_slider/main/touch_slider_example_main.c
|
|
||||||
examples/peripherals/touch_pad_interrupt/main/esp32/tp_interrupt_main.c
|
|
||||||
examples/peripherals/touch_pad_interrupt/main/esp32s2/tp_interrupt_main.c
|
|
||||||
examples/peripherals/touch_pad_read/main/esp32/tp_read_main.c
|
|
||||||
examples/peripherals/touch_pad_read/main/esp32s2/tp_read_main.c
|
|
||||||
examples/peripherals/twai/twai_alert_and_recovery/example_test.py
|
examples/peripherals/twai/twai_alert_and_recovery/example_test.py
|
||||||
examples/peripherals/twai/twai_alert_and_recovery/main/twai_alert_and_recovery_example_main.c
|
examples/peripherals/twai/twai_alert_and_recovery/main/twai_alert_and_recovery_example_main.c
|
||||||
examples/peripherals/twai/twai_network/example_test.py
|
examples/peripherals/twai/twai_network/example_test.py
|
||||||
|
Reference in New Issue
Block a user