Skip to content

Commit

Permalink
WIP klicky support
Browse files Browse the repository at this point in the history
  • Loading branch information
pellcorp committed Dec 27, 2024
1 parent 8050cd3 commit 6948461
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 1 deletion.
49 changes: 48 additions & 1 deletion k1/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ setup_bltouch() {
cleanup_probe btteddy
cleanup_probe cartotouch
cleanup_probe beacon
cleanup_probe klicky

# we merge bltouch.cfg into printer.cfg so that z_offset can be set
if [ -f /usr/data/printer_data/config/bltouch.cfg ]; then
Expand Down Expand Up @@ -1062,6 +1063,7 @@ setup_microprobe() {
cleanup_probe btteddy
cleanup_probe cartotouch
cleanup_probe beacon
cleanup_probe klicky

# we merge microprobe.cfg into printer.cfg so that z_offset can be set
if [ -f /usr/data/printer_data/config/microprobe.cfg ]; then
Expand All @@ -1085,6 +1087,42 @@ setup_microprobe() {
return 0
}

setup_klicky() {
grep -q "klicky-probe" /usr/data/pellcorp.done
if [ $? -ne 0 ]; then
echo
echo "INFO: Setting up klicky ..."

cleanup_probe bltouch
cleanup_probe btteddy
cleanup_probe cartotouch
cleanup_probe beacon
cleanup_probe microprobe

cp /usr/data/pellcorp/k1/klicky.cfg /usr/data/printer_data/config/ || exit $?
$CONFIG_HELPER --add-include "klicky.cfg" || exit $?

# need to add a empty probe section for baby stepping to work
$CONFIG_HELPER --add-section "probe" || exit $?

cp /usr/data/pellcorp/k1/klicky_macro.cfg /usr/data/printer_data/config/ || exit $?
$CONFIG_HELPER --add-include "klicky_macro.cfg" || exit $?

cp /usr/data/pellcorp/k1/klicky-${model}.cfg /usr/data/printer_data/config/ || exit $?
$CONFIG_HELPER --add-include "klicky-${model}.cfg" || exit $?

# initially only support a pre-defined bed mesh for klicky
$CONFIG_HELPER --file start_end.cfg --replace-section-entry "gcode_macro _START_END_PARAMS" "variable_adaptive_bed_mesh" False

echo "klicky-probe" >> /usr/data/pellcorp.done
sync

# means klipper needs to be restarted
return 1
fi
return 0
}

set_serial_cartotouch() {
local SERIAL_ID=$(ls /dev/serial/by-id/usb-Cartographer* | head -1)
if [ -n "$SERIAL_ID" ]; then
Expand Down Expand Up @@ -1112,6 +1150,7 @@ setup_cartotouch() {
cleanup_probe microprobe
cleanup_probe btteddy
cleanup_probe beacon
cleanup_probe klicky

cp /usr/data/pellcorp/k1/cartographer.conf /usr/data/printer_data/config/ || exit $?
$CONFIG_HELPER --file moonraker.conf --add-include "cartographer.conf" || exit $?
Expand Down Expand Up @@ -1193,6 +1232,7 @@ setup_beacon() {
cleanup_probe microprobe
cleanup_probe btteddy
cleanup_probe cartotouch
cleanup_probe klicky

cp /usr/data/pellcorp/k1/beacon.conf /usr/data/printer_data/config/ || exit $?
$CONFIG_HELPER --file moonraker.conf --add-include "beacon.conf" || exit $?
Expand Down Expand Up @@ -1281,6 +1321,7 @@ setup_btteddy() {
cleanup_probe microprobe
cleanup_probe cartotouch
cleanup_probe beacon
cleanup_probe klicky

cp /usr/data/pellcorp/k1/btteddy.cfg /usr/data/printer_data/config/ || exit $?
$CONFIG_HELPER --add-include "btteddy.cfg" || exit $?
Expand Down Expand Up @@ -1342,6 +1383,8 @@ elif [ -f /usr/data/printer_data/config/cartotouch.cfg ]; then
probe=cartotouch
elif [ -f /usr/data/printer_data/config/beacon.cfg ]; then
probe=beacon
elif [ -f /usr/data/printer_data/config/klicky.cfg ]; then
probe=klicky
elif grep -q "\[scanner\]" /usr/data/printer_data/config/printer.cfg; then
probe=cartotouch
elif [ -f /usr/data/printer_data/config/microprobe-k1.cfg ] || [ -f /usr/data/printer_data/config/microprobe-k1m.cfg ]; then
Expand Down Expand Up @@ -1382,6 +1425,7 @@ while true; do
echo "ERROR: Switching probes is not supported while trying to fix serial!"
exit 1
fi
elif [ "$1" = "microprobe" ] || [ "$1" = "bltouch" ] || [ "$1" = "beacon" ] || [ "$1" = "klicky" ] || [ "$1" = "cartographer" ] || [ "$1" = "cartotouch" ] || [ "$1" = "btteddy" ]; then
if [ -n "$probe" ] && [ "$1" != "$probe" ]; then
echo "WARNING: About to switch from $probe to $1!"
fi
Expand All @@ -1396,7 +1440,7 @@ done

if [ -z "$probe" ]; then
echo "ERROR: You must specify a probe you want to configure"
echo "One of: [microprobe, bltouch, cartotouch, btteddy, beacon]"
echo "One of: [microprobe, bltouch, cartotouch, btteddy, beacon, klicky]"
exit 1
fi

Expand Down Expand Up @@ -1603,6 +1647,9 @@ elif [ "$probe" = "btteddy" ]; then
elif [ "$probe" = "microprobe" ]; then
setup_microprobe
setup_probe_specific=$?
elif [ "$probe" = "klicky" ]; then
setup_klicky
setup_probe_specific=$?
elif [ "$probe" = "beacon" ]; then
setup_beacon
setup_probe_specific=$?
Expand Down
10 changes: 10 additions & 0 deletions k1/klicky-k1.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[bed_mesh]
speed: 100
horizontal_move_z: 8
mesh_min: -3,3
mesh_max: 192,215
probe_count: 12,12
fade_start: 1.0
fade_end: 10.0
algorithm: bicubic
bicubic_tension: 0.1
10 changes: 10 additions & 0 deletions k1/klicky-k1m.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[bed_mesh]
speed: 100
horizontal_move_z: 8
mesh_min: 5,5
mesh_max: 262,295
probe_count: 12,12
fade_start: 1.0
fade_end: 10.0
algorithm: bicubic
bicubic_tension: 0.1
11 changes: 11 additions & 0 deletions k1/klicky.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[probe]
pin: ^nozzle_mcu: PA8
deactivate_on_each_sample: False
x_offset: -33.0
y_offset: 0
z_offset: 0
samples: 3
speed: 5
lift_speed: 20
samples_tolerance: 0.05
samples_tolerance_retries: 3
12 changes: 12 additions & 0 deletions k1/klicky_macro.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: _BED_MESH_CALIBRATE
gcode:
{% if printer["gcode_macro _SAF_BED_MESH_START"] != null %}
_SAF_BED_MESH_START
{% endif %}

_BED_MESH_CALIBRATE {rawparams}

{% if printer["gcode_macro _SAF_BED_MESH_END"] != null %}
_SAF_BED_MESH_END
{% endif %}
5 changes: 5 additions & 0 deletions k1/start_end.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ gcode:
{% set BED_TEMP=params.BED_TEMP|default(65)|float %}
{% set EXTRUDER_TEMP=params.EXTRUDER_TEMP|default(230)|float %}
{% set CARTOGRAPHER_MODEL=params.CARTOGRAPHER_MODEL|default(None) %}
{% set BED_MESH_PROFILE=params.BED_MESH_PROFILE|default(None) %}
{% set camera_started = printer["gcode_macro START_CAMERA"].started|default(true) %}
{% set cartographer = ('cartographer' in printer.configfile.settings) %}
{% set cartotouch = ('scanner' in printer.configfile.settings and 'touch' == printer.configfile.settings['scanner'].mode|default('touch')) %}
Expand Down Expand Up @@ -132,7 +133,11 @@ gcode:
M109 S{preheat_nozzle_temp}
{% endif %}

{% if BED_MESH_PROFILE %}
BED_MESH_PROFILE LOAD="{BED_MESH_PROFILE}"
{% else %}
BED_MESH_CALIBRATE ADAPTIVE=1 ADAPTIVE_MARGIN=5
{% endif %}

{% if beacon %}
G28 Z METHOD=CONTACT CALIBRATE=0
Expand Down

0 comments on commit 6948461

Please sign in to comment.