Skip to content

Commit

Permalink
add installer.sh and support.
Browse files Browse the repository at this point in the history
  • Loading branch information
ballaswag committed Dec 11, 2023
1 parent 62a064c commit 965c1cf
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: ballaswag
ko_fi: ballaswag
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ Guppy Screen is a touch UI for Klipper using APIs exposed by Moonraker. It build
## Installation
Run the following interactive script via SSH on your K1/Max to install Guppy Screen.

#### Material Design Theme
```
sh -c "$(wget --no-check-certificate -qO - https://raw.githubusercontent.com/ballaswag/guppyscreen/main/installer.sh)"
```

#### Z-Bolt Theme
```
sh -c "$(wget --no-check-certificate -qO - https://raw.githubusercontent.com/ballaswag/guppyscreen/main/installer.sh)" -s zbolt
```

## Features
:white_check_mark: Console/Macro Shell
:white_check_mark: Bedmesh
Expand All @@ -14,7 +24,7 @@ Run the following interactive script via SSH on your K1/Max to install Guppy Scr
:white_check_mark: Extrude/Retract
:white_check_mark: Temperature Control
:white_check_mark: Fans/LED/Move Control
:white_check_mark: Fine Tune (speed, flow, z-offset)
:white_check_mark: Fine Tune (speed, flow, z-offset)
:white_check_mark: File Browser

## Roadmap
Expand All @@ -36,6 +46,12 @@ Earlier development screenshots can be found [here](https://github.com/ballaswag
## Video Demo
https://www.reddit.com/r/crealityk1/comments/17jp59g/new_touch_ui_for_the_k1/

## Support Guppy Screen
You can directly support this project using [GitHub Sponsors](https://github.com/sponsors/ballaswag/) or [Ko-Fi](https://ko-fi.com/ballaswag)

## Credits
[Material Design Icons](https://pictogrammers.com/library/mdi/)
[Z-Bolt Icons](https://github.com/Z-Bolt/OctoScreen)
[Z-Bolt Icons](https://github.com/Z-Bolt/OctoScreen)
[Moonraker](https://github.com/Arksine/moonraker)
[KlipperScreen](https://github.com/KlipperScreen/KlipperScreen)
[Fluidd](https://github.com/fluidd-core/fluidd)
151 changes: 151 additions & 0 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/bin/sh

yellow=`echo "\033[01;33m"`
green=`echo "\033[01;32m"`
red=`echo "\033[01;31m"`
white=`echo "\033[m"`

K1_CONFIG_DIR=/usr/data/printer_data/config
BACKUP_DIR=/usr/data/guppyify-backup
K1_GUPPY_DIR=/usr/data/guppyscreen
FT2FONT_PATH=/usr/lib/python3.8/site-packages/matplotlib/ft2font.cpython-38-mipsel-linux-gnu.so
KLIPPY_EXTRA_DIR=/usr/share/klipper/klippy/extras
GCODE_SHELL_CMD=$KLIPPY_EXTRA_DIR/gcode_shell_command.py
SHAPER_CONFIG=$KLIPPY_EXTRA_DIR/calibrate_shaper_config.py

printf "${green}=== Installing Guppy Screen === ${white}\n"

# check ld.so version
if [ ! -f /lib/ld-2.29.so ]; then
printf "${red}ld.so is not the expected version. Make sure you're running 1.3.x.y firmware versions ${white}\n"
exit 1
fi

echo "Checking for a working Moonraker"
MRK_KPY_OK=`curl localhost:7125/server/info | jq .result.klippy_connected`
if [ "$MRK_KPY_OK" != "true" ]; then
printf "${yellow}Moonraker is not properly setup at port 7125. Continue anyways? (y/n) ${white}\n"
read confirm
echo

if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
echo "Continuing to install GuppyScreen"
else
echo "Please fix Moonraker and restart this script."
exit 1
fi
fi

# download/extract latest guppyscreen
if [ x"$1" == x"zbolt" ]; then
wget -q --no-check-certificate https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen-zbolt.tar.gz -O /tmp/guppyscreen.tar.gz
else
wget -q --no-check-certificate https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen.tar.gz -O /tmp/guppyscreen.tar.gz
fi
tar xf /tmp/guppyscreen.tar.gz -C /usr/data/

if [ ! -d "$K1_GUPPY_DIR" ]; then
printf "${red}Did not find guppyscreen in $K1_GUPPY_DIR. GuppyScreen must be extracted in $K1_GUPPY_DIR ${white}\n"
exit 1
fi


if [ ! -d "$BACKUP_DIR" ]; then
printf "${green} Backing up original K1 files ${white}\n"
mkdir -p $BACKUP_DIR

mv /etc/init.d/S12boot_display $BACKUP_DIR
cp /etc/init.d/S50dropbear $BACKUP_DIR
cp /etc/init.d/S99start_app $BACKUP_DIR
fi

if [ ! -f $BACKUP_DIR/ft2font.cpython-38-mipsel-linux-gnu.so ]; then
# backup ft2font
mv /usr/lib/python3.8/site-packages/matplotlib/ft2font.cpython-38-mipsel-linux-gnu.so $BACKUP_DIR
fi

printf "${white}=== Do you want to disable all Creality services (revertable) with GuppyScreen installation? ===\n"
printf "${green} Pros: Frees up system resources on your K1 for critical services such as Klipper (Recommended)\n"
printf "${white} Cons: Disabling all Creality services breaks Creality Cloud/Creality Slider.\n\n"
printf "Disable all Creality Services? (y/n)"

read confirm_decreality
echo

if [ "$confirm_decreality" = "y" -o "$confirm_decreality" = "Y" ]; then
printf "${green}Disabling Creality services ${white}\n"
rm /etc/init.d/S99start_app
else
# disables only display-server and Monitor
cp $K1_GUPPY_DIR/k1_mods/S99start_app /etc/init.d/S99start_app
fi

printf "${green}Setting up GuppyScreen ${white}\n"
cp $K1_GUPPY_DIR/k1_mods/S50dropbear /etc/init.d/S50dropbear
cp $K1_GUPPY_DIR/k1_mods/S99guppyscreen /etc/init.d/S99guppyscreen

cp $K1_GUPPY_DIR/k1_mods/calibrate_shaper_config.py $SHAPER_CONFIG

if [ ! -d "/usr/lib/python3.8/site-packages/matplotlib-2.2.3-py3.8.egg-info" ]; then
echo "Not replacing mathplotlib ft2font module. PSD graphs might not work"
else
printf "${green}Replacing mathplotlib ft2font module for plotting PSD graphs ${white}\n"
cp $K1_GUPPY_DIR/k1_mods/ft2font.cpython-38-mipsel-linux-gnu.so $FT2FONT_PATH
fi

if [ ! -f $GCODE_SHELL_CMD ]; then
printf "${green}Installing gcode_shell_command.py for klippy ${white}\n"
cp $K1_GUPPY_DIR/k1_mods/gcode_shell_command.py $GCODE_SHELL_CMD
fi

mkdir -p $K1_CONFIG_DIR/GuppyScreen/scripts
cp $K1_GUPPY_DIR/scripts/*.cfg $K1_CONFIG_DIR/GuppyScreen
cp $K1_GUPPY_DIR/scripts/*.py $K1_CONFIG_DIR/GuppyScreen/scripts

## includ guppyscreen *.cfg in printer.cfg
if grep -q "include GuppyScreen" $K1_CONFIG_DIR/printer.cfg ; then
echo "printer.cfg already includes GuppyScreen cfgs"
else
printf "${green}Including guppyscreen cfgs in printer.cfg ${white}\n"
sed -i '/\[include gcode_macro\.cfg\]/a \[include GuppyScreen/*\.cfg\]' $K1_CONFIG_DIR/printer.cfg
fi

sync

if [ ! -f $K1_GUPPY_DIR/guppyscreen ]; then
printf "${red}Installation failed, did not find guppyscreen in $K1_GUPPY_DIR. Make sure to extract the guppyscreen directory in /usr/data. ${white}\n"
exit 1
fi

## double check dropbear is the correct one
if ! diff $K1_GUPPY_DIR/k1_mods/S50dropbear /etc/init.d/S50dropbear > /dev/null ; then
printf "${red}Dropbear (SSHD) didn't install properly. ${white}\n"
exit 1
fi

## request to reboot
printf "Restart Klipper now to pick up the new changes (y/n): "
read confirm
echo

if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
echo "Restarting Klipper"
/etc/init.d/S55klipper_service restart
else
printf "${red}Some GuppyScreen functionaly won't work until Klipper is restarted. ${white}\n"
fi

killall Monitor
killall display-server
if [ "$confirm_decreality" = "y" -o "$confirm_decreality" = "Y" ]; then
echo "Killing Creality services"
killall master-server
killall audio-server
killall wifi-server
killall app-server
killall upgrade-server
killall web-server
fi

printf "${green}Starting GuppyScreen ${white}\n"
/etc/init.d/S99guppyscreen restart

0 comments on commit 965c1cf

Please sign in to comment.