mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
touch: update touch-related code to compile without -Wno-format flag
This commit is contained in:
parent
885e501d99
commit
e51845d04c
@ -11,6 +11,7 @@
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "esp_system.h"
|
||||
#include "driver/touch_pad.h"
|
||||
#include "unity.h"
|
||||
@ -114,7 +115,7 @@ static void printf_touch_hw_read(const char *str)
|
||||
printf("[%s] ", str);
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
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");
|
||||
}
|
||||
@ -125,7 +126,7 @@ static void printf_touch_benchmark_read(const char *str)
|
||||
printf("[%s] ", str);
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
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");
|
||||
}
|
||||
@ -136,7 +137,7 @@ static void printf_touch_smooth_read(const char *str)
|
||||
printf("[%s] ", str);
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
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");
|
||||
}
|
||||
@ -227,7 +228,7 @@ esp_err_t test_touch_sw_read(void)
|
||||
TEST_ESP_OK( touch_pad_sw_start() );
|
||||
while (!touch_pad_meas_is_done()) ;
|
||||
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]);
|
||||
}
|
||||
printf("\n");
|
||||
@ -246,7 +247,7 @@ esp_err_t test_touch_sw_read(void)
|
||||
TEST_ESP_OK( touch_pad_sw_start() );
|
||||
while (!touch_pad_meas_is_done()) ;
|
||||
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]);
|
||||
}
|
||||
printf("\n");
|
||||
@ -298,7 +299,7 @@ esp_err_t test_touch_timer_read(void)
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; 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]);
|
||||
printf("T%d:[%4d] ", touch_list[i], touch_value[i]);
|
||||
printf("T%d:[%4"PRIu32"] ", touch_list[i], touch_value[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||
@ -314,7 +315,7 @@ esp_err_t test_touch_timer_read(void)
|
||||
/* Read the touch sensor raw data in FSM mode. */
|
||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; 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]);
|
||||
}
|
||||
printf("\n");
|
||||
@ -472,7 +473,7 @@ int test_touch_base_parameter(touch_pad_t pad_num, int meas_time, int slp_time,
|
||||
}
|
||||
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.
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
}
|
||||
@ -544,7 +545,7 @@ static esp_err_t test_touch_check_ch_touched(uint32_t test_ch_num, uint32_t exce
|
||||
while (1) {
|
||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||
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)) {
|
||||
ret = ESP_OK;
|
||||
break;
|
||||
@ -552,7 +553,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)) {
|
||||
continue;
|
||||
} 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;
|
||||
}
|
||||
} else {
|
||||
@ -575,7 +576,7 @@ static esp_err_t test_touch_check_ch_released(uint32_t test_ch_num, uint32_t exc
|
||||
while (1) {
|
||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||
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)) {
|
||||
ret = ESP_OK;
|
||||
break;
|
||||
@ -583,7 +584,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)) {
|
||||
continue;
|
||||
} 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;
|
||||
}
|
||||
} else {
|
||||
@ -607,7 +608,7 @@ static esp_err_t test_touch_check_ch_touched_with_proximity(uint32_t test_ch_num
|
||||
while (1) {
|
||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||
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)) {
|
||||
ret = ESP_OK;
|
||||
break;
|
||||
@ -618,14 +619,14 @@ static esp_err_t test_touch_check_ch_touched_with_proximity(uint32_t test_ch_num
|
||||
if (BIT(i) & ch_mask) {
|
||||
if (evt.pad_num == i) {
|
||||
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;
|
||||
} 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;;
|
||||
}
|
||||
} else {
|
||||
@ -649,7 +650,7 @@ static esp_err_t test_touch_check_ch_released_with_proximity(uint32_t test_ch_nu
|
||||
while (1) {
|
||||
if (pdTRUE == xQueueReceive(que_touch, &evt, exceed_time_ms / portTICK_PERIOD_MS)) {
|
||||
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)) {
|
||||
ret = ESP_OK;
|
||||
break;
|
||||
@ -660,14 +661,14 @@ static esp_err_t test_touch_check_ch_released_with_proximity(uint32_t test_ch_nu
|
||||
if (BIT(i) & ch_mask) {
|
||||
if (evt.pad_num == i) {
|
||||
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;
|
||||
} 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;;
|
||||
}
|
||||
} else {
|
||||
@ -705,7 +706,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)) {
|
||||
continue;
|
||||
} 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;
|
||||
}
|
||||
} else {
|
||||
@ -737,7 +738,7 @@ static esp_err_t test_touch_check_ch_intr_timeout(touch_pad_t pad_num)
|
||||
touch_pad_timeout_resume();
|
||||
break;
|
||||
} 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);
|
||||
touch_pad_timeout_resume();
|
||||
}
|
||||
@ -832,7 +833,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
|
||||
@ -900,7 +901,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
|
||||
@ -965,7 +966,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
/* Set timeout parameter */
|
||||
@ -1011,7 +1012,7 @@ TEST_CASE("Touch Sensor interrupt test (active, inactive, scan_done, timeout)",
|
||||
static void test_touch_measure_step(uint32_t step)
|
||||
{
|
||||
/* Fake the process of debounce. */
|
||||
// printf("measure cnt %d: [ ", step);
|
||||
// printf("measure cnt %"PRIu32": [ ", step);
|
||||
for (int i = 0; i < step; i++) {
|
||||
for (int j = 0; j < TEST_TOUCH_CHANNEL; j++) {
|
||||
TEST_ESP_OK( touch_pad_sw_start() );
|
||||
@ -1067,7 +1068,7 @@ esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
||||
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_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));
|
||||
}
|
||||
|
||||
@ -1132,7 +1133,7 @@ esp_err_t test_touch_filter_parameter_reset(int reset_cnt)
|
||||
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_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));
|
||||
}
|
||||
|
||||
@ -1267,7 +1268,7 @@ esp_err_t test_touch_filter_parameter_jitter(int jitter_step)
|
||||
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||
//set interrupt 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));
|
||||
}
|
||||
|
||||
@ -1400,7 +1401,7 @@ TEST_CASE("Touch Sensor denoise test (cap, level)", "[touch]")
|
||||
} else {
|
||||
/* If the value of denoise is approximately 0,
|
||||
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 ********************");
|
||||
@ -1416,7 +1417,7 @@ TEST_CASE("Touch Sensor denoise test (cap, level)", "[touch]")
|
||||
printf("denoise read: ");
|
||||
for (int i = 0; i < TOUCH_PAD_DENOISE_CAP_MAX - 1; i++) {
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(denoise_val[i], denoise_val[i + 1]);
|
||||
printf("%d ", denoise_val[i]);
|
||||
printf("%"PRIu32" ", denoise_val[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@ -1557,11 +1558,11 @@ esp_err_t test_touch_proximity(int meas_num)
|
||||
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i],
|
||||
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)));
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -1653,7 +1654,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
|
||||
@ -1754,18 +1755,18 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
||||
if (touch_list[i] == sleep_pad) {
|
||||
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));
|
||||
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)));
|
||||
} else if (touch_list[i] == sleep_pad) {
|
||||
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
||||
/* 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));
|
||||
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)));
|
||||
} else {
|
||||
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) );
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -1787,7 +1788,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
/* Sleep channel setting */
|
||||
@ -1808,7 +1809,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_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
||||
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,
|
||||
touch_thres, touch_pad_get_status());
|
||||
}
|
||||
@ -1820,7 +1821,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_proximity_get_data(sleep_pad, &measure_out) );
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -1899,7 +1900,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
|
||||
@ -1915,7 +1916,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_data(sleep_pad, &raw) );
|
||||
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_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||
@ -1923,7 +1924,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_data(sleep_pad, &raw) );
|
||||
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;
|
||||
}
|
||||
@ -1944,18 +1945,18 @@ static void test_deep_sleep_init(void)
|
||||
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
|
||||
if (wakeup_pin_mask != 0) {
|
||||
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 {
|
||||
printf("Wake up from GPIO\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
case ESP_SLEEP_WAKEUP_UNDEFINED:
|
||||
@ -2059,7 +2060,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_filter_read_smooth(touch_list[i], &smooth) );
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -8,5 +8,4 @@ if(IDF_TARGET IN_LIST TOUCH_ELEMENT_COMPATIBLE_TARGETS)
|
||||
INCLUDE_DIRS include
|
||||
REQUIRES driver
|
||||
PRIV_REQUIRES esp_timer)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
endif()
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.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, "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
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
if (waterproof_shield_check_state()) {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (waterproof_guard_check_state()) {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
@ -575,7 +576,7 @@ static void matrix_proc_state(te_matrix_handle_t matrix_handle)
|
||||
if (matrix_handle->current_state == TE_STATE_PRESS) {
|
||||
if (matrix_handle->last_state == TE_STATE_IDLE) { //IDLE ---> Press = On_Press
|
||||
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) {
|
||||
matrix_handle->event = TOUCH_MATRIX_EVT_ON_PRESS;
|
||||
matrix_dispatch(matrix_handle, dispatch_method);
|
||||
@ -583,7 +584,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
|
||||
if (event_mask & TOUCH_ELEM_EVENT_ON_LONGPRESS) {
|
||||
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_dispatch(matrix_handle, dispatch_method);
|
||||
matrix_handle->trigger_cnt = 0;
|
||||
@ -592,7 +593,7 @@ static void matrix_proc_state(te_matrix_handle_t matrix_handle)
|
||||
}
|
||||
} else if (matrix_handle->current_state == TE_STATE_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) {
|
||||
matrix_handle->event = TOUCH_MATRIX_EVT_ON_RELEASE;
|
||||
matrix_dispatch(matrix_handle, dispatch_method);
|
||||
|
@ -1,4 +1,3 @@
|
||||
idf_component_register(SRCS "touch_button_example_main.c"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES touch_element)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -66,11 +66,11 @@ static void button_handler_task(void *arg)
|
||||
/* Decode message */
|
||||
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
||||
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) {
|
||||
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) {
|
||||
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
|
||||
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) {
|
||||
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) {
|
||||
ESP_LOGI(TAG, "Button[%d] LongPress", (uint32_t)arg);
|
||||
ESP_LOGI(TAG, "Button[%d] LongPress", (int)arg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -107,8 +107,9 @@ void app_main(void)
|
||||
/* Create Touch buttons */
|
||||
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
||||
/* 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,
|
||||
(void *)channel_array[i]));
|
||||
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 *)channel_array[i]));
|
||||
#ifdef CONFIG_TOUCH_ELEM_EVENT
|
||||
/* Set EVENT as the dispatch method */
|
||||
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"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES touch_element)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -36,11 +36,11 @@ static void button_handler_task(void *arg)
|
||||
touch_element_message_receive(&element_message, portMAX_DELAY); //Block take
|
||||
const touch_button_message_t *button_message = touch_button_get_message(&element_message);
|
||||
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) {
|
||||
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) {
|
||||
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 */
|
||||
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
||||
/* 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,
|
||||
(void *)channel_array[i]));
|
||||
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 *)channel_array[i]));
|
||||
/* Button set dispatch method */
|
||||
ESP_ERROR_CHECK(touch_button_set_dispatch_method(button_handle[i], TOUCH_ELEM_DISP_EVENT));
|
||||
#ifdef CONFIG_TOUCH_WATERPROOF_GUARD_ENABLE
|
||||
|
@ -1,4 +1,3 @@
|
||||
idf_component_register(SRCS "touch_elements_example_main.c"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES touch_element)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.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);
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
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) {
|
||||
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 */
|
||||
ESP_ERROR_CHECK(touch_button_create(&button_config, &button_handle[i]));
|
||||
/* 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]));
|
||||
/* Set EVENT as the dispatch method */
|
||||
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));
|
||||
/* 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 */
|
||||
ESP_ERROR_CHECK(touch_slider_set_dispatch_method(slider_handle, TOUCH_ELEM_DISP_EVENT));
|
||||
ESP_LOGI(TAG, "Touch slider created");
|
||||
|
@ -1,4 +1,3 @@
|
||||
idf_component_register(SRCS "touch_matrix_example_main.c"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES touch_element)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "touch_element/touch_matrix.h"
|
||||
@ -58,11 +59,14 @@ static void matrix_handler_task(void *arg)
|
||||
/* Decode message */
|
||||
const touch_matrix_message_t *matrix_message = touch_matrix_get_message(&element_message);
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
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
|
||||
@ -105,7 +112,8 @@ void app_main(void)
|
||||
};
|
||||
ESP_ERROR_CHECK(touch_matrix_create(&matrix_config, &matrix_handle));
|
||||
/* 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
|
||||
/* Set EVENT as the dispatch method */
|
||||
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"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES touch_element)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "touch_element/touch_slider.h"
|
||||
@ -51,11 +52,11 @@ static void slider_handler_task(void *arg)
|
||||
/* Decode message */
|
||||
const touch_slider_message_t *slider_message = touch_slider_get_message(&element_message);
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
ESP_LOGI(TAG, "Slider Calculate, position: %d", out_message->position);
|
||||
ESP_LOGI(TAG, "Slider Calculate, position: %"PRIu32, out_message->position);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -97,7 +98,8 @@ void app_main(void)
|
||||
};
|
||||
ESP_ERROR_CHECK(touch_slider_create(&slider_config, &slider_handle));
|
||||
/* 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
|
||||
/* Set EVENT as the dispatch method */
|
||||
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"
|
||||
INCLUDE_DIRS ".")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
@ -93,7 +94,7 @@ static void tp_example_read_task(void *pvParameter)
|
||||
touch_pad_read_filtered(i, &value);
|
||||
if (value < s_pad_init_val[i] * TOUCH_THRESH_PERCENT / 100) {
|
||||
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);
|
||||
// Reset the counter to stop changing mode.
|
||||
change_mode = 1;
|
||||
|
@ -1,3 +1,2 @@
|
||||
idf_component_register(SRCS "tp_read_main.c"
|
||||
INCLUDE_DIRS ".")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.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.
|
||||
touch_pad_read_raw_data(i, &touch_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
|
||||
touch_pad_read(i, &touch_value);
|
||||
printf("T%d:[%4d] ", i, touch_value);
|
||||
printf("T%d:[%4"PRIu16"] ", i, touch_value);
|
||||
#endif
|
||||
}
|
||||
printf("\n");
|
||||
|
@ -1,3 +1,2 @@
|
||||
idf_component_register(SRCS "tp_interrupt_main.c"
|
||||
INCLUDE_DIRS ".")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
@ -76,7 +77,7 @@ static void tp_example_set_thresholds(void)
|
||||
touch_pad_read_benchmark(button[i], &touch_value);
|
||||
//set interrupt threshold.
|
||||
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]));
|
||||
}
|
||||
}
|
||||
@ -113,10 +114,10 @@ static void tp_example_read_task(void *pvParameter)
|
||||
/* if guard pad be touched, other pads no response. */
|
||||
if (evt.pad_num == button[3]) {
|
||||
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 {
|
||||
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 {
|
||||
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 (evt.pad_num == button[3]) {
|
||||
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 {
|
||||
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) {
|
||||
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) {
|
||||
/* 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.
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,2 @@
|
||||
idf_component_register(SRCS "tp_read_main.c"
|
||||
INCLUDE_DIRS ".")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/touch_pad.h"
|
||||
@ -46,7 +47,7 @@ static void tp_example_read_task(void *pvParameter)
|
||||
while (1) {
|
||||
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
|
||||
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");
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
|
Loading…
Reference in New Issue
Block a user