jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

[solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Wed Feb 08, 2017 9:06 pm

Hi,

I have an LCD that is a Waveshare copy, this one.
I'm having trouble getting the touch to work properly in PIXEL.

I'm running the lates jessie (2017-01-11) on a Raspberry Pi 3. The LCD is displaying the Picture as it should.

The issue is that the touch area seems to be "bigger" that the screen. When I press the screen in the middle the cursor is in the same Place, but as I move to the borders of the screen the curser "falls behind", and when I'm right at the edge of the screen the cursor is about 10 mm in on the screen. So, I am unable to open the startmenu or perss any of the icons in the task bar.

I've run xinput_calibrator and saved the calibration data in /etc/X11/xorg.conf.d/99-calibration.conf with not luck.

What I have to get the touch screen working at all is this:
  • 1. Added this to /boot/config.txt:

    Code: Select all

    dtparam=i2c_arm=on
    dtparam=spi=on
    
    dtoverlay=ads7846,penirq=25,speed=10000,penirq_pull=2,xohms=150
  • 2. Added this to /etc/modules:

    Code: Select all

    ads7846_device model=7846 cs=1 gpio_pendown=25 speed=1000000 keep_vref_on=1 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=184 x_max=3869 y_min=141 y_max=3959
  • 3. Added this to /etc/X11/xorg.conf.d/99-calibration.conf

    Code: Select all

    Section "InputClass"
            Identifier      "calibration"
            MatchProduct    "ADS7846 Touchscreen"
            Option  "MinX"  "2778"
            Option  "MaxX"  "63781"
            Option  "MinY"  "3254"
            Option  "MaxY"  "62964"
            Option  "SwapXY"        "0" # unless it was already set to 1
            Option  "InvertX"       "0"  # unless it was already set
            Option  "InvertY"       "0"  # unless it was already set
    EndSection
    
I have also tried using Waveshares LCD5-show script with the same result as using the above steps.

However, when I run ts_calibrate and ts_test the touch works perfect! So I Think there might be something off with the X calibration. Or, is there a way to use tslib as driver for the touch screen in X?

I've seen a few other people on the Internet that has the same issue, but no solution.

Is there anyone here that might be able to assist me? I consider my self an advanced user, but this is something out of my league.

Thanks in advance!

Regards,
Jonas
Last edited by jonaslorander on Wed Mar 15, 2017 7:07 pm, edited 1 time in total.

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Feb 10, 2017 2:15 pm

How do you have so large calibration numbers?
Please install evtest run it using sudo evtest and post the touch log for the corner points.

:D By the way I have the XPT issue as well. Just purchased 4inch display and I have failed in calibration. Touch simply gives random numbers.....or no numbers at all. Though I use my own instructions (viewtopic.php?t=143581), nothing helps.
It seems like ther is a certain noise in the touch interface which results the touch pannel issues.
Will check with oscilloscope today and report. And I will test it with the older Jessie version.

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Feb 10, 2017 8:31 pm

I have never thought that I could reach the rage state during debug. :evil:

What happened: when I test the reaction on SPI pins in position "Screen faces table" then oscilloscope shows the perfect signal
But when I try to calibrate with the display up then I see only issues without any systematic diagnosis. Touch simply does not react at all!!! Or leads the cursor to the edge.

That drives me crazy. But suddenly, I have touched the the output pins near the end of the glass and everything have started to operate PERFECTLY!!!

So I took the transparent duct tape and stick it on the screen with good pressure. That had fixed all issues with the touch screen :twisted:
20170210_210605.jpg
20170210_210605.jpg (56.92 KiB) Viewed 50242 times
[img]20170210_210605.jpg[/img]

THEREFORE: I believe that you have touch glass issue like mine. Please check the panel output!!!!

Some more info:
I do not use Modules file any more
I do not use axis swap any more.

Adding my config here

Code: Select all

dtparam=spi=on
dtparam=i2c_arm=on
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 800 60 6 0 0 0
display_rotate=3
dtoverlay=ads7846,penirq=25,speed=10000,keep_vref_on=0,penirq_pull=2,xohms=150
Adding 99-calibration.conf calibration file content here

Code: Select all

Section "InputClass"
        Identifier "calibration"
        MatchProduct "ADS7846 Touchscreen"
        Option "Calibration" "3853 170 288 3796"
        Option "SwapAxes" "1"
EndSection
I will update main instructions

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Feb 10, 2017 8:38 pm

Those are the values I got from xinput_calibrator...

I did run evtest just a few minutes ago and the values are much lower.

Here are the values of top left corner and bottom right:

Code: Select all

Event: time 1486758330.018684, -------------- EV_SYN ------------
Event: time 1486758337.921061, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1486758337.921061, type 3 (EV_ABS), code 0 (ABS_X), value 302
Event: time 1486758337.921061, type 3 (EV_ABS), code 1 (ABS_Y), value 299
Event: time 1486758337.921061, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65178
Event: time 1486758337.921061, -------------- EV_SYN ------------
Event: time 1486758337.931099, type 3 (EV_ABS), code 0 (ABS_X), value 304
Event: time 1486758337.931099, type 3 (EV_ABS), code 1 (ABS_Y), value 294
Event: time 1486758337.931099, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65184
Event: time 1486758337.931099, -------------- EV_SYN ------------
Event: time 1486758337.941156, type 3 (EV_ABS), code 0 (ABS_X), value 308
Event: time 1486758337.941156, type 3 (EV_ABS), code 1 (ABS_Y), value 301
Event: time 1486758337.941156, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65047
Event: time 1486758337.958742, -------------- EV_SYN ------------
Event: time 1486758339.000121, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1486758339.000121, type 3 (EV_ABS), code 0 (ABS_X), value 3807
Event: time 1486758339.000121, type 3 (EV_ABS), code 1 (ABS_Y), value 3662
Event: time 1486758339.000121, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65173
Event: time 1486758339.000121, -------------- EV_SYN ------------
Event: time 1486758339.010132, type 3 (EV_ABS), code 0 (ABS_X), value 3817
Event: time 1486758339.010132, type 3 (EV_ABS), code 1 (ABS_Y), value 3661
Event: time 1486758339.010132, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 64975
I did enter these new values in 99-calibration.conf, but they doesn't seem to be used. What ever values I type I see no difference in the behaviour of the mouse pointer...

Also, after inspecting the logs for Xorg it seems like the 99-calibration.conf file should reside in /usr/share/X11/xorg.conf.d/ rather then /etc/X11/xorg.conf.d/. However, placing the file there doesn't seem to be doing any magic. But, in the log files I can see that X11 are Reading the InputClass calibration placed in 99-calibration.conf.

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Feb 10, 2017 8:49 pm

I have removed the ads7846 part of my /etc/modules as well, earlier today. As it doesn't seem to be needed.
I don't Think I have an issue with my touch panel, since it works perfect when using tslib (sudo TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/event2 ts_test).

I did try to apply preasure on the places you pointed out, but it didn't get any better.

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Feb 10, 2017 9:12 pm

By the way, I have turned back my OS to NOOBS 1.9.0 cause in versions from 2017 SSH\XRDP and WiFi work VERY unstable!
Could you please try older version of Jessie? Do not forget to sudo apt-get update the old OS or evtest wont install

dbliz
Posts: 1
Joined: Thu Mar 02, 2017 1:22 pm

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Thu Mar 02, 2017 1:31 pm

I believe I have run into the same issue. I am able to verify everything is running fine with latest jessie with ts_calibrate, but I find the axis are flipped in X no matter how I configure the 99-calibration.conf.

I am able to verify that the conf file is being loaded, but it is almost like the values are being ignored.

I have also found that most guides/demos show that the output of "DISPLAY=:0.0 xinput_calibrator" should show something like:

Code: Select all

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "2815 62207 62417 3800"
        Option  "SwapAxes"      "1"
EndSection
My execution of "DISPLAY=:0.0 xinput_calibrator" creates:

Code: Select all

Section "InputClass"
	Identifier	"calibration"
	MatchProduct	"ADS7846 Touchscreen"
	Option	"MinX"	"3635"
	Option	"MaxX"	"62206"
	Option	"MinY"	"62588"
	Option	"MaxY"	"4243"
	Option	"SwapXY"	"1" # unless it was already set to 1
EndSection
Note - I have removed the 99-calibration.conf prior to each run of the calibration to ensure it is not influencing the results.

I swear there has got to be something that is overriding the X configuration for the axis. Works fine with ts_calibrate, but X and Y swapped in X.

Any ideas?

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Mar 03, 2017 6:32 am

I got the same calibration data from xinput_calibrator as you. And even if I formated it to the "normal" format it didn't work.
As you, I belive that the calibration file is not used or something is overriding it.

mastermushi's suggestion to revert to an older version of Raspbian is not an option for me. I'm adding this LCD to an RPi board already up and running, and I'm not gonna reconfigure everything again. I gave up on getting the touch to work properly in X, and I'm now gonna use the official RPi 7" screen instead.

But if someone were to get the touch working on the 5" LCD I could find a use for it :)

fq1888
Posts: 10
Joined: Mon Mar 06, 2017 1:13 pm

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Mon Mar 06, 2017 1:22 pm

I have the same problem with you,and I have try all the ways,who can help!!!

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Tue Mar 07, 2017 10:11 am

I hope I get the time to try these commands when I get home. Specifically the autostart of xinput_calibrator part.
Has anyone else tried them?

https://github.com/notro/fbtft/wiki/FBT ... alibration

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Wed Mar 08, 2017 8:24 pm

The above link did not help in any way.

I was unable to run the calibration script actually. And trying to run the calibration manually it failed saying that xinput_calibrator didnät support xinput as --output-type.

fq1888
Posts: 10
Joined: Mon Mar 06, 2017 1:13 pm

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Wed Mar 15, 2017 8:49 am

Finally find a solution to the problem of reason, tested with Raspbian 2017-03-02 is Perfect,
The link is as follows:
https://github.com/goodtft/LCD-show

If you are using the newest Raspbian version: 2017-03-02
You need to additional excute this two command bellow after Step1, 2, 3 excuted.
If not so, the Resistive touch to reverse or always be calibrated.
This additional command bellow is just for Raspbian - 2017-03-02:

sudo apt-get install xserver-xorg-input-evdev
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo reboot

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Wed Mar 15, 2017 8:54 am

Thank you! I will give it a try!

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Wed Mar 15, 2017 7:05 pm

Thank you fq1888! Those instructions works flawlessly! The touch works as it should now!

japercaper
Posts: 2
Joined: Sat Apr 01, 2017 9:24 pm

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Sat Apr 01, 2017 9:28 pm

I have the Waveland 2046 LCD screen and latest and greatest Rasbian Jessie.

When I plug screen in, it works, but only covers about 80% of the screen. The right-most 20% is blank. No matter what changes I put in (that I read on this forum), the display will not fill in the right side.

If I change the framebuffer widths in /boot/config.txt, it does change the screen resolution and size, but still nothing on the right side.

Ideas?

Thanks,
TomT

jonaslorander
Posts: 21
Joined: Wed Oct 29, 2014 6:14 am
Location: Stockholm , Sweden
Contact: Website Twitter

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Sun Apr 02, 2017 4:35 am

Hi japercaper,

Are you sure about the make and model of your LCD , I can't find any information about it.

japercaper
Posts: 2
Joined: Sat Apr 01, 2017 9:24 pm

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Tue Apr 04, 2017 10:52 pm

it says 5inch HDMI Display
800x480 Pixel
XPT2046 Touch Controller
Rev3.0

wabbajack
Posts: 2
Joined: Fri Apr 28, 2017 1:09 pm

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Sun Apr 30, 2017 10:27 am

I have 5inch display (v2.02) and RPi3 (2017-04-10-raspbian-jessie-lite) anyway can't force to work the sensor.

francois_l1
Posts: 1
Joined: Fri Oct 06, 2017 7:14 pm

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri Oct 06, 2017 7:20 pm

Not sure if this is still relevant but this panel seems to have the Touch Input interrupt connected to GPIO 22 instead of GPIO25 as the V3.00 panels.

The following line in config.txt worked for me :
dtoverlay=ads7846,cs=1,penirq=22,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900

Regards

Francois
wabbajack wrote:
Sun Apr 30, 2017 10:27 am
I have 5inch display (v2.02) and RPi3 (2017-04-10-raspbian-jessie-lite) anyway can't force to work the sensor.

denicolai76
Posts: 1
Joined: Wed Oct 18, 2017 1:03 pm

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Thu Oct 26, 2017 8:59 pm

fq1888 wrote:
Wed Mar 15, 2017 8:49 am

The link is as follows:
https://github.com/goodtft/LCD-show

sudo apt-get install xserver-xorg-input-evdev
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo reboot
ith all of this on monitor LCD 3.5 of Kumar seller WORK FINE!!!

very thank you, very much!

User avatar
DMike92
Posts: 23
Joined: Mon Dec 29, 2014 12:52 am
Location: France
Contact: Website

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Mon Jan 01, 2018 3:21 pm

Hi,
The link is as follows:
https://github.com/goodtft/LCD-show
After having done :

Code: Select all

cd LCD-show
./LCD35-show
it results in: unable to reboot !
(Same story happened when trying to install waveshare drivers from another forum)

I will restart from NOOBS now !
Any other ideas ?
Any way to make a backup before (2 partitions disk)?
Le savoir ne vaut que quand il est partagé (c'est pas de moi mais j'adhère).

doveoscar
Posts: 8
Joined: Wed Mar 09, 2016 10:50 pm

Re: Issue with XPT2046/ADS7846 touchscreen on RPi3

Thu May 03, 2018 9:03 pm

fq1888 wrote:
Wed Mar 15, 2017 8:49 am
Finally find a solution to the problem of reason, tested with Raspbian 2017-03-02 is Perfect,
The link is as follows:
https://github.com/goodtft/LCD-show

If you are using the newest Raspbian version: 2017-03-02
You need to additional excute this two command bellow after Step1, 2, 3 excuted.
If not so, the Resistive touch to reverse or always be calibrated.
This additional command bellow is just for Raspbian - 2017-03-02:

sudo apt-get install xserver-xorg-input-evdev
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo reboot
Thank you thank you thank you.

I thought I was going mad. Changing the values in any conf file seemed to have no effect at all on my Pi 3/Stretch/Elecrow 5. The quoted post fixed it and when I go preferences-touchscreen calibration the values are saved with no intervention from me.

Did I say thank you?

efem360
Posts: 1
Joined: Fri May 25, 2018 6:57 am

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Fri May 25, 2018 7:11 am

My Touchpanel 18,5inch. I have Raspberry pi 3 v2.8.1. I use it with mouse smoothly. There is a 10 mm side gap in the touchpanel. Calibrate touchpanel could not solve my problem.


I have to solve this problem in 2 days. I can get out of work because I can not solve this problem. my mail: efem360@gmail.com
Please Help Me! :!: :cry: :cry:

TimPe
Posts: 1
Joined: Thu May 31, 2018 12:20 pm

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Thu May 31, 2018 12:55 pm

The solution provided by fq1888 works perfect for me.

I am running a Raspberry Pi 3 with Raspbian Stretch release "2018-04-18"
together with a Elecrow 5 inch TFT Display https://www.elecrow.com/wiki/index.php? ... FT_Display

Thank you very much.

el.gigante
Posts: 2
Joined: Wed Mar 06, 2019 9:19 am

Re: [solved] Issue with XPT2046/ADS7846 touchscreen on RPi3

Wed Mar 06, 2019 9:35 am

THANKS GUYS! After about 4 hours, i made my 3,5" touch run with your help!

- My situation: Raspberry 3B+ 2017
- OS: raspberian Stretch (updated from Jessie to Stretch using this guideline: https://www.datenreise.de/en/raspberry- ... o-stretch/
- Touch 3,5" bought from Quimat / Producer is "Kuman" / Chip is ADS7846

To make LCD + basic Touch work, i just followed the minimalistic instructions from https://mega.nz/#F!DRUwEDgI!Ug1aoighYUN0uLdEhTC-sA
(found on the traders homepage: http://www.kumantech.com/kuman-35quot-3 ... p0162.html)

Then came the Problem: Calibration did not work as expected. Following the steps 2) - 4) below various times, it finally worked:

1] git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./LCD35-show

2] DISPLAY=:0.0 xinput_calibrator

3] To view logs wirtten at boot-up: cat /var/log/Xorg.0.log
To edit config file(instead of mcedit also nano can be used): sudo mcedit /usr/share/X11/xorg.conf.d/45-evdev.conf
I had to insert these two lines(output from xinput_calibrator) to the .conf file:

Option "Calibration" "3909 241 255 3898"
Option „SwapAxes“ „1“

4] By viewing the Xorg.0.log above, i found that the conf file does not effect the settings, so i followed the top from one guy above to rename the evdev.conf file to 45-evdev.conf in order to place it after exectution of the ...libs...confs. Further in my case the files under /user/share/X11... are used instead of those at /etc/X11...

Still, somehow the "InvertX" and "InvertY" options seem to have no effect - fortunately the "SwapAxes" option was enough to fix this in my case. Mind that in my case the other proposed option "SwapXY" seemed to have no effect to...

Mybe this helps someone... If someone has details why "InvertX"... does not work, i would be eager to hear...

Return to “Interfacing (DSI, CSI, I2C, etc.)”