mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-30 20:40:59 +02:00
Summary Added compiler.warning_flags to all chips in platform.txt to reflect users setting of warning level output during compilation (set up in Arduino IDE preferences) Impact When a warning is set to none the compilation will no longer display warnings Related links Solves issue #6118
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
/*
|
|
|
|
This is an example how to use Touch Intrrerupts
|
|
The sketh will tell when it is touched and then relesased as like a push-button
|
|
|
|
This method based on touchInterruptGetLastStatus() is only available for ESP32 S2 and S3
|
|
*/
|
|
|
|
#include "Arduino.h"
|
|
|
|
int threshold = 1500; // ESP32S2
|
|
bool touch1detected = false;
|
|
bool touch2detected = false;
|
|
|
|
void gotTouch1() {
|
|
touch1detected = true;
|
|
}
|
|
|
|
void gotTouch2() {
|
|
touch2detected = true;
|
|
}
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(1000); // give me time to bring up serial monitor
|
|
|
|
Serial.println("\n ESP32 Touch Interrupt Test\n");
|
|
touchAttachInterrupt(T1, gotTouch1, threshold);
|
|
touchAttachInterrupt(T2, gotTouch2, threshold);
|
|
}
|
|
|
|
void loop() {
|
|
if (touch1detected) {
|
|
touch1detected = false;
|
|
if (touchInterruptGetLastStatus(T1)) {
|
|
Serial.println(" --- T1 Touched");
|
|
} else {
|
|
Serial.println(" --- T1 Released");
|
|
}
|
|
}
|
|
if (touch2detected) {
|
|
touch2detected = false;
|
|
if (touchInterruptGetLastStatus(T2)) {
|
|
Serial.println(" --- T2 Touched");
|
|
} else {
|
|
Serial.println(" --- T2 Released");
|
|
}
|
|
}
|
|
|
|
delay(80);
|
|
}
|