0

pygame problem with adafruit-pitft on raspbian jessie
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: pygame problem with adafruit-pitft on raspbian jessie

by adafruit2 on Thu Jul 05, 2018 12:33 pm

yeah...
the linux kernel broke support for the capacitive touch chip :( it sux, we dont have a solution. we used to try patching kernels but raspbian came out with a new one every few months, we just couldnt keep up. can you use a resistive touch?

adafruit2
Site Admin
 
Posts: 16539
Joined: Fri Mar 11, 2005 7:36 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by przemo on Thu Jul 05, 2018 1:33 pm

I could use resistive, no problem, but I enjoy fixing the capacitive touch. OK, we have kernel driver that seems to work (evtest is OK) and I think I have it working with pygame :-)
It was overconfigured and now with only this:
Code: Select all | TOGGLE FULL SIZE
        os.environ["SDL_FBDEV"] = "/dev/fb1"
        os.putenv('SDL_VIDEODRIVER', 'fbcon')

instead of that:
Code: Select all | TOGGLE FULL SIZE
        os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')
         os.environ["SDL_FBDEV"] = "/dev/fb1"
         os.putenv('SDL_VIDEODRIVER', 'fbcon')
         os.putenv('SDL_MOUSEDRV', 'TSLIB')

works fine. I need to fix /etc/pointercal (more info later)
Last edited by przemo on Thu Jul 05, 2018 4:24 pm, edited 1 time in total.

przemo
 
Posts: 40
Joined: Tue Jul 22, 2014 4:28 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by adafruit2 on Thu Jul 05, 2018 1:49 pm

oh neat! ok we'll update the guide if you do!

adafruit2
Site Admin
 
Posts: 16539
Joined: Fri Mar 11, 2005 7:36 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by przemo on Fri Jul 06, 2018 7:43 pm

There is more in it than I thought. Looks like it works in a strange mode (absolute + relative??), the movement is smooth, so I thought it's OK.

przemo
 
Posts: 40
Joined: Tue Jul 22, 2014 4:28 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by przemo on Sat Jul 07, 2018 5:01 am

ts_calibrate compiled from source shows strange resolution:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi:~ $ sudo  TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
xres = 656, yres = 416
[..]

Edit: It's probably because there was no TSLIB_FBDEVICE=/dev/fb1 defined. With TS_LIB_FBDEVICE the resolution is 320x240 and calibration works fine.
ts_print_raw gives roughly 320x240 as expected:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi:~/tslib/tests $ sudo TSLIB_TSDEVICE=/dev/input/touchscreen ts_print_raw
1530953528.130071:    217    317    255
1530953528.191536:      0      0      0
1530953528.579774:    235    309    255
1530953528.677743:      0      0      0
1530953529.211827:    235    314    255
1530953529.297738:      0      0      0
1530953529.491317:    235    317    255

przemo
 
Posts: 40
Joined: Tue Jul 22, 2014 4:28 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by przemo on Sat Jul 07, 2018 6:26 pm

I found detailed explanation what is wrong here (no solution, unless you want to compile a few things): https://bugs.debian.org/cgi-bin/bugrepo ... bug=798160

przemo
 
Posts: 40
Joined: Tue Jul 22, 2014 4:28 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by adafruit2 on Sat Jul 07, 2018 11:15 pm

yep - its been a few years but this sounds familiar. we dont mind compiling our own package but it would have to be a real fix!

adafruit2
Site Admin
 
Posts: 16539
Joined: Fri Mar 11, 2005 7:36 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by przemo on Sun Jul 08, 2018 6:13 am

I'm still gathering info, but looks like:
1. pygame uses ancient libsdl1.2 & tslib
2. tslib functionality has been replaced by evdev
3. libsdl2 is the new version of SDL, but it might not support PiTFT framebutter (TO BE CONFIRMED)
4. There is no official pygame based on SDL2, but there is pygame_SDL2 fork that looks promising [1]

I'm currently compiling SDL2 and pygame_SDL2.

[1] https://github.com/renpy/pygame_sdl2

przemo
 
Posts: 40
Joined: Tue Jul 22, 2014 4:28 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by przemo on Sun Jul 08, 2018 4:14 pm

Another piece of information: python-evdev [1] seem to be much better way of handling touchscreen from python. And it Just Works (tm).
If someone really needs pygame maybe getting touch events using python-evdev and posting them into pygame event queue with pygame.event.post would work?

[1] https://python-evdev.readthedocs.io/en/ ... index.html

przemo
 
Posts: 40
Joined: Tue Jul 22, 2014 4:28 pm

Re: pygame problem with adafruit-pitft on raspbian jessie

by adafruit2 on Sun Jul 08, 2018 11:25 pm

probably! its just nice when pygame works because it does it the way one expects (mouse/touch events)

adafruit2
Site Admin
 
Posts: 16539
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.