pygame problem with adafruit-pitft on raspbian jessie
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- liyue
- Posts: 2
- Joined: Tue Jun 30, 2015 2:02 pm
pygame problem with adafruit-pitft on raspbian jessie
system distribution :
- raspbian jessie;
python version:
- 2.7.9;
Adafruit PiTFT
- 2.8" Touchscreen
python code:
- while True:
# Scan touchscreen events
for event in pygame.event.get():
if(event.type is MOUSEBUTTONDOWN):
pos = pygame.mouse.get_pos()
print pos
elif(event.type is MOUSEBUTTONUP):
problem :
'pos' value not actual position and the same code works fine on raspibian wheezy
Any help, thanks!
code reference:
- http://jeremyblythe.blogspot.com/2014/0 ... asics.html
- raspbian jessie;
python version:
- 2.7.9;
Adafruit PiTFT
- 2.8" Touchscreen
python code:
- while True:
# Scan touchscreen events
for event in pygame.event.get():
if(event.type is MOUSEBUTTONDOWN):
pos = pygame.mouse.get_pos()
print pos
elif(event.type is MOUSEBUTTONUP):
problem :
'pos' value not actual position and the same code works fine on raspibian wheezy
Any help, thanks!
code reference:
- http://jeremyblythe.blogspot.com/2014/0 ... asics.html
- adafruit2
- Posts: 22803
- Joined: Fri Mar 11, 2005 7:36 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
Does the PiTFT and touchscreen work otherwise?
- liyue
- Posts: 2
- Joined: Tue Jun 30, 2015 2:02 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
all works on rpi 2 + raspbian wheeze distribution;but not work on rpi 2+ raspbian “jessie” distribution
- adafruit2
- Posts: 22803
- Joined: Fri Mar 11, 2005 7:36 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
jeez ok it must be some change in pygame versions. dont know right now how to fix - but thx for letting us know - and if you find a solution please let us know too! :)
- ferretface
- Posts: 2
- Joined: Thu Jul 23, 2015 2:35 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
Hi Guys,
Similarly, I'm having pygame issues...this time.
I've built 2-3 of these a while ago & all was peachy. worked like a charm, kudos to the writer.
However. I'm rebuilding (my wife's jukebox) from scratch and it's all gone pear shaped (heh - fruit pun!)
Python 2.7.3 from the raspbian repository, python-pygame also.
Run the "sudo python ./radioplayer.py" command & get horrid nasty error messages which mean nothing to me as a non-programmer (no, not for a looong time, and then it was C....).
Traceback (most recent call last):
File "radioplayer.py", line 1, in <module>
import sys, pygame
File "/usr/lib/python2.7/dist-packages/pygame/__init__.py", line 99, in <module>
from pygame.base import *
ImportError: libbcm_host.so: cannot open shared object file: No such file or directory
I've tried searching on those errors, but end up wondering whether pygame & python are not in-step, but how do I find out what version of pygame I've got ?
OK - update -
Found a pygame page saying it's compatible with almost all version ps python except 2.7 (current standard apt-get), however, that's all tosh because a working one is using python 2.7. So that's a dead-end after about 4 hours of testing!
Giving up & copying the filesystem from the working one. Not the right answer though, as this instructable is now broken based on current distribution.
Unless of course - you know differently...please share if you know the secret!
I'd be very grateful if anyone might be able to point me in the right direction, thanks.
Similarly, I'm having pygame issues...this time.
I've built 2-3 of these a while ago & all was peachy. worked like a charm, kudos to the writer.
However. I'm rebuilding (my wife's jukebox) from scratch and it's all gone pear shaped (heh - fruit pun!)
Python 2.7.3 from the raspbian repository, python-pygame also.
Run the "sudo python ./radioplayer.py" command & get horrid nasty error messages which mean nothing to me as a non-programmer (no, not for a looong time, and then it was C....).
Traceback (most recent call last):
File "radioplayer.py", line 1, in <module>
import sys, pygame
File "/usr/lib/python2.7/dist-packages/pygame/__init__.py", line 99, in <module>
from pygame.base import *
ImportError: libbcm_host.so: cannot open shared object file: No such file or directory
I've tried searching on those errors, but end up wondering whether pygame & python are not in-step, but how do I find out what version of pygame I've got ?
OK - update -
Found a pygame page saying it's compatible with almost all version ps python except 2.7 (current standard apt-get), however, that's all tosh because a working one is using python 2.7. So that's a dead-end after about 4 hours of testing!
Giving up & copying the filesystem from the working one. Not the right answer though, as this instructable is now broken based on current distribution.
Unless of course - you know differently...please share if you know the secret!
I'd be very grateful if anyone might be able to point me in the right direction, thanks.
- ferretface
- Posts: 2
- Joined: Thu Jul 23, 2015 2:35 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
-Update2-
Reverted back to previous image, still same one as before, but before update & upgrade
Long story short - it's fixed but I don't know why! Worst possible answer!
I suspect that the update/upgrade process added something which disagrees with it, so my best advice is choose a suitably early raspbian (not the latest) which was released about the time of this radio project & don't upgrade it.
Sorted.
Reverted back to previous image, still same one as before, but before update & upgrade
Long story short - it's fixed but I don't know why! Worst possible answer!
I suspect that the update/upgrade process added something which disagrees with it, so my best advice is choose a suitably early raspbian (not the latest) which was released about the time of this radio project & don't upgrade it.
Sorted.
- heine
- Posts: 4
- Joined: Sat Sep 05, 2015 6:22 am
Re: pygame problem with adafruit-pitft on raspbian jessie
I can confirm this issue. With the Raspbian Wheezy Image (2015-05-05) everything works fine.
With a raspbian jessie Image (I built myself) it is giving a whole lot of events which show x and y values which are at least strange.
If I use "TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_print" I see the expected values. Pretty much identical to the output under wheezy.
So I suspected something in the pygame implementation shipping with jessie is broken.
But:
Under wheezy I was also able to try with python3 as it also ships a python3-pygame package. This was also working fine.
On jessie I had to build it myself (using http://askubuntu.com/questions/401342/h ... -python3-3). In the end this gives me the same problems as with using python 2.7 on jessie.
So maybe some interface pygame is using has changed in some way? I'll keep investigating.
With a raspbian jessie Image (I built myself) it is giving a whole lot of events which show x and y values which are at least strange.
If I use "TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_print" I see the expected values. Pretty much identical to the output under wheezy.
So I suspected something in the pygame implementation shipping with jessie is broken.
But:
Under wheezy I was also able to try with python3 as it also ships a python3-pygame package. This was also working fine.
On jessie I had to build it myself (using http://askubuntu.com/questions/401342/h ... -python3-3). In the end this gives me the same problems as with using python 2.7 on jessie.
So maybe some interface pygame is using has changed in some way? I'll keep investigating.
- heine
- Posts: 4
- Joined: Sat Sep 05, 2015 6:22 am
Re: pygame problem with adafruit-pitft on raspbian jessie
Okay, spend a lot of time today replacing the different libs involved. And I found the guilty one.
pygame isn't really doing much. It's essentially just querying SDL_GetMouseState() (see https://bitbucket.org/pygame/pygame/src ... mouse.c-46)
It's SDL. I don't know exactly what changed from wheezy to jessie. But I built SDL-1.2.15 from scratch and now my touch events are coming in as expected.
Wheezy version is 1.2.15-5, Jessie version is 1.2.15-10 so I'm too tired now to check for the differences between these two builds. As I'm building the jessie image myself I might be sticking to compiling SDL myself.
In case I have time/reason to investigate more I'll report back.
pygame isn't really doing much. It's essentially just querying SDL_GetMouseState() (see https://bitbucket.org/pygame/pygame/src ... mouse.c-46)
It's SDL. I don't know exactly what changed from wheezy to jessie. But I built SDL-1.2.15 from scratch and now my touch events are coming in as expected.
Wheezy version is 1.2.15-5, Jessie version is 1.2.15-10 so I'm too tired now to check for the differences between these two builds. As I'm building the jessie image myself I might be sticking to compiling SDL myself.
In case I have time/reason to investigate more I'll report back.
- heine
- Posts: 4
- Joined: Sat Sep 05, 2015 6:22 am
Re: pygame problem with adafruit-pitft on raspbian jessie
Submitted bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798160
For now the easiest way seems be to use the package from wheezy. Seems to work fine in jessie.
For now the easiest way seems be to use the package from wheezy. Seems to work fine in jessie.
- kck
- Posts: 29
- Joined: Fri Dec 25, 2015 1:40 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
Ran into this same problem and finally found this thread. Does anyone know if any progress/change has happened with the issue. I saw at the bug report referenced that the Jessie folks simply say no support for TSLIB but this now seems to make pygame useless on Jessie without some alternative solution. Is there one? Ref the comment at the end to use the package from Wheezy - what is the easiest way to do that? Thanks,
- heine
- Posts: 4
- Joined: Sat Sep 05, 2015 6:22 am
Re: pygame problem with adafruit-pitft on raspbian jessie
Hi,
since my last post raspbian jessie has officially been released. I didn't have the time to check if anything changed with this situation. But as libsdl1.2 is horribly outdated I don't see that this will come back into the official release. But I would also be interested if somebody provided a different way to have pygame touchscreen support in jessie working.
So here is how I solved this:
(the code is copied from an install script, you could of course also do these steps manually)
I hope this helps.
since my last post raspbian jessie has officially been released. I didn't have the time to check if anything changed with this situation. But as libsdl1.2 is horribly outdated I don't see that this will come back into the official release. But I would also be interested if somebody provided a different way to have pygame touchscreen support in jessie working.
So here is how I solved this:
Code: Select all
#enable wheezy package sources
echo "deb http://archive.raspbian.org/raspbian wheezy main
" > /etc/apt/sources.list.d/wheezy.list
#set stable as default package source (currently jessie)
echo "APT::Default-release \"stable\";
" > /etc/apt/apt.conf.d/10defaultRelease
#set the priority for libsdl from wheezy higher then the jessie package
echo "Package: libsdl1.2debian
Pin: release n=jessie
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
#install
apt-get update
apt-get -y --force-yes install libsdl1.2debian/wheezy
I hope this helps.
- kck
- Posts: 29
- Joined: Fri Dec 25, 2015 1:40 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
Thank you so much for the merry Christmas present!! Fixed me up. Have a great holiday season - good wishes are the best thanks I can offer.
- Turnierhamster
- Posts: 1
- Joined: Sat Jan 09, 2016 7:23 am
Re: pygame problem with adafruit-pitft on raspbian jessie
Hi heine,
thanks for your post - after hours of searching and debugging almost all the pygame examples for my LCD Panel (ads7846/ili9341fb based) which gave me wrong readings, your solution helped me. Perhaps you should mention it to adafruit, as their tutorials at learn.adafruit.com regarding touchscreen panels might not work for other users, too.
All the best
T.
thanks for your post - after hours of searching and debugging almost all the pygame examples for my LCD Panel (ads7846/ili9341fb based) which gave me wrong readings, your solution helped me. Perhaps you should mention it to adafruit, as their tutorials at learn.adafruit.com regarding touchscreen panels might not work for other users, too.
All the best
T.
- adafruit2
- Posts: 22803
- Joined: Fri Mar 11, 2005 7:36 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
yep this is awesome. thank you for letting us know. ive added a page to each pitft tutorial
https://learn.adafruit.com/adafruit-2-4 ... ygame-tips
https://learn.adafruit.com/adafruit-2-4 ... ygame-tips
- jumpzero
- Posts: 43
- Joined: Thu Feb 21, 2013 8:32 pm
Re: pygame problem with adafruit-pitft on raspbian jessie
Thanks Heine and Adafruit,
I had the same problem when moving my piradiohttps://learn.adafruit.com/raspberry-pi ... n/overview from wheezy to jessie. Touchscreen had erractic behavior under pygame only (Ok with X).
Found this script, fixed!
But may I suggest to correct the Adafruit "PiTFT Pygame Tips" page.
Because this page was the first place were I went and read
"SDL 2.x has some serious incompatibilities with touchscreen. You can force SDL 1.2 by running a script"
I checked on my new Adafruit PiTFT jessie install:
I though, well I'm ok I'm not with sdl 2 but sdl 1.2, so my problem is something else. I went on the forum and found this solution that worked.
But the fix is to replace sdl 1.2.15-10 with 1.2.15-5 (Not sdl 2 with 1.2)
Anyway it worked fine, thanks again
--
Jmp0
I had the same problem when moving my piradiohttps://learn.adafruit.com/raspberry-pi ... n/overview from wheezy to jessie. Touchscreen had erractic behavior under pygame only (Ok with X).
Found this script, fixed!
But may I suggest to correct the Adafruit "PiTFT Pygame Tips" page.
Because this page was the first place were I went and read
"SDL 2.x has some serious incompatibilities with touchscreen. You can force SDL 1.2 by running a script"
I checked on my new Adafruit PiTFT jessie install:
Code: Select all
dpkg -l | grep libsdl
ii libsdl-image1.2:armhf 1.2.12-5+b1 armhf Image loading library for Simple DirectMedia Layer 1.2, libraries
ii libsdl-mixer1.2:armhf 1.2.12-11+b1 armhf Mixer library for Simple DirectMedia Layer 1.2, libraries
ii libsdl-ttf2.0-0:armhf 2.0.11-3 armhf TrueType Font library for Simple DirectMedia Layer 1.2, libraries
ii libsdl1.2debian:armhf 1.2.15-10+rpi1 armhf Simple DirectMedia Layer
But the fix is to replace sdl 1.2.15-10 with 1.2.15-5 (Not sdl 2 with 1.2)
Anyway it worked fine, thanks again
--
Jmp0
Please be positive and constructive with your questions and comments.