KlipperScreen on Android - SA7BNT/3D-Druckerplausch-Klipper GitHub Wiki
Run Android device with KlipperScreen
Connect with ssh to your Raspberry. Go to your moonraker.cfg and add/edit the cfg.
[authorization]
trusted_clients:
127.0.0.1
force_logins: true
[update_manager KlipperScreen]
type: git_repo
path: ~/KlipperScreen
origin: https://github.com/jordanruthe/KlipperScreen.git
env: ~/.KlipperScreen-env/bin/python
requirements: scripts/KlipperScreen-requirements.txt
install_script: scripts/KlipperScreen-install.sh
Safe your changes.
Clone & install the KlipperScreen repositorie
cd /home/pi/
git clone https://github.com/jordanruthe/KlipperScreen
cd KlipperScreen/scripts/
./KlipperScreen-install.sh
Connect your Android device to your Raspberry.
After this type lsusb
to get your idVendor & idProduct.
pi@pi-desktop:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. 4-Port USB 3.1 Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 005: ID 12d1:107e Huawei Technologies Co., Ltd.
Bus 001 Device 004: ID 2c99:0002
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. 4-Port USB 2.1 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@pi-desktop:~$
Now add a new udev
rule for your Android device
sudo nano /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", ATTR{idProduct}=="107e", MODE="0666", GROUP="plugdev"
Safe your created rule and reload the rule with
sudo udevadm control --reload-rule
Check if your device is listed
pi@pi-desktop:~$ adb devices
List of devices attached
73QDU16916005508 device
pi@pi-desktop:~$
Now download & install the application to your device from the Raspberry.
wget https://sourceforge.net/projects/libsdl-android/files/apk/XServer-XSDL/XServer-XSDL-1.11.40.apk
adb install XServer-XSDL-1.11.40.apk
Change to the install map of KlipperScreen and add this bash script
cd /home/pi/KlipperScreen
nano launch_klipperscreen.sh
#!/bin/bash
# forward local display :100 to remote display :0
adb forward tcp:6100 tcp:6000
adb shell dumpsys nfc | grep 'mScreenState=' | grep OFF_LOCKED > /dev/null 2>&1
if [ $? -lt 1 ]
then
echo "Screen is OFF and Locked. Turning screen on..."
adb shell input keyevent 26
fi
adb shell dumpsys nfc | grep 'mScreenState=' | grep ON_LOCKED> /dev/null 2>&1
if [ $? -lt 1 ]
then
echo "Screen is Locked. Unlocking..."
adb shell input keyevent 82
fi
# start xsdl
adb shell am start x.org.server/.MainActivity
ret=1
timeout=0
echo -n "Waiting for x-server to be ready "
while [ $ret -gt 0 ] && [ $timeout -lt 60 ]
do
xset -display :100 -dpms s off -q > /dev/null 2>&1
ret=$?
timeout=$( expr $timeout + 1 )
echo -n "."
sleep 1
done
echo ""
if [ $timeout -lt 60 ]
then
DISPLAY=:100 /home/pi/.KlipperScreen-env/bin/python screen.py
exit 0
else
exit 1
fi
Safe your script.
chmod 755 launch_klipperscreen.sh
Now change the systemd service for KlipperScreen. The important part is WorkingDirectory
&ExecStart
cd ~/
git clone https://github.com/jordanruthe/KlipperScreen.git
cd ~/KlipperScreen
./scripts/KlipperScreen-install.sh
sudo nano /etc/systemd/system/KlipperScreen.service
[Unit]
Description=KlipperScreen
After=moonraker.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=pi
WorkingDirectory=/home/pi/KlipperScreen
ExecStart=/home/pi/KlipperScreen/launch_klipperscreen.sh
[Install]
WantedBy=multi-user.target
Safe your systemd service. Now reload & start KlipperScreen. And hopefully you will get KlipperScreen running on your device.
sudo systemctl daemon-reload
sudo service KlipperScreen start
If you do not have touch on your device try this
After you start the App press Device Configuration (on the top of your screen)
then
Mouse Emulation->Mouse Emulation Mode->Large (Tablets)->OK->OK
If you whant to remove the overlay "Ctrl / Alt / Shift"
Remove USB from device Restart the app Tab on second upcomming screen
You will now see
Set the overlay to "no" as in the picture Done Reconnect USB restart KlipperScreen service
sudo systemctl restart KlipperScreen.service
Side Note to get working over Wi-Fi instead of USB ADB
Follow all steps and put this code in script (launch_klipperscreen.sh) instead.
#!/bin/bash
DISPLAY=(your ip from blue screen):0 /home/pi/.KlipperScreen-env/bin/python3 /home/pi/KlipperScreen/screen.py
With the Wi-Fi method you can create multiple scripts to push to separate devices however if you lose connection you'll have to restart the service to push to the devices again