mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
821c70f5d7
* Use "example" in all example function & variable names, ie use i2c_example_xxx instead of i2c_xxx for example functions. Closes #198 https://github.com/espressif/esp-idf/issues/198 * Mark example functions, etc. static * Replace uses of "test" & "demo" with "example" * Split the UART example into two * Rename "main" example files to end with "_main.c" for disambiguation
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
/* Touch Pad Read 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 <stdio.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
#include "driver/touch_pad.h"
|
|
|
|
|
|
/*
|
|
Read values sensed at all available touch pads.
|
|
Print out values in a loop on a serial monitor.
|
|
*/
|
|
static void tp_example_read_task(void *pvParameter)
|
|
{
|
|
while (1) {
|
|
uint16_t touch_value;
|
|
for (int i=0; i<TOUCH_PAD_MAX; i++) {
|
|
ESP_ERROR_CHECK(touch_pad_read(i, &touch_value));
|
|
printf("T%d:%4d ", i, touch_value);
|
|
}
|
|
printf("\n");
|
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
|
}
|
|
}
|
|
|
|
void app_main()
|
|
{
|
|
// Initialize touch pad peripheral
|
|
touch_pad_init();
|
|
|
|
// Start task to read values sensed by pads
|
|
xTaskCreate(&tp_example_read_task, "touch_pad_read_task", 2048, NULL, 5, NULL);
|
|
|
|
}
|