Overview

The OSOYOO 3.5HDMI resistive touchscreen does not work properly when using the default Wayfire graphics system on the Raspberry Pi 4B and 5B. However, if you change the default graphics system on these models to X11, it will work fine.

The tutorial you mentioned for adapting the OSOYOO 3.5HDMI resistive touchscreen on the Bullseye system should still be applicable. However, the touchscreen functionality does not seem to work on Bookworm’s default Wayfire graphics system. If you want to adjust this resistive touchscreen to the default Wayfire graphics system in Bookworm, you may need to perform additional configuration steps. In this case, you may need to explore other methods or configurations to make the ADS7846 touchscreen compatible with Wayfire in Bookworm. It is recommended that you consult the official documentation or community forums for Bookworm and Wayfire for further assistance in adjusting the touchscreen.

Click here for more information about Bookworm.

Getting Started

Hardware Connection

Connect the GPIO and HDMI interface

Raspberry Pi leads out 40 GPIO pins, while the screen leads out 12 pins. When connecting, pay attention to the corresponding pins and Raspberry Pi pins.

Install image file

1) Install the Bookworm image as the official website or follow our tutorial.

2)After the image has finished writing, save and quit the TF card safely.

3) Insert the TF card into the Raspberry Pi, power on the Raspberry Pi, and wait for more than 10 seconds to display normally. But the touch is abnormal at that time, and the touch needs to be calibrated as the following steps.

Note:

Recommend to remotely control Raspberry Pi via ssh, VNC or other remote desktop tools, as the resolution is too high as default. (Here we use putty for Windows users. You can learn more about remotely control Raspberry Pi from: https://osoyoo.com/?p=56660)

Touch settings

Step 1) The option to set to use X11 instead of Wayland

Enable SSH so logged in and ran

sudo raspi-config

In there under 6 Advanced Options there’s A6 Wayland which now controls which backend to use for the desktop. In Bookworm it now defaults to Wayland on the PI4 & soon PI5, so we need to switch it to W1 X11.

Save your settings and reboot the Raspberry Pi.

The option to set to use X11 instead of Wayland

Note: Raspberry Pi OS Bookworm branch system, since dtoverlay=vc4-kms-v3d is loaded by default, it is invalid to modify the resolution in /boot/config.txt. If you need to modify the resolution, you need to click the Raspberry Pi icon -> Preferences -> Screen Configuration. We recommend setting the resolution to 640×480.

Touch settings

It needs install xpt2046(ads7846) driver, so we need to add settings to the config.txt file.

Open config.txt

sudo nano /boot/config.txt

Add following parameters to the end of the config.txt file

hdmi_group=2
hdmi_mode=87
hdmi_drive=1
hdmi_pixel_freq_limit=20000000
hdmi_cvt 480 320 60 6 0 0 0

dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900

Save/close the file, and reboot

Press ctrl + X then Y to save this file, then type below command to reboot:

sudo reboot

Install xpt2046 driver, and calibrator

sudo apt install xserver-xorg-input-evdev

sudo apt install -y xinput-calibrator

Config touch calibration files

sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf

sudo nano /usr/share/X11/xorg.conf.d/99‐calibration.conf


Section “InputClass”

Identifier      “calibration”

MatchProduct    “ADS7846 Touchscreen”

Option  “Calibration”   “211 3942 3905 141”

Option  “SwapAxes”      “1”

EndSection


Add the above string lines to 99-calibration.conf, save/close.

Reboot

sudo reboot

Calibrate touch

Run [Preferences]-[Calibrate Touchscreen] from main menu, or enter

DISPLAY=:0.0 xinput_calibrator

In the terminal.

After calibration (click four cross bar points on corners), it will show the calibration values which are similar to previously written to the 99-calibration.conf file.

open 99‐calibration.conf file again.

sudo nano /usr/share/X11/xorg.conf.d/99‐calibration.conf

Replace

Option  “Calibration”   “211 3942 3905 141”

Option  “SwapAxes”      “1”

values with data shown in the calibration result.

Check touch, repeat calibration if it is not correct.

 

Note

Doing so means you are no longer using Wayland. Might the a temporary solution only as all Pi’s will be ‘converted’ to use Wayland and then that option will be dropped most likely.Yes – it would be great if I could figure out how to calibrate within Wayland, but I just couldn’t find anything.

for now, Wayland is only the default on Raspberry Pi 4 and 5. The performance of Wayfire on earlier platforms is still being optimised, so for now they will continue to run the old X11 display server and the Openbox window manager, but at some point these platforms will also be switched to Wayfire.

We’ll be following the official Raspberry Pi posts and updating the tutorials!

How to verify that your X11 desktop system is running properly?

You can tell which one you are running by using “echo $GDMSESSION” in a terminal.(Connecting to the system using SSH-like tools and executing this command will not produce any results.)
“LXDE-pi-wayfire” means Wayland.
“LXDE-pi-x” means X11