-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
586 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/sh | ||
|
||
CONFIG_HELPER="/usr/data/pellcorp/k1/config-helper.py" | ||
|
||
MODEL=$(/usr/bin/get_sn_mac.sh model) | ||
if [ "$MODEL" = "CR-K1" ] || [ "$MODEL" = "K1C" ] || [ "$MODEL" = "K1 SE" ]; then | ||
model=k1 | ||
elif [ "$MODEL" = "CR-K1 Max" ] || [ "$MODEL" = "K1 Max SE" ]; then | ||
model=k1m | ||
else | ||
echo "This script is not supported for $MODEL!" | ||
exit 1 | ||
fi | ||
|
||
function apply_mount_overrides() { | ||
local probe=$1 | ||
local mount=$2 | ||
|
||
return_status=0 | ||
overrides_dir=/usr/data/pellcorp/k1/mounts/$probe/$mount | ||
if [ ! -f /usr/data/pellcorp/k1/mounts/$probe/${mount}.overrides ]; then | ||
echo "ERROR: Probe and Mount combination not found" | ||
exit 0 # FIXME unfortunately we are using this exit code to know overrides were applied | ||
fi | ||
|
||
echo "INFO: Applying mount overrides ..." | ||
overrides_dir=/tmp/overrides.$$ | ||
mkdir $overrides_dir | ||
file= | ||
while IFS= read -r line; do | ||
if echo "$line" | grep -q "^--"; then | ||
file=$(echo $line | sed 's/-- //g') | ||
touch $overrides_dir/$file | ||
elif echo "$line" | grep -q "^#"; then | ||
continue # skip comments | ||
elif [ -n "$file" ] && [ -f $overrides_dir/$file ]; then | ||
echo "$line" >> $overrides_dir/$file | ||
fi | ||
done < "/usr/data/pellcorp/k1/mounts/$probe/${mount}.overrides" | ||
|
||
files=$(find $overrides_dir -maxdepth 1 -name "*.cfg") | ||
for file in $files; do | ||
file=$(basename $file) | ||
|
||
if [ "$file" = "bltouch.cfg" ] && [ "$probe" = "bltouch" ]; then # bltouch.cfg is merged into printer.cfg | ||
target_file=printer.cfg | ||
elif [ "$file" = "microprobe.cfg" ] && [ "$probe" = "microprobe" ]; then # microprobe.cfg is merged into printer.cfg | ||
target_file=printer.cfg | ||
elif [ "$file" = "printer-${model}.cfg" ]; then | ||
target_file=printer.cfg | ||
else | ||
target_file=$file | ||
fi | ||
|
||
if [ -f /usr/data/printer_data/config/$target_file ]; then | ||
echo "Applying mount overrides for $target_file ..." | ||
$CONFIG_HELPER --file $target_file --overrides $overrides_dir/$file || exit $? | ||
fi | ||
return_status=1 | ||
done | ||
rm -rf $overrides_dir | ||
sync | ||
return $return_status | ||
} | ||
|
||
mode=config | ||
if [ "$1" = "--verify" ]; then | ||
mode=verify | ||
shift | ||
fi | ||
|
||
# note for cartotouch we pass in 'cartographer' as the mount | ||
if [ $# -eq 0 ]; then | ||
echo "Usage: $0 <cartotouch|btteddy|microprobe|bltouch> <mount>" | ||
exit 0 | ||
fi | ||
|
||
probe=$1 | ||
mount=$2 | ||
|
||
if [ "$mode" = "verify" ]; then | ||
if [ -d /usr/data/pellcorp/k1/mounts/$probe ]; then | ||
if [ -f /usr/data/pellcorp/k1/mounts/$probe/${mount}.overrides ]; then | ||
exit 0 | ||
else | ||
if [ -n "$mount" ]; then | ||
echo "ERROR: Invalid $probe mount $mount specified!" | ||
fi | ||
echo | ||
echo "The following mounts are available:" | ||
echo | ||
files=$(find /usr/data/pellcorp/k1/mounts/$probe -maxdepth 1 -name "*.overrides") | ||
for file in $files; do | ||
comment=$(cat $file | grep "^#" | head -1 | sed 's/#\s*//g') | ||
file=$(basename $file .overrides) | ||
echo " * $file - $comment" | ||
done | ||
echo | ||
exit 1 | ||
fi | ||
else | ||
echo "ERROR: Invalid probe $probe specified!" | ||
exit 1 | ||
fi | ||
else | ||
apply_mount_overrides "$probe" "$mount" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# https://www.printables.com/model/1073375-cr-touch-mount-k1-k1maxk1c-zero-y-offset | ||
|
||
-- bltouch.cfg | ||
[bltouch] | ||
x_offset: -37 | ||
y_offset: 0 | ||
|
||
-- bltouch-k1.cfg | ||
[bed_mesh] | ||
mesh_min: 3,5 | ||
mesh_max: 192,215 | ||
|
||
[screws_tilt_adjust] | ||
screw1: 62,20 | ||
screw2: 232,20 | ||
screw3: 232,190 | ||
screw4: 62,190 | ||
|
||
-- bltouch-k1m.cfg | ||
[bed_mesh] | ||
mesh_min: 3,5 | ||
mesh_max: 192,215 | ||
|
||
[screws_tilt_adjust] | ||
screw1: 56,23 | ||
screw2: 306,23 | ||
screw3: 285,272 | ||
screw4: 85,272 | ||
|
||
-- printer-k1.cfg | ||
[stepper_y] | ||
position_endstop: 226 | ||
position_max: 226 | ||
|
||
-- printer-k1m.cfg | ||
[stepper_y] | ||
position_endstop: 306 | ||
position_max: 306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# https://www.printables.com/model/666186-creality-k1-bltouch-adapter | ||
|
||
-- bltouch.cfg | ||
[bltouch] | ||
x_offset: 0.0 | ||
y_offset: 25.25 | ||
|
||
-- bltouch-k1.cfg | ||
[bed_mesh] | ||
mesh_min: 5,30 | ||
mesh_max: 210,209 | ||
|
||
[screws_tilt_adjust] | ||
screw1: 25,0 | ||
screw2: 195,0 | ||
screw3: 195,165 | ||
screw4: 25,165 | ||
|
||
-- bltouch-k1m.cfg | ||
[bed_mesh] | ||
mesh_min: 5,30 | ||
mesh_max: 285,280 | ||
|
||
[screws_tilt_adjust] | ||
screw1: 19,0 | ||
screw2: 278,0 | ||
screw3: 248,252 | ||
screw4: 48,252 | ||
|
||
-- printer-k1.cfg | ||
[stepper_y] | ||
position_endstop: 210 | ||
position_max: 210 | ||
|
||
-- printer-k1m.cfg | ||
[stepper_y] | ||
position_endstop: 290 | ||
position_max: 290 |
Oops, something went wrong.