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

Touchio - slow updates when touching multiple touch-pins #9624

Open
BennettB123 opened this issue Sep 14, 2024 · 5 comments
Open

Touchio - slow updates when touching multiple touch-pins #9624

BennettB123 opened this issue Sep 14, 2024 · 5 comments
Assignees
Milestone

Comments

@BennettB123
Copy link

CircuitPython version

Adafruit CircuitPython 9.1.2 on 2024-08-22; Waveshare ESP32-S3-Zero with ESP32S3

Code/REPL

from touchio import TouchIn
import board
import time

pins = []
pins.append(TouchIn(board.D13))
pins.append(TouchIn(board.D12))
pins.append(TouchIn(board.D11))
pins.append(TouchIn(board.D10))
pins.append(TouchIn(board.D9))
pins.append(TouchIn(board.D8))
pins.append(TouchIn(board.D7))

while True:
    i = 0
    for pin in pins:
        print(i, "raw_value: ", pin.raw_value)
        i += 1
    print()
    time.sleep(.01)

Behavior

The example code prints out the raw_values of all touch pins. When 0 or 1 pins are touched, the values update extremely fast (updating every loop iteration). However, whenever 2 or more pins are touch simultaneously, All of the other pin's raw_values update extremely slowly (in some cases taking several seconds to update).

Description

No response

Additional information

My goal is to be able to accurately/quickly handle simultaneous touch inputs.

@dhalbert dhalbert self-assigned this Sep 14, 2024
@tannewt tannewt added this to the Long term milestone Sep 16, 2024
@tannewt
Copy link
Member

tannewt commented Sep 16, 2024

@dhalbert did you mean to self-assign this?

@dhalbert
Copy link
Collaborator

@dhalbert did you mean to self-assign this?

Yes, I discussed it with @BennettB123 in discord and plan to test this in more detail.

@dhalbert
Copy link
Collaborator

dhalbert commented Sep 17, 2024

@BennettB123 I tested this with an Adafruit Metro ESP32-S3, running CircuitPython 9.2.0-beta.0. I connected some ~6-inch jumpers with alligator clips at one end to D8 through D11. Touching two alligator cips with one hand and two with another produced raw values of 65535, as expected, but the loop was still running very quickly. I also tried clipping coins with the alligator clips, and that made no difference.

I am suspecting something about your setup, but I'm not sure what it is. We did talk about whether there was coupling between the wires, but I twisted all the wires together and it made no difference.

EDIT: I also tested with a QT PY ESP32-S3, which has a similar form factor to the WaveShare, and so has much shorter on-board traces. I got similar good results.

@BennettB123
Copy link
Author

@dhalbert Thanks for testing! I went ahead and upgraded to 9.2.0-beta.0 to rule out differences there and I'm still getting the same behavior. One thing I may not have made clear is that the loop still runs very quickly when I'm touching several pins. However, the actual raw_values don't update every loop iteration like they do when no pins are touched.

If you touch 3 of your alligator clips and leave the 4th alone, do you notice any slowdowns in how often the raw_value of the 4th pin updates? When I do this scenario, the 4th pin's raw_value only updates once every second (rather than every loop iteration when no pins are touched)

@dhalbert
Copy link
Collaborator

Ah, I did misunderstand you about the loop timing. However, I am seeing quick response when touching three and then adding a fourth. I will try some more experiments tomorrow.

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

No branches or pull requests

3 participants