adafruit / Raspberry-Pi-Installer-Scripts

381 stars 160 forks source link

PiTFT 3.5" Plus slow touch response #307

Closed mikeysklar closed 6 months ago

mikeysklar commented 6 months ago

Script Command

sudo -E env PATH=$PATH python3 adafruit-pitft.py --display=35r --rotation=90 --install-type=mirror

Operating System

64-bit Pi OS Bookworm Desktop

Hardware

Pi 4B

Behavior

2min delay with touch screen updates

Description

Install runs smoothly. X comes up. Touch response works. There is a two minute lag from when I press a location on the screen to when it responds.

Additional information

IMG_2598

evtest runs fine with immediate output.

dmesg might provide a clue here:

$ dmesg | grep -i stmpe
[    2.221584] stmpe-spi spi0.1: stmpe610 detected, chip id: 0x811
[    2.244321] stmpe-gpio stmpe-gpio: DMA mask not set
[    6.148211] stmpe-ts stmpe-ts: DMA mask not set
[    6.461093] input: stmpe-ts as /devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.1/stmpe-ts/input/input4

Based on forum issue brought up by @ronaldlw.

mikeysklar commented 6 months ago

Rolled back to Bullseye Legacy 64-bit Full install and touchscreen is very responsive and usable. No issues on that legacy release.

Screenshot 2024-04-26 at 10 25 19 AM

makermelissa commented 6 months ago

Good to know. In both cases, it is using the touch drivers provided by Raspberry Pi. It's possible they need to be updated and a PR submitted to Raspberry Pi.

mikeysklar commented 6 months ago

@makermelissa -

I suspect the touch driver STMPE is good as evtest is responsive.

Somewhere along the Xwin process of translating those coordinates to icons to opening drop down menus a timeout must be happening. I'm looking through the log files and see another clue. These are coming in one line at a time after the 2min timeout.

pi5 : Bookworm 12/5/23 : $HOME/.xsession

II 26-04-24 12:31:01.035 - [src/view/xdg-shell.cpp:25] New xdg popup
II 26-04-24 12:31:23.363 - [src/view/xdg-shell.cpp:25] New xdg popup
EE 26-04-24 12:31:24.719 - [types/seat/wlr_seat_touch.c:303] got touch point focus for unknown touch point

I'm suspicious of WAYLAND and xdg interactions.

mikeysklar commented 6 months ago

Yeah...Wayland it is...

raspi-config --> Advanced --> W1 X11 (do not use Wayfire Wayland backend [default])

modify /boot/firmware/config.txt comment out this line:

#dtoverlay=vc4-kms-v3d

reboot...

Display has instant response time on Pi5 Bookworm / 12/5/23 release.

mikeysklar commented 6 months ago

@ronaldw's automated change for rolling back to the Xorg server.

sudo sed -e '/dtoverlay=vc4/ s/^#*/#/' -i /boot/firmware/config.txt
sudo sed -i -e '/greeter-session=/ s/=.*/=pi-greeter/' /etc/lightdm/lightdm.conf
sudo sed -i -e '/user-session=/ s/=.*/=LXDE-pi-x/' /etc/lightdm/lightdm.conf
sudo sed -i -e '/autologin-session=/ s/=.*/=LXDE-pi-x/' /etc/lightdm/lightdm.conf
mikeysklar commented 6 months ago

Strace output collected from the /usr/bin/wayfire process during a menu timeout while using the Wayland X server.

This is the moment where the screen responds and the -1 EAGAIN (Resource temporarily unavailable) goes away and the message goes through to drop down the main menu.

sudo strace -p 1058
epoll_pwait(3, [{events=EPOLLIN, data={u32=184344496, u64=93828039892912}}], 32, -1, NULL, 8) = 1                                                                                                                                      epoll_pwait(42, [{events=EPOLLIN, data={u32=183526576, u64=93828039074992}}], 32, 0, NULL, 8) = 1                                                                                                                                      read(46, "\331\2\0\0\0\0\0\0\234\305\1\0\0\0\0\0\3\0\0\0D\16\0\0\331\2\0\0\0\0\0\0"..., 6144) = 96                                                                                                                                     read(46, 0x55560aefee00, 6144)          = -1 EAGAIN (Resource temporarily unavailable)                                                                                                                                                 recvmsg(51, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)                                                                                                                                                 sendmsg(60, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\36\0\0\0\2\0\30\0\34 \v\0\0\0\0\0\370\253\1\0\354\35\0\0\36\0\0\0\3\0\10\0", iov_len=32}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 32                                                                                                                                                                                                                                      epoll_pwait(3, [{events=EPOLLIN, data={u32=184344496, u64=93828039892912}}], 32, -1, NULL, 8) = 1                                                                                                                                      epoll_pwait(42, [{events=EPOLLIN, data={u32=183526576, u64=93828039074992}}], 32, 0, NULL, 8) = 1                                                                                                                                      read(46, "\331\2\0\0\0\0\0\0\354\302\2\0\0\0\0\0\3\0\30\0\0\0\0\0\331\2\0\0\0\0\0\0"..., 6144) = 72                                                                                                                                    read(46, 0x55560aefee00, 6144)          = -1 EAGAIN (Resource temporarily unavailable)                                                                                                                                                 recvmsg(51, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)                                                                                                                                                 sendmsg(60, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\36\0\0\0\1\0\24\0\303\1\0\0\\ \v\0\0\0\0\0\36\0\0\0\3\0\10\0", iov_len=28}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 28             epoll_pwait(3, [{events=EPOLLIN, data={u32=184350736, u64=93828039899152}}], 32, -1, NULL, 8) = 1                                                                                                                                      recvmsg(60, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\4\0\0\0\0\0\20\0/\0\0\0\370\346\7\0/\0\0\0\0\0 \0<\0\0\0\0\0\0\0"..., iov_len=2584}, {iov_base="", iov_len=1512}], msg_iovlen=2, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[68]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_CMSG_CLOEXEC) = 180                                                                                               fcntl(68, F_GET_SEALS)                  = 0x1 (seals F_SEAL_SEAL)                                                                                                                                                                      mmap(NULL, 517880, PROT_READ|PROT_WRITE, MAP_SHARED, 68, 0) = 0x7fff00518000                                                                                                                                                           close(68)                               = 0                                                                                                                                                                                            getpid()                                = 1058

Full strace:

wayfire-strace-touchscreen.txt

makermelissa commented 6 months ago

Thanks. I'm working on updating the script to temporarily switch to x11 (which should provide a temporary workaround) until we can get it working in Wayland again.

makermelissa commented 6 months ago

I'm pretty sure the 2.8" resistive touch screen (with STMPE610) uses the same touch driver, so will test that out as well.

makermelissa commented 6 months ago

To automatically change to X11, you can run sudo raspi-config nonint do_wayland W1, which runs the raspi-config script that runs the sed commands.

makermelissa commented 6 months ago

309 should fix the issue.

mikeysklar commented 6 months ago

Confirmed.

Pi5 / Bookworm 3/15 drop + PiTFT 3.5" Plus

Works smooth with X11 rollback updates added to adafruit-pitft.py today.

mikeysklar commented 6 months ago

Pi4 / Bookworm 3/15 drop + PiTFT 3.5" Plus

Also works smoothly with adafruit-pitft.py.

Two notable differences:

1) resolution:

2) mouse pointer

mikeysklar commented 6 months ago

Should the file /boot/firmware/config.txt contain the correct resolution for this display?

change this:

hdmi_cvt=720 480 60 1 0 0 0

to this:

hdmi_cvt=480 320 60 1 0 0 0

I did test this on the Pi4 to match up the display with my Pi5 and it is a little easier to with the larger menu items.

makermelissa commented 6 months ago

I believe the reason the resolutions are different was because it wasn't being scaled in the config.txt anymore when it was updated for wayland, which ignores those parameters and the changes are performed in the wayfire.ini file instead. However, for non-wayland devices, it should be the 720x480 because the start menu can become inaccessible otherwise due to screen height.

mikeysklar commented 6 months ago

kk. You can close this issue.