EasyManuals Logo

Freenove ESP32 User Manual

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
Page #118 background imageLoading...
Page #118 background image
Need support? support@freenove.com
116
Chapter 11 Touch
www.freenove.com
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
touch_pad_intr_enable();
xTaskCreateUniversal(task_Touch, "task_Touch", 4096, NULL, 1, NULL, 1);
}
uint8_t touchMechineStatus = 0;
uint32_t t0 = millis(), // start time point
t1 = 0, // update time point
t2 = 0, // release time
t3 = 0; // pressed time
void task_TouchPad(void *pvParameters) {
switch (touchMechineStatus) {
case 0: // Idle , Wait for the button to press.
if (touchPadVal) {
t0 = millis();
t1 = t0;
touchPadVal = false;
touchMechineStatus = 1;
}
break;
case 1: // short press or long press ?
if (touchPadVal) {
t1 = millis();
touchPadVal = false;
}
t2 = millis() - t1; // Time since the last press signal was detected
t3 = t1 - t0; // calculate pressed time.
if (t3 > 700) // long pressed
{
Serial.printf("long press: %dms\n", t3);
touchMechineStatus = 3; // wait release
}
if (t2 > 50) // release time > 50, press time < 700, short press, enter short pressed state
{
touchMechineStatus = 2;
}
break;
case 2: // short press
Serial.printf("short press: %dms\n", t3);
touchMechineStatus = 0;
break;
case 3: // Wait for release after long press.
if (touchPadVal) {
t1 = millis();

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove ESP32 and is the answer not in the manual?

Freenove ESP32 Specifications

General IconGeneral
BrandFreenove
ModelESP32
CategoryComputer Hardware
LanguageEnglish

Related product manuals