0

Coordination issue with Rpi 3+ and 3.5" screen
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Coordination issue with Rpi 3+ and 3.5" screen

by arminghasemazar on Thu Jun 10, 2021 8:59 am

I have a Rpi 3+ installed with fresh raspbian stretch version. I followed Adafruit guideline to install touch screen, in summary as follows:
Code: Select all | TOGGLE FULL SIZE
sudo apt-get remove 'libsdl.*'
sudo apt autoremove -y
sudo apt-get -y update
sudo apt-get -y --allow-downgrades install libsdl1.2debian
sudo apt-get install -y git python3-pip evtest tslib libts-bin fbi
sudo pip3 install --upgrade adafruit-python-shell click
git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git
cd Raspberry-Pi-Installer-Scripts
sudo python3 adafruit-pitft.py --display=35r --rotation=90 --install-type=console --reboot=yes

First I uninstall all packages starting with libsdl and then I install required packages. After reboot, screen works as expected and shows the console. Then, I install Pygame to execute my code, as follows:
Code: Select all | TOGGLE FULL SIZE
sudo apt-get -y update
sudo apt-get install -y python-pip
sudo apt-get install -y python-pygame


And attached is my simple python code (got from https://github.com/garthvh/pitftmenu). So the problem is that when I touch button, nothing happens (no print to console). When I touch one of buttons and print pygame.mouse.get_pos(), I could see that coordinations are not correct. I thought maybe screen was not calibrated (even though it should automatically be after running the automatic installation script), I followed manual on Adafruit to manually calibrate, but again no success. I also tried installing with different --rotation options but same problem happened.

So somewhere there is misinterpretation of coordinates or an orientation issue. Anybody can figure out where the problem could be?

Example: When I click inside Menu Item 1 rectangle (coded like make_button("Menu Item 1", 30, 30, 55, 210, blue)), the touch coordinate should lie between: 30 <= x_pos <= 240 and 30 <= x_pos <= 85. However, here is what I get when I touch that button for couple of times:
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(0, 27)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(76, 292)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 288)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(73, 0)
(73, 0)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(10, 319)
(0, 221)
(0, 221)
(0, 221)
(0, 221)
(0, 221)
(0, 221)
(0, 221)
(0, 221)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 2)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(0, 162)
(75, 0)
(75, 0)
(75, 0)
(75, 0)
(75, 0)
(75, 0)
Attachments
test.py
(2.07 KiB) Downloaded 1 time

arminghasemazar
 
Posts: 2
Joined: Thu Jun 10, 2021 8:21 am

Re: Coordination issue with Rpi 3+ and 3.5" screen

by arminghasemazar on Fri Jun 18, 2021 4:00 am

Anybody has any clue how I can solve this problem?

arminghasemazar
 
Posts: 2
Joined: Thu Jun 10, 2021 8:21 am

Please be positive and constructive with your questions and comments.