BillyBlaze / OctoPrint-TouchUI

A touch friendly interface for a small TFT module or phone
https://billyblaze.github.io/OctoPrint-TouchUI/
GNU Affero General Public License v3.0
274 stars 92 forks source link

xserver setup by https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart prevents using screen rotation. #502

Closed scyto closed 3 years ago

scyto commented 3 years ago

When I use Octoprint OS image and touch ui using the https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart scripts to install X it results in an X implementation where it is impossible to rotate the screen either with xrandr as per https://www.raspberrypi.org/documentation/configuration/display_rotation.md or with the gui tool arandr as expected.

When using desktop version of raspbian this all works perfectly. It seems that the script https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart/blob/master/helpers/install-steps/4-xorg-setup is likely not doing enough config or https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart/blob/master/helpers/install-steps/3-apt-get-install isn't installing enough.

Unfortunately I don't know enough about X (until today all my 5+ years of pi experience has been SSH only) to suggest a fix. But happy to help where I can.

--edit-- The X installed by the script results in a display called default which supports no orientation modes other than normal. On the X installed by raspbian it results in a display called HDMI-1 which supports multiple states. Starting with a full raspbian desktop os and installing ocoto print that works with touch and then running the touchui-autostart scripts doesn't fix this issue.

--edit 2-- ok i can fix the invalid screen / display name by renaming /usr/share/X11/xorg.conf.d/99-fbdev.conf to /usr/share/X11/xorg.conf.d/99-fbdev.conf.old and rebooting.

after reboot i run the following

$ export DISPLAY=:0
$ sudo xrandr --output HDMI-1 --rotate left

this rotates the screen correctly; however it doesn't seem to set it to persist over reboots, nor did running sudo arandr and I know that saves the setting to /usr/share/dispsetup.sh - maybe the issue is that script is not called during X startup correctly?

for reference this is what gets put in the dispsetup.sh

i@octopi:/usr/share $ cat dispsetup.sh 
#!/bin/sh
if ! grep -q 'Raspberry Pi' /proc/device-tree/model || (grep -q okay /proc/device-tree/soc/v3d@7ec00000/status 2> /dev/null || grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null || grep -q okay /proc/device-tree/v3dbus/v3d@7ec04000/status 2> /dev/null) ; then
if xrandr --output HDMI-1 --primary --mode FIXED_MODE --rate 59.85 --pos 0x0 --rotate left --dryrun ; then 
xrandr --output HDMI-1 --primary --mode FIXED_MODE --rate 59.85 --pos 0x0 --rotate left
fi
fi
if [ -e /usr/share/tssetup.sh ] ; then
. /usr/share/tssetup.sh
fi
scyto commented 3 years ago

Ok to summarize how to get touch screen rotation working for HDMI displays.

  1. the /f99-fbdev.conf file has to not exist
  2. screen has to be rotated using one of these two approaches:
    • use sudo arandr (can be installed using apt) this has advantage of being a UI and writing settings to /usr/share/dispsetup.sh
    • use xrandr as per raspi orgs docs
  3. during startup either /usr/share/dispsetup.sh has to be called (after X has started) and before app starts OR use xrandr to rotate manually

Once all of these steps have been done, the touch matrix can be re-orientated to match by adding one of these 3 options too /usr/share/X11/xorg.conf.d/40-libinput.conf

90° = Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1" 180° = Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1" 270° = Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"

for example, on my system in this section in that file

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection

i am not sure what i want to suggest via a PR, especially as i dont know why the fbdev file exisits - i assume thats for something.... maybe the startup scripts need to ask what type of screen one has and what type of rotation you want to have set and what type of touch input, but thats too large a PR for me to attempt (i am not a coder) maybe someone else can build off this?

scyto commented 3 years ago

:-) (now i need to figure out if i can change font size! or chromium zoom leve) image0

BillyBlaze commented 3 years ago

Hi, I have stopped giving instructions about rotating displays since they change alot and can be different with other touchscreens. So the best way is to check the manufacturing instructions.

You can also add a file calibration.sh inside the TouchUI-autostart folder. This file will be executed before launching the browser. (see code here)

As for changing the font-size just navigate to Settings > TouchUI > Enable customization and select your prefered size in the dropdown. If you want to tweak it more then you need to add a local LESS file and change the variable to your liking from there. More on the latter part is over here: https://github.com/BillyBlaze/OctoPrint-TouchUI/wiki/Customize:-Use-your-own-file

scyto commented 3 years ago

@BillyBlaze i understand your position. For reference the method described above is generic for all HDMI based monitors that use HDMI cable and that use USB to connect the screen as a touchpad - there is no calibration for example. This is only about rotation. Either way i solved it and this issue is here for posterity for others.

Thanks for the tip on the script in the TouchUI-autostart, that's perfect.

I saw the LESS instructions before, read them and left clueless about where a LESS file goes, what its format is etc. It assumes i know what a LESS file is (googling generic LESS instructions helped but i still didn't understand where i was supposed to make those edits. Not sure if you can be a little more explicit in the linked instructions for noob idiots like me. :-)

Nice project, thanks for replying, appreciate it.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.