mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'example/update_format_string_in_touch_related_examples' into 'master'
example: update format string in touch related examples See merge request espressif/esp-idf!19743
This commit is contained in:
commit
935a63efca
@ -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