From 2384d811c990c35f582f553d0e42bd53c6b6e028 Mon Sep 17 00:00:00 2001 From: Chris0xdeadbeef Date: Tue, 23 Sep 2025 11:07:06 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3faaccd..93a4db3 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,25 @@ Now, when you build your project, PlatformIO will download the library from the #include ``` -2. Create a TouchHandler object, providing an array of touch sensor pins and the number of pins. +2. Create a TouchHandler object by providing an array of touch sensor pins, + the number of pins, and a configuration structure specifying parameters + like sample period, initialization period, filter period, sensitivity, + factor, offset, and the number of initial samples. ```cpp const int touchPins[NUM_TOUCH_PINS] = {4, 12, 13, 14, 15, 27, 32, 33}; -TouchHandler touchHandler(touchPins, NUM_TOUCH_PINS); + +TouchConfig config = { + .samplePeriod = 10, // in milliseconds. + .initPeriod = 5000, // Initialization period in milliseconds. + .filterPeriod = 10000, // Filtering period in milliseconds. + .sensitivity = 0.5f, // Sensitivity factor for touch detection. + .factor = 12.0f, // Scaling factor used in threshold calculation. + .offset = 40.0f, // Offset added to baseline for threshold detection. + .numInitSamples = 50 // Number of samples collected during initialization. +}; + +TouchHandler touchHandler(touchPins, NUM_TOUCH_PINS, config); ``` 3. In the setup() function, call the begin() method on the TouchHandler object. @@ -137,7 +151,18 @@ Here is an example of how to use the TouchHandler library in a simple Arduino sk const int NUM_TOUCH_PINS = 8; const int touchPins[NUM_TOUCH_PINS] = {4, 12, 13, 14, 15, 27, 32, 33}; -TouchHandler touchHandler(touchPins, NUM_TOUCH_PINS); + +TouchConfig config = { + .samplePeriod = 10, // in milliseconds. + .initPeriod = 5000, // Initialization period in milliseconds. + .filterPeriod = 10000, // Filtering period in milliseconds. + .sensitivity = 0.5f, // Sensitivity factor for touch detection. + .factor = 12.0f, // Scaling factor used in threshold calculation. + .offset = 40.0f, // Offset added to baseline for threshold detection. + .numInitSamples = 50 // Number of samples collected during initialization. +}; + +TouchHandler touchHandler(touchPins, NUM_TOUCH_PINS, config); void setup() { Serial.begin(115200); @@ -206,4 +231,6 @@ The TouchHandler library is released under the MIT License. This means that you ## Disclaimer -This code and documentation have been generated using ChatGPT, a large language model based on OpenAI's GPT-4 architecture. While efforts have been made to provide accurate information and guidance, please be aware that the content may not be perfect and should be used at your own discretion. \ No newline at end of file +This project is a fork of https://github.com/Defozo/ESP32-TouchHandler +The initial documentation or examples may have been assisted by AI tools, but all further modifications and fixes were made manually by the fork maintainer. +The maintainer takes full responsibility for the changes introduced in this fork. From 141f90e811267a6f835e8a10c2952413cab05b86 Mon Sep 17 00:00:00 2001 From: Chris0xdeadbeef Date: Tue, 23 Sep 2025 11:16:32 +0200 Subject: [PATCH 2/4] feat(example): update demo for new TouchConfig constructor --- examples/turn_on_led_on_touch/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/turn_on_led_on_touch/main.cpp b/examples/turn_on_led_on_touch/main.cpp index 56a56ee..9caefe7 100644 --- a/examples/turn_on_led_on_touch/main.cpp +++ b/examples/turn_on_led_on_touch/main.cpp @@ -10,7 +10,19 @@ const int touchPins[] = {4, 12, 13, 14, 15, 27, 32, 33}; const int numTouchPins = sizeof(touchPins) / sizeof(touchPins[0]); -TouchHandler touchHandler(touchPins, numTouchPins); +// Configure touch parameters +TouchConfig config = { + .samplePeriod = 10, // in milliseconds + .initPeriod = 5000, // Initialization period in milliseconds + .filterPeriod = 10000, // Filtering period in milliseconds + .sensitivity = 0.5f, // Sensitivity factor for touch detection + .factor = 12.0f, // Scaling factor used in threshold calculation + .offset = 40.0f, // Offset added to baseline for threshold detection + .numInitSamples = 50 // Number of samples collected during initialization +}; + +// Initialize TouchHandler with touch pins, number of pins, and configuration +TouchHandler touchHandler(touchPins, numTouchPins, config); void setup() { Serial.begin(115200); @@ -21,7 +33,7 @@ void setup() { void loop() { touchHandler.update(); - for (int i = 0; i < numTouchPins; i++) { + for (int i = 0; i < numTouchPins; ++i) { if (touchHandler.isTouched(i)) { digitalWrite(LED_PIN, HIGH); Serial.print("Touch pin "); From 9d49a06621582261efa1acc46da2c7a0c280ae72 Mon Sep 17 00:00:00 2001 From: Chris0xdeadbeef Date: Tue, 23 Sep 2025 14:28:30 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 93a4db3..4290a28 100644 --- a/README.md +++ b/README.md @@ -233,4 +233,3 @@ The TouchHandler library is released under the MIT License. This means that you This project is a fork of https://github.com/Defozo/ESP32-TouchHandler The initial documentation or examples may have been assisted by AI tools, but all further modifications and fixes were made manually by the fork maintainer. -The maintainer takes full responsibility for the changes introduced in this fork. From b3ab3cb905fc493d14acf6fdd72315dcf7cf8d08 Mon Sep 17 00:00:00 2001 From: Chris0xdeadbeef Date: Thu, 25 Sep 2025 15:58:35 +0200 Subject: [PATCH 4/4] Update README.md changing the disclaimer for pull request --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4290a28..3aed4f4 100644 --- a/README.md +++ b/README.md @@ -231,5 +231,4 @@ The TouchHandler library is released under the MIT License. This means that you ## Disclaimer -This project is a fork of https://github.com/Defozo/ESP32-TouchHandler -The initial documentation or examples may have been assisted by AI tools, but all further modifications and fixes were made manually by the fork maintainer. +This code and documentation have been generated using ChatGPT, a large language model based on OpenAI's GPT-4 architecture. While efforts have been made to provide accurate information and guidance, please be aware that the content may not be perfect and should be used at your own discretion.