landonr / lilygo-tdisplays3-esphome

tdisplay s3 170x320 running esphome using patched tft_espi
85 stars 29 forks source link

Example with touch... not working? #47

Open inakiarredondo opened 6 months ago

inakiarredondo commented 6 months ago

Has anyone managed to get the example-with-touch to work? (with Lilygo T-Display-S3 Touch version) Logs show this message: "[E][lilygo_tdisplay_s3.touchscreen:069]: Failed to communicate!" (8 times in a row, each time I touch the screen) Any advice? Thank you.

guillempages commented 6 months ago

I haven't seen that; for me it was working until I updated to the latest dev.

Currently (with latest dev; which will be released with ESPHome 2023.12), the touchscreen component cannot even be compiled :-(

Working on that, but no ETA yet

guillempages commented 6 months ago

The base touchscreen component was changed, and all external touchscreen components need some reworking.

I've got it to compile, but the touch coordinates are completely bonkers. Will keep looking.

guillempages commented 6 months ago

Not looking good... I've got it working if I don't set the display rotation, but as soon as I set rotation 90 or 270, the y coordinates get halved (i.e. from 0-90 instead of 0-170).

On the plus side of things, there is a PR on the official ESPHome repo (https://github.com/esphome/esphome/pull/5941) that adds touchscreen functionality for exactly this same touch controller. And it's a PR by someone who was involved on the touch/display discussions that are causing the problem now.

So there is a chance, that official support for this touch screen is coming into ESPHome core "soon"

inakiarredondo commented 6 months ago

Thank you for your answer. How did you do to make it working just don't setting the display rotation? Just removing that line doesn't make any change for me...

PS: Fingers crossed for the official support "soon".

guillempages commented 6 months ago

To make the "t-display-s3 touchscreen" work, I had to do many changes in the code, that I haven't pushed yet. The PR I mentioned above works "out-of-the-box", if the display rotation is 0 (i.e. not set).

external_components:
  - source: github://pr#5941
    components: [cst816]

touchscreen:
  - platform: cst816
    display: disp
    interrupt_pin: 16
    id: my_touchscreen
    on_touch:
      - lambda: |-
         auto touch_point = id(touch_all).get_touches()[0];
         ESP_LOGI("tdisplays3-touch", "Touchdown: x:%d, y:%d",
           touch_point.x,
           touch_point.y
         );

If I change the display rotation, then the touch coordinates are just wrong 😢

inakiarredondo commented 6 months ago

Could you share the full code (for me to try it)? Thanks!

guillempages commented 6 months ago

@inakiarredondo I've created a PR (#50) that should fix the compilation issues with 2023.12

Whether this also fixes the "Failed to communicate" issue you originally mentioned, I cannot tell, since I'm not seeing this (nor was seeing it before). But it is probably worth a try (it is actually a must, if you upgraded to ESPHome 2023.12.0 or later)

inakiarredondo commented 6 months ago

Now, once updated to ESPHome 2023 12.3, I get this warning Couldn't find any component that can be used for 'display::Display'. Are you missing a hub declaration? when editing, highlighting tdisplays3 on this section:

touchscreen:
  - platform: tdisplays3
    interrupt_pin: 16
    address: 0x15
    ...
guillempages commented 6 months ago

Yes, with 2023.12.0 there were some changes done to the touchscreen base component, that in turn required changes to the implementations.

That's what #50 should fix, but somehow it does not get through CI, so we cannot merge it. I'm also afk for two weeks, so unfortunately I cannot look into that at the moment.

You might want to take a look at that PR; if I am not mistaken I wrote a comment on how to use that (you need to add @<branch> to the external component, but I can't tell you the exact name of the branch)

guillempages commented 5 months ago

@inakiarredondo The needed PR has been merged now. Can you try without the @branch part, and see if it is now working for you? Then we could close this issue

inakiarredondo commented 5 months ago

Sorry for the delay.

Yes, I've tried without the @branch part, with ESPHome 2023.12.5 and also with 2023.12.7 ...but the "Failed to communicate!" keeps arising on the logs.

Iñaki

raphbag commented 2 months ago

Hello, I have the same problem with this error : "[lilygo_tdisplay_s3.touchscreen:082]: Failed to communicate!" when I touch the screen with ESPHome 2024.4.1. Is there any news about this ?

raphbag commented 1 month ago

I finally solved my problem. I had just reversed the sda and scl pin which is not the right one on the doc image (and the right one on your example).