Adding Touchscreen to Octoprint/Raspberry Pi

Hey everyone, as you can guess, I'm having a problem with my raspberry pi, and I was hoping someone could help me.

Let me start off by saying that I've no coding experience myself, I'm simply trying to follow guides as much as I can, and when I run into problems like now, I can only ask for help.

What I'm trying to do is I'm trying to add a touchscreen to my raspberry pi, that's installed with Octoprint, so I can control octorpint through the touchscreen. The guide I'm following is this one.
In that guide, the writer is using an Adafruit touchscreen, but I'm using a different type of touchscreen. Because of that I'm not able to fully follow the guide 1:1

The touchscreen that I'm using uses this website for driver installations. So far I've been able to successfully install the driver, and rotate the screen, but that's where the problem comes up. I need to calibrate the screen, but I can't figure out how I can run the calibration script. The website mentions "Click the Men button on the task bar, choose Preference -> Calibrate Touchscreen." but I'm guessing that they're using a raspbian instance for this. I'm using an Octoprint instance, so I can't actually open a menu and run the program. So I need to figure out a way to start the calibration program through commands, but I've no idea on how to do this.

The guide I'm following is able to do this by issuing

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

But because I'm using another driver installation, this doesn't work.

Does anyone know how I can calibrate the touchscreen using the instructions from the driver installations?

I am assuming that you end goal is to get TouchUI working on your screen for Octoprint.

If so, install TouchUI using these instructions:https://github.com/BillyBlaze/OctoPrint-TouchUI/wiki/Setup:-Boot-to-Browser

Once TouchUI is working you can do the calibration by following the calibration instructions in the Troubleshooting section of the TouchUI github wiki:https://github.com/BillyBlaze/OctoPrint-TouchUI/wiki/Setup:-Troubleshooting#calibration-touch-location

Thank you very much for your reply. With that I was able to start and complete the touchscreen calibration process.

The next step is the calibration rotate touchscreen process, which I'm able to start, but ofcourse I'm still running into a problem.

there's 3 lines of code that I can use

su $TOUCHUI_USER -c "xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1" # Rotate clockwise 90 degrees
su $TOUCHUI_USER -c "xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1" # Rotate counterclockwise 90 degrees
su $TOUCHUI_USER -c "xinput set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1" # Rotate 180 degrees

If I use the "Rotate clockwise 90 degrees" line of code, the screen properly moves left and right, but up and down are inversed. If I use the "Rotate counterclockwise 90 degrees" the up and down move correctly, but the left and right are inversed. And if I use the "Rotate 180 degrees" then down is left, left is down, up is right and right is up. So now I can start pulling my hair on how I can find out how to solve that. :exploding_head:

You may need to manual update the configuration files that control rotation and display direction.

Here is the link to the file that describes how to do that: http://www.lcdwiki.com/res/Show_Direction_and_Touch/How_to_change_display_direction-GPIO-Resistive_Touch-V1.2.pdf

It is really important that you make a backup of the /boot/config.txt and /etc/X11/xorg.conf.d/99-calibration.conf files by making a copy of them with another name such as config.txt.bak or 99-calibration.conf.bak

Thank you. I'll be trying this out in the coming days. I hope it'll work so I can finally get this touchscreen properly working. I stupidly though it'd be a rather simple plug and play, but ofcourse that hasn't been the case.

I just use the Android phone app, which works fantastic to control octoprint, then when the print completes if late at night I just turn the printer off with the sonoff device app.