aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Smith <davidosmith@gmail.com>2020-03-28 09:52:46 -0400
committerGitHub <noreply@github.com>2020-03-28 09:52:46 -0400
commitd4bf61262e6f78b5366fe368b3d4ec1dcbc82f60 (patch)
treeeb67b23c7079bb7e106dcd92d4f0c7f6dc3919dc
parent8f8cf7ef4151adab8f1122bf6b61c185575f32f6 (diff)
downloadkutter-d4bf61262e6f78b5366fe368b3d4ec1dcbc82f60.tar.gz
kutter-d4bf61262e6f78b5366fe368b3d4ec1dcbc82f60.tar.xz
kutter-d4bf61262e6f78b5366fe368b3d4ec1dcbc82f60.zip
Extruder: Add g-code to set extruder step_distance (#2598)
Signed off by: David Smith <davidosmith@gmail.com>
-rw-r--r--docs/G-Codes.md6
-rw-r--r--klippy/kinematics/extruder.py17
-rw-r--r--klippy/stepper.py4
3 files changed, 27 insertions, 0 deletions
diff --git a/docs/G-Codes.md b/docs/G-Codes.md
index 076e31c6..c8edd792 100644
--- a/docs/G-Codes.md
+++ b/docs/G-Codes.md
@@ -162,6 +162,12 @@ The following standard commands are supported:
[SMOOTH_TIME=<pressure_advance_smooth_time>]`: Set pressure advance
parameters. If EXTRUDER is not specified, it defaults to the active
extruder.
+- `SET_EXTRUDER_STEP_DISTANCE [EXTRUDER=<config_name>] [DISTANCE=<distance>]`:
+ Set a new value for the provided extruder's step_distance. Value is
+ not retained on Klipper reset. Use with caution, small changes can
+ result in excessive pressure between extruder and hot end. Do proper
+ calibration steps with filament before use. If 'DISTANCE' value is
+ not included command will return current step distance.
- `SET_STEPPER_ENABLE STEPPER=<config_name> ENABLE=[0|1]`: Enable or
disable only the given stepper. This is a diagnostic and debugging
tool and must be used with care. Disabling an axis motor does not
diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py
index b4450596..f0264e1e 100644
--- a/klippy/kinematics/extruder.py
+++ b/klippy/kinematics/extruder.py
@@ -72,6 +72,9 @@ class PrinterExtruder:
gcode.register_mux_command("ACTIVATE_EXTRUDER", "EXTRUDER",
self.name, self.cmd_ACTIVATE_EXTRUDER,
desc=self.cmd_ACTIVATE_EXTRUDER_help)
+ gcode.register_mux_command("SET_EXTRUDER_STEP_DISTANCE", "EXTRUDER",
+ self.name, self.cmd_SET_E_STEP_DISTANCE,
+ desc=self.cmd_SET_E_STEP_DISTANCE_help)
def update_move_time(self, flush_time):
self.trapq_free_moves(self.trapq, flush_time)
def _set_pressure_advance(self, pressure_advance, smooth_time):
@@ -185,6 +188,20 @@ class PrinterExtruder:
pressure_advance, smooth_time))
self.printer.set_rollover_info(self.name, "%s: %s" % (self.name, msg))
gcode.respond_info(msg, log=False)
+ cmd_SET_E_STEP_DISTANCE_help = "Set extruder step distance"
+ def cmd_SET_E_STEP_DISTANCE(self, params):
+ gcode = self.printer.lookup_object('gcode')
+ toolhead = self.printer.lookup_object('toolhead')
+ if 'DISTANCE' not in params:
+ step_dist = self.stepper.get_step_dist()
+ gcode.respond_info("%s E step distance: %f" % (self.name, step_dist))
+ return
+ dist = gcode.get_float('DISTANCE', params, 0.)
+ toolhead.flush_step_generation()
+ self.stepper.set_step_dist(self.sk_extruder, dist)
+ step_dist = self.stepper.get_step_dist()
+ gcode.respond_info("%s E step distance set: %f" %
+ (self.name, step_dist))
cmd_ACTIVATE_EXTRUDER_help = "Change the active extruder"
def cmd_ACTIVATE_EXTRUDER(self, params):
gcode = self.printer.lookup_object('gcode')
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 747e74b3..bbe57ca5 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -94,6 +94,10 @@ class MCU_stepper:
return self._oid
def get_step_dist(self):
return self._step_dist
+ def set_step_dist(self, sk, dist):
+ self._step_dist = dist
+ self.set_stepper_kinematics(sk)
+ logging.info("%s manually set to =%.6f", (self._name, dist))
def is_dir_inverted(self):
return self._invert_dir
def calc_position_from_coord(self, coord):