#include "TouchPad.h"
void setup() {
Serial.begin(115200);
setupTouchPad();
}
void loop() {
int isTouch = getTouch();
Serial.printf("Touch state: %d\r\n", isTouch);
delay(100);
}
Get the status value of the touch sensor. When the sensor is not touched, the state value is 0. When it is
touched, the status value is 1. The short press status value is 2, and the long press status value is 3.
#ifndef _TOUCHPAD_h
#define _TOUCHPAD_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "driver/touch_pad.h"
#define PIN_TOUCH_PAD (TOUCH_PAD_NUM3)
#define TOUCH_THRESH_NO_USE (0)
#define TOUCH_THRESH_PERCENT (80)
#define TOUCHPAD_FILTER_TOUCH_PERIOD (10)
void setupTouchPad(void);
void __attribute__((weak)) isr_touchpad(void *arg);
extern void isr_touchpad(void *arg);
void isr_touchpad();
void task_TouchPad(void *pvParameters);
void task_Touch(void *pvParameters);
int getTouch(void);
#endif