Skip to content

esp32: Fix stuck TouchPad readings on ESP32-S3, use version specifiers in code. #16169

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

Merged
merged 3 commits into from
Nov 28, 2024

Conversation

projectgus
Copy link
Contributor

@projectgus projectgus commented Nov 6, 2024

Summary

The new order of initialisation matches more closely the order in Espressif's example code, i.e.
https://github.com/espressif/esp-idf/blob/v5.2.2/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/tp_read_main.c#L86

This work was funded through GitHub Sponsors.

Testing

  • Tested on ESP32, ESP32-S2 and ESP32-S3 using the example code from the linked issue. Plus a similar example which initialised multiple channels.
  • Unfortunately I had no working boards with PCB touch pads, so used dupont wires hanging off dev board connections... Works well enough.

The only buggy case of stuck max readings that I was able to reproduce was on ESP32-S3, and never reproduced once the fix was applied.

The hardware FSM did seem to get stuck once on ESP32-S3 in a different way (was reading correctly and then stopped updating and didn't start again). However I think this was due to my poor quality touch pad inputs (had moved the wires a lot and it would have changed capacitance by a huge factor).

Trade-offs and Alternatives

  • The Espressif touch sensor V2 hardware in S2 and S3 has a lot of features (denoise, background averaging, etc) which MicroPython is not using. It'd be good to support this, although it'd be a lot of work for someone and also may break code that relies on the current "raw" readings.

@projectgus
Copy link
Contributor Author

@wangshujun-tj Thanks for submitting the bug report and the description of a fix, and for being patient while we followed up.

@wangshujun-tj @brainstorm @SkaveRat do any of you have hardware that you can use to confirm this fix before we merge it?

@brainstorm
Copy link

brainstorm commented Nov 11, 2024

Tested on my side, works like a charm 🚀

/cc @GoatNote @adricl

@projectgus projectgus requested a review from dpgeorge November 12, 2024 00:07
brainstorm added a commit to CCHS-Melbourne/Spectrogram that referenced this pull request Nov 12, 2024
…, mapped both touch buttons... LED and MIC still need to be fixed/mapped correctly to their pins
@brainstorm
Copy link

brainstorm commented Nov 13, 2024

Tested on an aditional (different design/prototype) board with an esp32s3-mini-1u module: the difference between having this PR applied or not means reliable touch support or not.

ESP32 has hardware V1 and S2/S3 has V2, and future chips
may have different versions.

This should still compile to the same binary before and after.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Closes micropython#13178.

TouchPad confirmed working on both chips, and fixes the the ESP32-S3
reading constant max value. Was unable to reproduce the bug on ESP32-S2 but
this may be due to my test setup, and it still works with the fix.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
@projectgus projectgus force-pushed the bugfix/touch_fsm_start branch from fb6c8da to 63e184e Compare November 20, 2024 03:19
@projectgus
Copy link
Contributor Author

Updated according to review, re-tested with dodgy dupont wire method on ESP32-S2 and original ESP32, rebased.

@projectgus projectgus requested a review from dpgeorge November 27, 2024 22:54
@projectgus projectgus merged commit 154d141 into micropython:master Nov 28, 2024
9 checks passed
@projectgus projectgus deleted the bugfix/touch_fsm_start branch November 28, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

esp32s3 TouchPad not working
3 participants