Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions config/sensorless.cfg → config/homing.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gcode_macro _SENSORLESS_PARAMS]
[gcode_macro _HOMING_PARAMS]
variable_homing_current: 1.5
variable_safe_z: 3
# force move for homing after M84 or power off
Expand All @@ -17,7 +17,7 @@ variable_home_y_before_x: False
# coordinates that the _POST_HOME_XY will position the nozzle before homing z
variable_home_x: 150
variable_home_y: 150
# if you are rocking other than TMC 2209 drivers should should configure it here
# if you are rocking other than TMC 2209 drivers should configure it here
variable_driver_type: "tmc2209"
gcode:

Expand Down Expand Up @@ -48,9 +48,9 @@ gcode:
{% set klicky = (printer["gcode_macro _KLICKY_VARIABLES"] != null) %}

{% set sensorless_homing = ('virtual_endstop' in printer.configfile.settings['stepper_x'].endstop_pin and 'virtual_endstop' in printer.configfile.settings['stepper_y'].endstop_pin) %}
{% set repeat_home_xy = printer["gcode_macro _SENSORLESS_PARAMS"].repeat_home_xy %}
{% set repeat_home_xy = printer["gcode_macro _HOMING_PARAMS"].repeat_home_xy %}
{% set home_count = 2 if sensorless_homing and repeat_home_xy else 1 %}
{% set home_y_before_x = printer["gcode_macro _SENSORLESS_PARAMS"].home_y_before_x %}
{% set home_y_before_x = printer["gcode_macro _HOMING_PARAMS"].home_y_before_x %}
{% set home_axes_order = ['y', 'x'] if home_y_before_x else ['x', 'y'] %}
{% set btteddy_wait_for_temp = (printer["gcode_macro _BTTEDDY_MACRO_PARAMS"] != null and printer["gcode_macro _BTTEDDY_MACRO_PARAMS"].wait_for_temp) %}

Expand Down Expand Up @@ -144,7 +144,7 @@ gcode:
gcode:
{% set sensorless_homing = ('virtual_endstop' in printer.configfile.settings['stepper_x'].endstop_pin) %}
{% if sensorless_homing %}
{% set HOMING_CURRENT = printer["gcode_macro _SENSORLESS_PARAMS"].homing_current %}
{% set HOMING_CURRENT = printer["gcode_macro _HOMING_PARAMS"].homing_current %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOMING_CURRENT}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOMING_CURRENT}
{% endif %}
Expand All @@ -154,7 +154,7 @@ gcode:
gcode:
{% set sensorless_homing = ('virtual_endstop' in printer.configfile.settings['stepper_y'].endstop_pin) %}
{% if sensorless_homing %}
{% set HOMING_CURRENT = printer["gcode_macro _SENSORLESS_PARAMS"].homing_current %}
{% set HOMING_CURRENT = printer["gcode_macro _HOMING_PARAMS"].homing_current %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOMING_CURRENT}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOMING_CURRENT}
{% endif %}
Expand All @@ -166,7 +166,7 @@ variable_camera_started: True
gcode:
{% set camera_started = printer["gcode_macro START_CAMERA"].started|default(true) %}
SET_GCODE_VARIABLE MACRO=_PRE_HOME_Z VARIABLE=camera_started VALUE={camera_started}
{% set stop_start_camera = printer["gcode_macro _SENSORLESS_PARAMS"].stop_start_camera %}
{% set stop_start_camera = printer["gcode_macro _HOMING_PARAMS"].stop_start_camera %}
{% set klicky = (printer["gcode_macro _KLICKY_VARIABLES"] != null) %}

{% if stop_start_camera and camera_started %}
Expand All @@ -178,8 +178,8 @@ gcode:
{% if klicky %}
ATTACH_PROBE MANUAL=0
{% elif printer['output_pin _saf_z_endstop'] != null %}
{% set home_x = printer["gcode_macro _SENSORLESS_PARAMS"].home_x|int %}
{% set home_y = printer["gcode_macro _SENSORLESS_PARAMS"].home_y|int %}
{% set home_x = printer["gcode_macro _HOMING_PARAMS"].home_x|int %}
{% set home_y = printer["gcode_macro _HOMING_PARAMS"].home_y|int %}
G90
G0 X{home_x} Y{home_y} F15000
SET_PIN PIN=_saf_z_endstop VALUE=1
Expand All @@ -189,7 +189,7 @@ gcode:
gcode:
{% set sensorless_homing = ('virtual_endstop' in printer.configfile.settings['stepper_x'].endstop_pin) %}
{% if sensorless_homing %}
{% set homing_move_away_x = printer["gcode_macro _SENSORLESS_PARAMS"].homing_move_away_x %}
{% set homing_move_away_x = printer["gcode_macro _HOMING_PARAMS"].homing_move_away_x %}
{% set x_position_endstop = printer.configfile.settings['stepper_x'].position_endstop %}
{% set x_position_min = printer.configfile.settings['stepper_x'].position_min %}
G91
Expand All @@ -199,7 +199,7 @@ gcode:
G1 X+{homing_move_away_x } F1200
{% endif %}

{% set driver = printer["gcode_macro _SENSORLESS_PARAMS"].driver_type %}
{% set driver = printer["gcode_macro _HOMING_PARAMS"].driver_type %}
{% set RUN_CURRENT_X = printer.configfile.settings[driver ~ ' stepper_x'].run_current|float %}
{% set RUN_CURRENT_Y = printer.configfile.settings[driver ~ ' stepper_y'].run_current|float %}

Expand All @@ -214,7 +214,7 @@ gcode:
gcode:
{% set sensorless_homing = ('virtual_endstop' in printer.configfile.settings['stepper_y'].endstop_pin) %}
{% if sensorless_homing %}
{% set homing_move_away_y = printer["gcode_macro _SENSORLESS_PARAMS"].homing_move_away_y %}
{% set homing_move_away_y = printer["gcode_macro _HOMING_PARAMS"].homing_move_away_y %}
{% set y_position_endstop = printer.configfile.settings['stepper_y'].position_endstop %}
{% set y_position_min = printer.configfile.settings['stepper_y'].position_min %}
G91
Expand All @@ -224,7 +224,7 @@ gcode:
G1 Y+{homing_move_away_y} F1200
{% endif %}

{% set driver = printer["gcode_macro _SENSORLESS_PARAMS"].driver_type %}
{% set driver = printer["gcode_macro _HOMING_PARAMS"].driver_type %}
{% set RUN_CURRENT_X = printer.configfile.settings[driver ~ ' stepper_x'].run_current|float %}
{% set RUN_CURRENT_Y = printer.configfile.settings[driver ~ ' stepper_y'].run_current|float %}

Expand All @@ -238,9 +238,9 @@ gcode:
[gcode_macro _POST_HOME_Z]
gcode:
{% set camera_started = printer["gcode_macro _PRE_HOME_Z"].camera_started|default(true) %}
{% set stop_start_camera = printer["gcode_macro _SENSORLESS_PARAMS"].stop_start_camera %}
{% set stop_start_camera = printer["gcode_macro _HOMING_PARAMS"].stop_start_camera %}
{% set klicky = (printer["gcode_macro _KLICKY_VARIABLES"] != null) %}
{% set homing_move_away_z = printer["gcode_macro _SENSORLESS_PARAMS"].homing_move_away_z|int %}
{% set homing_move_away_z = printer["gcode_macro _HOMING_PARAMS"].homing_move_away_z|int %}

{% if stop_start_camera and camera_started %}
G4 P1000
Expand All @@ -265,8 +265,8 @@ gcode:
# where motors were turned off or printer power cycled / klipper restarted
# so if at least one axis has been homed printer.toolhead.homed_axes = "xyz"
# so this safe force move step only occurs when no axis are homed
{% set force_move = printer["gcode_macro _SENSORLESS_PARAMS"].force_move %}
{% set safe_z = printer["gcode_macro _SENSORLESS_PARAMS"].safe_z|int %}
{% set force_move = printer["gcode_macro _HOMING_PARAMS"].force_move %}
{% set safe_z = printer["gcode_macro _HOMING_PARAMS"].safe_z|int %}

{% if printer.toolhead.homed_axes != "xyz" and force_move %}
RESPOND TYPE=command MSG='Force moving Z {safe_z} mm distance'
Expand All @@ -284,8 +284,8 @@ gcode:
[gcode_macro _POST_HOME_XY]
gcode:
{% if "xy" in printer.toolhead.homed_axes %}
{% set home_x = printer["gcode_macro _SENSORLESS_PARAMS"].home_x|int %}
{% set home_y = printer["gcode_macro _SENSORLESS_PARAMS"].home_y|int %}
{% set home_x = printer["gcode_macro _HOMING_PARAMS"].home_x|int %}
{% set home_y = printer["gcode_macro _HOMING_PARAMS"].home_y|int %}
G90

G0 X{home_x} Y{home_y} F3200
Expand Down
23 changes: 14 additions & 9 deletions k1/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -806,14 +806,14 @@ function install_klipper() {
cp /usr/data/pellcorp/k1/services/S13mcu_update /etc/init.d/ || exit $?
fi

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

x_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_x" "position_max" --divisor 2 --integer)
$CONFIG_HELPER --file sensorless.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_home_x" "$x_position_mid" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_home_x" "$x_position_mid" || exit $?

y_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_y" "position_max" --divisor 2 --integer)
$CONFIG_HELPER --file sensorless.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_home_y" "$y_position_mid" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_home_y" "$y_position_mid" || exit $?

# just make sure the baud is written
$CONFIG_HELPER --replace-section-entry "mcu" "baud" 230400 || exit $?
Expand All @@ -824,11 +824,11 @@ function install_klipper() {
# for Ender 5 Max we need to disable sensorless homing, reversing homing order,don't move away and do not repeat homing
# but we are still going to use homing override even though the max has physical endstops to make things a bit easier
if [ "$MODEL" = "F004" ]; then
$CONFIG_HELPER --file sensorless.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_home_y_before_x" "True" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_home_y_before_x" "True" || exit $?
fi

if [ "$kinematics" = "corexy" ]; then # by default we want to home twice when using sensorless
$CONFIG_HELPER --file sensorless.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_repeat_home_xy" "True" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_repeat_home_xy" "True" || exit $?
fi

cp /usr/data/pellcorp/k1/internal_macros.cfg /usr/data/printer_data/config/ || exit $?
Expand Down Expand Up @@ -892,6 +892,7 @@ function install_klipper() {
$CONFIG_HELPER --remove-section-entry "tmc2209 stepper_x" "hold_current" || exit $?
$CONFIG_HELPER --remove-section-entry "tmc2209 stepper_y" "hold_current" || exit $?

$CONFIG_HELPER --remove-include "sensorless.cfg" || exit $?
$CONFIG_HELPER --remove-include "printer_params.cfg" || exit $?
$CONFIG_HELPER --remove-include "gcode_macro.cfg" || exit $?
$CONFIG_HELPER --remove-include "custom_gcode.cfg" || exit $?
Expand Down Expand Up @@ -1365,7 +1366,7 @@ function setup_bltouch() {
$CONFIG_HELPER --add-include "bltouch_macro.cfg" || exit $?

# for bltouch probe deploy issues occur with safe z at 3
$CONFIG_HELPER --file sensorless.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_safe_z" "5" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_safe_z" "5" || exit $?

# need to add a empty bltouch section for baby stepping to work
$CONFIG_HELPER --remove-section "bltouch" || exit $?
Expand Down Expand Up @@ -1687,7 +1688,7 @@ function setup_beacon() {
$CONFIG_HELPER --add-include "beacon.cfg" || exit $?

# for beacon can't use homing override
$CONFIG_HELPER --file sensorless.cfg --remove-section "homing_override"
$CONFIG_HELPER --file homing.cfg --remove-section "homing_override"

y_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_y" "position_max" --divisor 2 --integer)
x_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_x" "position_max" --divisor 2 --integer)
Expand Down Expand Up @@ -2485,13 +2486,17 @@ fi
if [ -f /usr/data/pellcorp-backups/printer.factory.cfg ]; then
# we want a copy of the file before config overrides are re-applied so we can correctly generate diffs
# against different generations of the original file
for file in printer.cfg start_end.cfg fan_control.cfg ${probe}.conf spoolman.conf internal_macros.cfg useful_macros.cfg timelapse.conf moonraker.conf webcam.conf sensorless.cfg ${probe}_macro.cfg ${probe}.cfg; do
for file in printer.cfg start_end.cfg fan_control.cfg ${probe}.conf spoolman.conf internal_macros.cfg useful_macros.cfg timelapse.conf moonraker.conf webcam.conf homing.cfg ${probe}_macro.cfg ${probe}.cfg; do
if [ -f /usr/data/printer_data/config/$file ]; then
cp /usr/data/printer_data/config/$file /usr/data/pellcorp-backups/$file
fi
done
fi

# remove old cfg files
[ -f /usr/data/pellcorp-backups/sensorless.cfg ] && rm /usr/data/pellcorp-backups/sensorless.cfg
[ -f /usr/data/printer_data/config/sensorless.cfg ] && rm /usr/data/printer_data/config/sensorless.cfg

apply_overrides=0
# there will be no support for generating pellcorp-overrides unless you have done a factory reset
if [ -f /usr/data/pellcorp-backups/printer.factory.cfg ]; then
Expand Down
2 changes: 1 addition & 1 deletion k1/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The following files were originally from other projects. Some of these files ar
- k1/services/S56moonraker_service -> https://github.com/Guilouz/Creality-Helper-Script/blob/main/files/services/S56moonraker_service
- k1/moonraker.conf -> https://github.com/Guilouz/Creality-Helper-Script/blob/main/files/moonraker/moonraker.conf
- k1/services/S55klipper_service -> https://raw.githubusercontent.com/K1-Klipper/installer_script_k1_and_max/main/S55klipper_service
- config/sensorless.cfg -> https://raw.githubusercontent.com/K1-Klipper/installer_script_k1_and_max/main/sensorless.cfg
- config/homing.cfg -> https://raw.githubusercontent.com/K1-Klipper/installer_script_k1_and_max/main/sensorless.cfg
- k1/tools/curl -> https://raw.githubusercontent.com/ballaswag/k1-discovery/main/bin/curl
- k1/tools/supervisorctl -> https://raw.githubusercontent.com/Guilouz/Creality-Helper-Script/main/files/fixes/supervisorctl
- k1/tools/systemctl -> https://github.com/Guilouz/Creality-Helper-Script/blob/main/files/fixes/systemctl
Expand Down
8 changes: 4 additions & 4 deletions rpi/incus/incus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ while true; do
done

incus file push $HOME/.ssh/id_rsa.pub "klipper/root/id_rsa.pub"

# seems like running this again before setup might fix some issues no idea why, perhaps this is a fedora thing
sudo iptables -P FORWARD ACCEPT

incus exec klipper -- /opt/projects/incus/setup.sh

IP_ADDRESS=$(incus info klipper | grep inet | head -1 | awk -F ':' '{print $2}' | sed 's:/24 (global)::g' | tr -d '[:space:]')
#IP_ADDRESS=$(incus exec klipper -- bash -c "ip route | grep 'default' | awk '{print \$9}' | tail -1" 2> /dev/null)
ssh-keygen -f "$HOME/.ssh/known_hosts" -R $IP_ADDRESS > /dev/null 2>&1
ssh-keyscan -t rsa "$IP_ADDRESS" >> "$HOME/.ssh/known_hosts" 2> /dev/null

# seems like running this again after setup might fix some issues no idea why, perhaps this is a fedora thing
sudo iptables -P FORWARD ACCEPT

ssh me@$IP_ADDRESS
10 changes: 5 additions & 5 deletions rpi/install-klipper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,19 @@ if [ $? -ne 0 ]; then

# most stuff only works with corexy and cartesian
if [ "$kinematics" = "corexy" ] || [ "$kinematics" = "cartesian" ]; then
cp $BASEDIR/pellcorp/config/sensorless.cfg $BASEDIR/printer_data/config/homing_override.cfg || exit $?
$CONFIG_HELPER --add-include "homing_override.cfg" || exit $?
cp $BASEDIR/pellcorp/config/homing.cfg $BASEDIR/printer_data/config/ || exit $?
$CONFIG_HELPER --add-include "homing.cfg" || exit $?

x_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_x" "position_max" --divisor 2 --integer)
$CONFIG_HELPER --file homing_override.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_home_x" "$x_position_mid" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_home_x" "$x_position_mid" || exit $?

y_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_y" "position_max" --divisor 2 --integer)
$CONFIG_HELPER --file homing_override.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_home_y" "$y_position_mid" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_home_y" "$y_position_mid" || exit $?

# there is an assumption the same stepper driver will be used for stepper x and y
tmc_driver=$($CONFIG_HELPER --list-sections tmc% | grep stepper_x | awk -F ' ' '{print $1}')
if [ -n "$tmc_driver" ] && [ "$tmc_driver" != "tmc2209" ]; then
$CONFIG_HELPER --file homing_override.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_driver_type" "\"$tmc_driver\"" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_driver_type" "\"$tmc_driver\"" || exit $?
fi

cp $BASEDIR/pellcorp/config/start_end.cfg $BASEDIR/printer_data/config/ || exit $?
Expand Down
12 changes: 9 additions & 3 deletions rpi/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function setup_bltouch() {
$CONFIG_HELPER --add-include "bltouch_macro.cfg" || exit $?

# for bltouch probe deploy issues occur with safe z at 3
$CONFIG_HELPER --file homing_override.cfg --replace-section-entry "gcode_macro _SENSORLESS_PARAMS" "variable_safe_z" "5" || exit $?
$CONFIG_HELPER --file homing.cfg --replace-section-entry "gcode_macro _HOMING_PARAMS" "variable_safe_z" "5" || exit $?

# need to add a empty bltouch section for baby stepping to work
$CONFIG_HELPER --remove-section "bltouch" || exit $?
Expand Down Expand Up @@ -672,7 +672,7 @@ function setup_beacon() {
$CONFIG_HELPER --add-include "beacon.cfg" || exit $?

# for beacon can't use homing override
$CONFIG_HELPER --file homing_override.cfg --remove-section "homing_override"
$CONFIG_HELPER --file homing.cfg --remove-section "homing_override"

y_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_y" "position_max" --divisor 2 --integer)
x_position_mid=$($CONFIG_HELPER --get-section-entry "stepper_x" "position_max" --divisor 2 --integer)
Expand Down Expand Up @@ -1470,7 +1470,7 @@ fi

# we want a copy of the file before config overrides are re-applied so we can correctly generate diffs
# against different generations of the original file
for file in printer.cfg start_end.cfg fan_control.cfg ${probe}.conf spoolman.conf timelapse.conf moonraker.conf crowsnest.conf webcam.conf useful_macros.cfg homing_override.cfg ${probe}_macro.cfg ${probe}.cfg; do
for file in printer.cfg start_end.cfg fan_control.cfg ${probe}.conf spoolman.conf timelapse.conf moonraker.conf crowsnest.conf webcam.conf useful_macros.cfg homing.cfg ${probe}_macro.cfg ${probe}.cfg; do
if [ -f $BASEDIR/printer_data/config/$file ]; then
cp $BASEDIR/printer_data/config/$file $BASEDIR/pellcorp-backups/$file
fi
Expand All @@ -1495,6 +1495,12 @@ fi
fi
fi

# remove old cfg files
[ -f $BASEDIR/pellcorp-backups/sensorless.cfg ] && rm $BASEDIR/pellcorp-backups/sensorless.cfg
[ -f $BASEDIR/pellcorp-backups/homing_override.cfg ] && rm $BASEDIR/pellcorp-backups/homing_override.cfg
[ -f $BASEDIR/printer_data/config/sensorless.cfg ] && rm $BASEDIR/printer_data/config/sensorless.cfg
[ -f $BASEDIR/printer_data/config/homing_override.cfg ] && rm $BASEDIR/printer_data/config/homing_override.cfg

fixup_client_variables_config
fixup_client_variables_config=$?
if [ $fixup_client_variables_config -eq 0 ]; then
Expand Down
Loading