Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

2.8" PiTFT Capacitive Touch Issue
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Wed Feb 05, 2020 5:19 pm

I'm using the 2.8" PiTFT Capacitive touch screen in a project. I have everything display related working perfectly. The TFT is my primary (and only) display attached the PI. I have it rotated properly for my application (four physical buttons on the right when viewing the display).

However, I'm having an issue with the touch portion of the display. The position touched seems to jump all over the place, and therefore the drivers aren't consistently picking up touch events (collisions) properly. Here's some of my code:

Code to set things up:
Code: Select all | TOGGLE FULL SIZE
button10 = pygame.Rect(0,0,30,30)


This is in my main loop:
Code: Select all | TOGGLE FULL SIZE
    #look for a screen press
    for event in pygame.event.get():       
        if(event.type is pygame.MOUSEBUTTONDOWN):
            touch_pos = event.pos
            print('screen was pressed at {0}'.format(touch_pos))
            if (button10.collidepoint(touch_pos)):
                print ('Backspace button pressed')


When I press the screen in the bottom left over and over, I may get (0, 17), (60, 46) or (127, 214). Sometimes I do get that it pressed the Backspace button, but not very often... It appears to vary widely, especially when you touch somewhere else and come back (touch a corner, then the middle, then back to the corner). Top left of the screen appears to be around (319, 0), top right is (319, 239), bottom left is (0, 0) and bottom right is (0, 239). Middle of the screen frequently shows around (300, 30) or (30, 239) which is really strange... Now that I think about it, I've never seen pressing the middle give around the (160, 120) like it should...

All I can figure is that I've got some sort of calibration issue, or a bad display. Anyone have any ideas?

Thanks,

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Thu Feb 13, 2020 11:31 am

Anyone have any ideas? I still don't have this working properly.

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Tue Feb 18, 2020 5:38 pm

Still not working, but I figured I'd update the status with the hopes someone can help me....

Using the 'adafruit-pitft.sh' configuration file, I played with the different rotations some more. The 180deg rotation appears to match the readings I'm getting best, but isn't a match. I changed the program to add a small circle to the location of every press event, and it doesn't match at all. I can't really find any rhyme or reason to what it's doing.

I found this thread that seems to be a similar issue: viewtopic.php?f=47&t=155729

I downloaded and installed the patched package, but it hasn't changed my touch performance. And now, if I run the adafruit-pitft.sh configurator, I get an error 'The repository 'http://archive.raspbian.org/raspbian wheezy Release' does not have a Release file. WARNING : Apt failed to update indexes!"...

So, now I'm not any better off, and possibly worse...

Anyone have any ideas for how to fix this - it appears to be a driver issue, but I'm running out of options.

Thanks,

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Tue Feb 18, 2020 5:59 pm

I just came across this thread:

viewtopic.php?f=47&t=145907&p=726728&hilit=pygame#p726728

So, my question becomes - is this still broken, a year later?

If so, what's my best option - downgrade to an older version of Raspbian (I'm currently on Buster)? If so, what's the recommendation (I need Pygame and the touch working, rest is just I/O stuff)?

It seems that there's a work-around of sorts using EVDEV, but that seems like a definite band-aid and not a solution. My project is not a one-off - I'm going to be building probably at least 20 units that will be used daily in a manufacturing environment, so it has to be bullet-proof...

I'll also echo one other question I saw mentioned in another thread: Does Adafruit actually monitor this forum and help their users? I first posted almost 2 weeks ago and have only heard crickets. In the meantime, I'm banging my head against a wall about something that is apparently known...

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Tue Mar 03, 2020 12:59 pm

Update: I still don't have touch working properly, and I still have heard NOTHING from adafruit on this forum or otherwise to help me...

I've tried using Stretch version 3-18-2018, but it appears to have the same issue as Buster.

Can someone, anyone please help me??.... I'm very close to throwing these displays in the trash and re-designing around something different, and I really hate to do that.

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by adafruit_support_carter on Wed Mar 04, 2020 7:38 pm

Hey, sorry for delay in responding here.

Just to make sure, is this the display you are using?
https://www.adafruit.com/product/2423
(there's an older one also)

What model Pi are you using?

Did you do your original install, for your first post, using the installer script?

adafruit_support_carter
 
Posts: 16938
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Thu Mar 05, 2020 9:45 am

Yes, that display. Pi 3B+. Yes, I used the installer script to install drivers and configure it.

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Fri Mar 06, 2020 11:44 am

Any update on your end?..

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by adafruit_support_carter on Fri Mar 06, 2020 4:46 pm

I've tried using Stretch version 3-18-2018, but it appears to have the same issue as Buster.

Do you mean the 2018-03-14 image mentioned here?
https://learn.adafruit.com/adafruit-2-8 ... d-card-3-4
I just went through the install with that OS version and it worked OK.

I also tried with the latest 2020-02-13 release which did *not* work. It responded, but the locations were off.

adafruit_support_carter
 
Posts: 16938
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Fri Mar 06, 2020 5:08 pm

Yes, but I'm running the lite version, not full. The LCD is my only display.

Maybe the lite and full have differences that would affect this, or did you use the lite version?

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by adafruit_support_carter on Fri Mar 06, 2020 5:46 pm

I was using the Full version and just basing it on the Desktop's response. I was using HDMI mirror. The mouse cursor tracked nicely with touch, etc.

Let me check with Lite and report back.

adafruit_support_carter
 
Posts: 16938
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.8" PiTFT Capacitive Touch Issue

by adafruit_support_carter on Fri Mar 06, 2020 8:06 pm

[EDIT] just to be clear, this was with 2018-03-13 Raspbian Lite

OK, I'm as far as having console output on the TFT and then I'm running evtest:
https://learn.adafruit.com/adafruit-2-8 ... sting-4-11

Can you try that and see if you are getting similar output as me. The general touch coordinates appear to be:
touch_coords.png
touch_coords.png (641.65 KiB) Viewed 98 times


I was just running same command from guide:
Code: Select all | TOGGLE FULL SIZE
sudo evtest /dev/input/touchscreen

and getting output like this:
Code: Select all | TOGGLE FULL SIZE
Event: time 1583539435.434688, -------------- SYN_REPORT ------------
Event: time 1583539435.482616, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 53
Event: time 1583539435.482616, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 232
Event: time 1583539435.482616, type 3 (EV_ABS), code 0 (ABS_X), value 53
Event: time 1583539435.482616, type 3 (EV_ABS), code 1 (ABS_Y), value 232

and the ABS_X and ABS_Y values were generally tracking well with touch location on the screen.

adafruit_support_carter
 
Posts: 16938
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Mon Mar 09, 2020 8:41 am

Yes, I'm using the 3-18-2018 version of Lite.

I used the EVTest and I'm getting the same results as you. Touch positions seem to be consistent, with the origin in the bottom left corner. I'd expect the origin in the upper left corner, but at least the positions are consistent and I can get readings across the entire display (touching the middle shows a value about (120,160) for instance).

I'm assuming that this means that my problem must be related to Pygame in some way. Here is the code I'm using to test position with:

Code: Select all | TOGGLE FULL SIZE
import pygame
from pygame.locals import *
import os
from time import sleep

pos = (0,0)

#Colors
WHITE = (255,255,255)
RED = (255,0,0)
 
os.putenv('SDL_FBDEV', '/dev/fb1')
os.putenv('SDL_MOUSEDRV', 'TSLIB')
os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')
 
pygame.init()
pygame.mouse.set_visible(False)
lcd = pygame.display.set_mode((320, 240))
lcd.fill(WHITE)
pygame.draw.circle(lcd, RED, pos, 10, 0)
pygame.display.update()
 
while True:
    # Scan touchscreen events
    for event in pygame.event.get():
        if(event.type is MOUSEBUTTONUP):
            pos = pygame.mouse.get_pos()
            print pos
   
   lcd.fill(WHITE)
   pygame.draw.circle(lcd, RED, pos, 10, 0)
   pygame.display.update()
   
    sleep(0.3)


Ideas for what could be wrong with Pygame?

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Mon Mar 09, 2020 8:53 am

Just playing, I tried the TSLib test program that's at the bottom of that guide again.

It doesn't work. On the console, it says that "selected device is not a touchscreen I understand"

On the display, the cross hair just flashes in the middle - it doesn't let you do anything with it.

I verified, and the numbers are correct in the pointercal file.

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Re: 2.8" PiTFT Capacitive Touch Issue

by DannyBGoode on Mon Mar 09, 2020 2:29 pm

I just noticed one other thing that I wanted to mention. When using the Stretch version, I'm seeing multiple touch events, where on the Buster version I only got single presses like I should...

Danny

DannyBGoode
 
Posts: 25
Joined: Wed Nov 06, 2019 11:58 am

Please be positive and constructive with your questions and comments.