/* Touch Pad Interrupt Example This example code is in the Public Domain (or CC0 licensed, at your option.) Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_log.h" #include "driver/touch_pad.h" #include "soc/rtc_cntl_reg.h" #include "soc/sens_reg.h" static const char* TAG = "Touch pad"; static bool s_pad_activated[TOUCH_PAD_MAX]; /* Read values sensed at all available touch pads. Use half of read value as the threshold to trigger interrupt when the pad is touched. Note: this routine demonstrates a simple way to configure activation threshold for the touch pads. Do not touch any pads when this routine is running (on application start). */ static void tp_example_set_thresholds(void) { uint16_t touch_value; for (int i=0; i> i) & 0x01) { s_pad_activated[i] = true; } } } } void app_main() { // Initialize touch pad peripheral ESP_LOGI(TAG, "Initializing touch pad"); touch_pad_init(); tp_example_set_thresholds(); touch_pad_isr_handler_register(tp_example_rtc_intr, NULL, 0, NULL); // Start a task to show what pads have been touched xTaskCreate(&tp_example_read_task, "touch_pad_read_task", 2048, NULL, 5, NULL); }