d4rk50ul1 / klipper-on-android

Using Android to run Klipper, Moonraker, Mainsail/Fuidd, and KlipperScreen
GNU General Public License v3.0
110 stars 22 forks source link

termux removed from instructions #23

Closed kkobold closed 1 year ago

kkobold commented 1 year ago

Termux is not really necessary. You can use unchroot. Also we can have a permanent link for the serial port from octo4a.

sudo unchroot am start -n com.octo4a/.ui.InitialActivity sleep 10 sudo ln -s `sudo unchroot readlink -f /data/data/com.octo4a/files/serialpipe` /dev/printer

d4rk50ul1 commented 1 year ago

Could you please elaborate a bit more on how would the instructions change and where should we write those ? i'm not a linux savvy, hence i need more context to modify the main

d4rk50ul1 commented 1 year ago

Also, i was checking on my installation and rc.local is not available, might be also useful to check if systemd might be a more compatible approach. I try to write my instructions as much 'human proof' as possible so if you could help me out with a more step by step details i would be highly greatful.

semka95 commented 1 year ago

There is much simpler approach, do not need to use unchroot. Go to LinuxDeploy settings, and mount /data/data/com.octo4a/files/ to /home/android/octo4a:

screenshot ![photo_2023-01-17_22-23-59](https://user-images.githubusercontent.com/4162760/212993267-551f26ff-ae4f-421e-b984-17cdbdba7b9b.jpg)

Then go to your printer.cfg and change mcu to /home/android/octo4a/serialpipe.

dsafak commented 1 year ago

I think info in this issue is really good and it would also be good if it is added to instructions. @semka95 @d4rk50ul1 @kkobold thanks to you, I now am able to fully automate it. @semka95 I was trying to smybolink outside chroot and actually that worked sort of but I also tried to mount and couldn't really get it to work. Thanks for pointing out that linuxdeploy can actually mount, this was a huge help.

Now I should add more info towards fully automated start on boot. I installed init.d light from f-droid which lets you run scripts on boot, I think magisk also can do it. So any app that can run scripts basicaly should work.

-Follow @semka95 message and mount octo4a's files folder into somewhere you want. In my case it is mounted at "/dev/printer" -You need some way or tool to run a script on boot, I used init.d light, available in f-droid. don't forget ot make the script executable (chmod +x) -You will need to set phone rotation to "Always portrait" (XServer XSDL will rotate it by itself to landscape.) -You need to disable any lock-screen including swipe open. In my phone I could select "None" so there is no lock screen at all. This is required so phone doesn't boot into lock screen. Maybe If there is no option and no other way to disable. One can use the input function to make script swipe open. -Octo4a should be set to auto-start from its settings, more info about it below after script. I used this script to automate the rest of the process:

#select autostart from octoprint, starting from script is for some reason buggy
sleep 10;
input tap 353 1336;
input tap 1149 1571;
sleep 5;
am start -a android.intent.action.MAIN -n x.org.server/.MainActivity;
sleep 15;
/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy mount;
/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy start;
/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy shell 'sudo chmod 777 /dev/printer/serialpipe';

I was starting and killing octo4a but it was causing problems that way. Even when it detects and select printer, it wasn't updating serialpipe for some reason in my case. So i had to use auto-start function within octo4a. This way it isn't as clean of a solution but I had to do this to get it to work.

the "input tap" lines are for clicking octo4a permission request boxes for my phone, it will not match other phones. This is also another issue. If you plug printer after phone is ON. Octo4a will remember and do not ask for permission. If you boot phone while printer is connected, it asks for permission and I couldn't get rid of it, so I made the script click the boxes. If your phone doesn't do this, you can remove those lines.

To get what coordinates you have to: go to developer settings in your phone and enable pointer location option, simply put your finger on the checkbox first, take the coordinates and then take the coordinates of "OK" button. So it can click the checkbox and then click OK. Replace input tap coordinates X,Y with what you have.

The rest should work. Again thanks everyone for help and this great repo.

d4rk50ul1 commented 1 year ago

i'm going to close this PR since the newest one from @semka95 it's simpler and straightforward. @kkobold thanks for your collaboration, it worked perfect for me but i believe the latest one is way easier for the general audience