EasyManua.ls Logo

Freenove ESP32 - Page 116

Default Icon
159 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Need support? support@freenove.com
114
Chapter 11 Touch
www.freenove.com
The following is the code:
1
2
3
4
5
6
7
8
9
10
11
12
#include "TouchPad.h"
void setup() {
Serial.begin(115200);
setupTouchPad();
}
void loop() {
int isTouch = getTouch();
Serial.printf("Touch state: %d\r\n", isTouch);
delay(100);
}
Initialize touch sensing function pins.
5
setupTouchPad();
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.
9
int isTouch = getTouch();
TouchPad.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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

Related product manuals