touch示例程序
程序员文章站
2022-04-30 15:49:47
...
进入touch工程目录
cd esp-dev-kits/esp32-s2-kaluga-1/examples/touch
配置工程
idf.py set-target esp32s2 menuconfig
Example Configuration—>(45) WS2812 GPIO 通过RGB灯看touch效果,所以选择GPIO45
Example Configuration—>touch pad type (ESP32-S2-KALUGA_V1.3) 开发板的版本号
编译
在这里你会发现编译错误,示例程序有个驱动结构体多了几个选项以及有个函数名对应不上,暂时不知道为什么,修改如下
diff --git a/esp32-s2-kaluga-1/examples/touch/main/main.c b/esp32-s2-kaluga-1/examples/touch/main/main.c
index 46b0401..b16863a 100644
--- a/esp32-s2-kaluga-1/examples/touch/main/main.c
+++ b/esp32-s2-kaluga-1/examples/touch/main/main.c
@@ -92,7 +92,7 @@ static void touchsensor_interrupt_cb(void *arg)
evt.pad_num = touch_pad_get_current_meas_channel();
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_DONE) {
- touch_pad_filter_read_baseline(evt.pad_num, &evt.pad_val);
+ touch_pad_read_benchmark(evt.pad_num, &evt.pad_val);
}
xQueueSendFromISR(que_touch, &evt, &task_awoken);
@@ -108,7 +108,7 @@ static void tp_example_set_thresholds(void)
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
/*!< read baseline value */
- touch_pad_filter_read_baseline(button[i], &touch_value);
+ 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", \
@@ -122,10 +122,10 @@ static void touchsensor_filter_set(touch_filter_mode_t mode)
touch_filter_config_t filter_info = {
.mode = mode, /*!< Test jitter and filter 1/4. */
.debounce_cnt = 1, /*!< 1 time count. */
- .hysteresis_thr = 3, /*!< 3% */
+ //.hysteresis_thr = 3, /*!< 3% */
.noise_thr = 0, /*!< 50% */
- .noise_neg_thr = 0, /*!< 50% */
- .neg_noise_limit = 10, /*!< 10 time count. */
+ //.noise_neg_thr = 0, /*!< 50% */
+ //.neg_noise_limit = 10, /*!< 10 time count. */
.jitter_step = 4, /*!< use for jitter mode. */
};
touch_pad_filter_set_config(&filter_info);
烧录