Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 S2 touch threshold has no effect #4076

Open
1 task done
RobinMeis opened this issue Jul 26, 2024 · 8 comments
Open
1 task done

ESP32 S2 touch threshold has no effect #4076

RobinMeis opened this issue Jul 26, 2024 · 8 comments
Labels

Comments

@RobinMeis
Copy link

RobinMeis commented Jul 26, 2024

What happened?

I'm running WLED 0.15.0-b4 on ESP32 S2 Mini. Adjusting the touch threshold doesn't change anything. Sensitivity doesn't change, it doesn't make any difference if I set the threshold to 1 or to 100. Sensitivity is always too low.

To Reproduce Bug

Attach a touch surface to the board and play around with the touch threshold.

Expected Behavior

Changing the threshold should change the sensitivity

Install Method

Binary from WLED.me

What version of WLED?

0.15.0-b4

Which microcontroller/board are you seeing the problem on?

ESP32-S2

Relevant log/trace output

No response

Anything else?

I think this is related to #3798 and the shifting of touchThreshold in
https://github.com/DedeHai/WLED/blob/15526bd6e8c7a75ee1e36cf24ae397a674f63c56/wled00/cfg.cpp#L260

touchAttachInterrupt(btnPin[s], touchButtonISR, touchThreshold<<4); //threshold on Touch V2 is much higher (1500 is a value given by Espressif example)

Maybe the shifting causes a scaling issue.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@RobinMeis RobinMeis added the bug label Jul 26, 2024
@blazoncek
Copy link
Collaborator

This change was implemented by @DedeHai and will require his attention.

@DedeHai
Copy link

DedeHai commented Jul 26, 2024

I will take a look. If I remember correctly, the base value is automatically adjusted (auto calibration) and thresholf is just for fine-tuning but that may be a misconception on my side.
What was the exact geometry and setup of your touch button?

@RobinMeis
Copy link
Author

I started to compile the firmware on my own and played around with the mentioned threshold scaling. I could achieve the desired sensitivity by lowering the threshold significantly. In my tests including touch buttons behind plastic covers, values around 100 worked best.

With ESP32 Wroom I observed that I had to increase the threshold to get a higher sensitivity but for Touch V2 it seems to be opposite. Setting the threshold < 100 results in ghost touches for some buttons. On the other hand setting the threshold static to 65300 results in no sensitivity at all.

So I think that we need to find a proper range to implement a better scaling. I modified the scaling to allow values between 50 and 3050. At least for the buttons I tested with, the range seems to be suitable.

I pushed my current changes to https://github.com/RobinMeis/WLED/blob/9c7afedece573d0611541cfe372f48fbd9b0c056/wled00/cfg.cpp#L299

@RobinMeis
Copy link
Author

RobinMeis commented Jul 26, 2024

What was the exact geometry and setup of your touch button?

For testing I used a round copper plate with a diameter of 18mm behind different thin plastic cards to simulate a hidden button. Without the plastic cards it worked. The real "button" is actually a coil spring that is part of a light.

Both worked well with ESP32 Wroom, but I could only get them working with ESP32 S2 after the described modifications.

@softhack007 softhack007 changed the title ESP32 C2 touch threshold has no effect ESP32 S2 touch threshold has no effect Jul 26, 2024
@DedeHai
Copy link

DedeHai commented Jul 26, 2024

So I think that we need to find a proper range to implement a better scaling. I modified the scaling to allow values between 50 and 3050. At least for the buttons I tested with, the range seems to be suitable.

Bit contradictory. The code uses a range from 0 to 4080 (at least it should, no PC access RN to check), which you say does not do anything. Could it be just a missing typecast?

@RobinMeis
Copy link
Author

RobinMeis commented Jul 26, 2024

It doesn't. What I replaced from current 0_15 branch was
256 + (touchThreshold << 4)
which won't allow to go below 256, but yes, not adding 256 should also work and would be a cleaner solution, just missed to test this while playing around

@GHBLoos
Copy link

GHBLoos commented Sep 7, 2024

I have the same problem, meaning there is no response at all on a touch. I like to check my config first to exclude a possible wrong setting or so, before I build and flash.

ESP32 wemos S2 mini
version v0.14.4 "Hoshi"

In prefeferences:
Button 0 GPIO 14 - Touch
Currently I have a 10cm wire connected to GPIO 14 with a stripped end of about 4 cm

@RobinMeis : Do you have a comparable config?

@DedeHai
Copy link

DedeHai commented Sep 7, 2024

V0.14 has no touch support for S2/S3, that bug is fixed in latest 0.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants