piTFT touchscreen rotation in console

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/
Locked
tinuk
 
Posts: 2
Joined: Sat Apr 12, 2014 4:39 pm

piTFT touchscreen rotation in console

Post by tinuk »

Hi

I have the PiTFT running perfectly to display in console and in LXDE. Touchscreen works fine in LXDE.

When using the touchscreen input in console only it is rotated wrong (touching the top corner in landscape with buttons at bottom which should be 0,0 is not correct). I don't see any instruction on rotating the touchscreen input device for console mode alone. The display is correct rotation but touch input is not.

Any help on rotating the input device in console? I am trying to make a python program using curses which I am held up on this problem. it works with a mouse but i need the touch screen to work for my final program, as i will not have a mouse connected.

Thanks in advance.

Tin.

User avatar
notro
 
Posts: 93
Joined: Tue Sep 11, 2012 9:59 am

Re: piTFT touchscreen rotation in console

Post by notro »

If your program uses tslib, you can calibrate it like this (from the Adafruit tutorial):

Code: Select all

 sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate

tinuk
 
Posts: 2
Joined: Sat Apr 12, 2014 4:39 pm

Re: piTFT touchscreen rotation in console

Post by tinuk »

Thanks for the reply.

I have run the calibration as per the install instructions but it remains 90 degrees out of alignment with the display.
The next step in the install instructions which tests the touchscreen also works fine drawing shapes so I believe it is something to do with somehow loading the calibration data etc at startup got my curses python program.

Tin.

User avatar
notro
 
Posts: 93
Joined: Tue Sep 11, 2012 9:59 am

Re: piTFT touchscreen rotation in console

Post by notro »

After some searching I have come to this understanding:
Python curses uses ncurses. ncurses uses gpm to get mouse/touch events.
gpm reads /dev/input/eventX and doesn't have tslib support (tslib is a library that sits on top of /dev/input/eventX).

If this is correct, you have to swap x/y and maybe do calibration inside your program to get it right.

I couldn't find a python tslib library, but pygame (graphical) supports tslib: https://github.com/notro/fbtft/wiki/Pygame

Locked
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/

Return to “Adafruit Raspberry Pi® accessories”