UnchartedBull / OctoDash

OctoDash is a simple, but beautiful dashboard for OctoPrint.
https://unchartedbull.github.io/OctoDash/index.html
Apache License 2.0
1.02k stars 224 forks source link

Adafruit 3.5TFT always has the touch rotated a -90 degrees from the screen #1029

Closed rv10guy closed 3 years ago

rv10guy commented 3 years ago

I am attempting to setup OctoDash on a Raspberry Pi4 with the Adafruit 3.5 TFT. I am installing the drivers following the guide here https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/overview. No matter what I do, the touchscreen ends up -90 degrees off from the touchscreen. So for example, if I want to press the upper right corner, I have to press the upper left corner and if I want to press the upper left corner I have to press the lower-left corner. It does not matter how I rotate the screen, the touch, and the display are always off by -90 degrees. I also tried the steps here https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/faq#faq-2859093 and it did not help.

carl1961 commented 3 years ago

maybe this link will help https://whitedome.com.au/re4son/topic/my-adafruit-3-5-setup-for-those-having-inverted-axis-out-of-the-box/

UnchartedBull commented 3 years ago

Probably not a problem with OctoDash, but rather with your setup. Please reopen this issue if @carl1961 link doesn't work.

sabarrett328 commented 3 years ago

@rv10guy did the link help with this issue? I have the same thing going on. When I get home I was going to try it.

rv10guy commented 3 years ago

No, I was never able to get it to work. I abandoned the screen.

From: sabarrett328 notifications@github.com Date: Wednesday, December 30, 2020 at 6:24 AM To: UnchartedBull/OctoDash OctoDash@noreply.github.com Cc: rv10guy scott@wrightfamily.org, Mention mention@noreply.github.com Subject: Re: [UnchartedBull/OctoDash] Adafruit 3.5TFT always has the touch rotated a -90 degrees from the screen (#1029)

@rv10guyhttps://github.com/rv10guy did the link help with this issue? I have the same thing going on. When I get home I was going to try it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/UnchartedBull/OctoDash/issues/1029#issuecomment-752514729, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADYSEXNIRBSA4IXLV3J36UDSXMLZBANCNFSM4R5DO3JA.

KTheMan commented 3 years ago

Copy-pasting my response from discord, since it's more searchable here:

So, I'm definitely sure the touch is working correctly out of the box and it is Adafruit's installer script missing something. You can run ts_calibration then ts_test and everything is perfect upon testing but X11 (which is what I'm assuming OctoDash is using to display through) doesn't pick up on it because the installer script looks for lightdm to rotate touch on X11. Install lightdm through apt, run the installer script again, and then remove lightdm. Reboot. Voila!

I did also have lxde (without its dependencies) installed/uninstalled at the time as lightdm but I do not believe that contributed to this solution.

Tl;dr: I seem to have solved it! Install lightdm through apt, run the installer script again, and then remove lightdm. Reboot. Voila!

sabarrett328 commented 3 years ago

hhmmm... Thanks for the info. I"ll have to try that. However.... I'm not a Linux guru by any means. I've stumbled around searching for info on lightdm, and I found the github page, however I don't see anything referring to install by apt. Could you please point me somewhere I can learn more about doing this?

thanks

machavezg9 commented 3 years ago

If I may give my 0.2, after hours of trying it came down to doing everything in the following two links. Follow the instructions here

Note: all code below is just a copy from the original source. Double check for mistakes or run from original source.

Install your 3.5" tft cd ~ sudo pip3 install --upgrade adafruit-python-shell click==7.0 sudo apt-get install -y git git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git cd Raspberry-Pi-Installer-Scripts

I ran through the interactive installation: 'sudo python3 adafruit-pitft.py'

After Reboot make sure your Octodash is displayed and running in the (all touch for me was portrait but landscape gui orientation)

Now run the manual calibration here

Want may have done all the magic.

Run X Calibration here

Install xcal per X Calibration linked above: sudo apt-get install libxaw7-dev libxxf86vm-dev libxaw7-dev libxft-dev git clone https://github.com/KurtJacobson/xtcal cd xtcal make

Reset your display: DISPLAY=:0.0 xinput set-prop "stmpe-ts" 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1

Set your display geometry (NOTE!! YES 480x320 for PITFT, followed the "720x480" and it did not work): DISPLAY=:0.0 xtcal/xtcal -geometry 480x320

Follow the on screen directions Copy your new "Transformation Matrix Coordinates"

Navigate to cd /usr/share/X11/xorg.conf.d/ List everything in drive ls If nothing with the name "20-calibration.conf" is listed, create this file sudo nano 20-calibration.conf Copy and Paste the code below (sourced from the xcal Adafruit link), make sure to replace the "TransformationMatrix" values with the ones previously recorded:

Section "InputClass"
        Identifier "STMPE Touchscreen Calibration"
        MatchProduct "stmpe"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "TransformationMatrix" "-0.000087 1.094214 -0.028826 -1.091711 -0.004364 1.057821 0 0 1"
EndSection

Reboot your Pi Hopefully it worked!

h3llb3nt commented 3 years ago

@KTheMan little workaround at the end of their post worked for me. which was to install lightdm, rerun the "installation script" and then remove lightdm.

I wasn't sure what "installation script" referred to and guessed it meant the Adafruit install script for the PiTFT. my octopi image only hadn't had octodash installed at all yet so I did the following:

I installed lightdm and after a reboot, sure enough, the touch input was off 90 degrees. next, via ssh I reinstalled the PiTFT using adafruits' script and rebooted. when lightdm came up touch input was correct! I installed octodash using the auto installer script and waited, and when the gui came up the touch input was working properly! next (instead of backing up my sdcard like I should have) I uninstalled lightdm via 'apt remove lightdm' and held my breath... and input is still working correctly!

that was a difficult 3 days.

BorkStick commented 3 years ago

Tried the @KTheMan fix and it did the trick.

I was goin off the troubleshooting page on the wiki and was also confused by the "installation script" referred to. Unlike @h3llb3nt I was thinking it was referring to the octodash script, and spent way longer than I would have like to figure out it was referring to the adafruit install script

Can we tweak the wiki section for this issue so it reads adafruit installer script, instead of installer script

https://github.com/UnchartedBull/OctoDash/wiki/Troubleshooting#touchscreen-is-rotated-adafruit-displays

Fix
Install lightdm through apt, run the adafruit installer script again, and then remove lightdm. Reboot. Thanks to @KTheMan