Friday, 5 May 2017

Raspberry Pi Touchscreen Portrait

I recently wanted to turn my Raspberry Pi Official Touchscreen portrait (i.e. sideways!), which turns out is a bit of pain.

Turning the display is relatively easy but making the touch work is more difficult - there was a set of instructions on the Raspberry Pi forum, but a recent update to Jessie meant they no longer worked, so I pulled this set of instructions together:

Install xinput:
sudo apt-get install xinput
Rotate the display by editing config.txt:
sudo nano /boot/config.txt
 .. add this to the buttom of the file:
display_rotate=1
Use Ctrl X, Yes to Save
Create a script to rotate the touchscreen:
nano /home/pi/touch_rotate.sh
 .. add the following command
xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix'  0 1 0 -1 0 1 0 0 1
Make the script executable:
chmod +x touch_rotate.sh
Make the script run when the GUI starts by editing autostart:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
 .. add this to the bottom to run your script
@/home/pi/touch_rotate.sh
Reboot:
sudo reboot

12 comments:

  1. Thank you !! I've spent way too many time on this until I found your post !

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. I can't get this working... I'm at the part for:

    sudo nano ~/.config/lxsession/LXDE-pi/autostart

    When I try to save it, I get the following error:

    Error writing /home/pi/.config/lxsession/LXDE-pi/autostart: No such file or directory

    ReplyDelete
    Replies
    1. Interesting... Was this on stretch? I wonder if the structure has changed.

      Delete
  5. Hell Yeah! Thank you! Works well. / Testet on Raspi3&Raspi 7" Touchmonitor. Only working solution in 2018 sofar.

    ReplyDelete
  6. I found somewhere how to set the matrix for 270degree rotation:
    xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

    ReplyDelete
  7. Anyone have a clue why this would work at first and then revert to the previous behavior?

    About to redo my whole install if I can't figure out why it seems to be loading a new instance wiping out these changes.

    ReplyDelete
  8. I cannot get this to work, but the reason may be that I dont have a FT5406 memory based driver, but a real HP USB Mouse.....
    so what do I do to get mouse rotation to work with an Olimex A20 and the same problem, and a normal USB mouse connected to it?

    ReplyDelete