Skip to content

Commit

Permalink
Extruder: Add g-code to set extruder step_distance (#2598)
Browse files Browse the repository at this point in the history
Signed off by: David Smith <[email protected]>
  • Loading branch information
ld3300 authored Mar 28, 2020
1 parent 8f8cf7e commit d4bf612
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __init__(self, config, extruder_num):
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):
Expand Down Expand Up @@ -185,6 +188,20 @@ def cmd_SET_PRESSURE_ADVANCE(self, params):
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')
Expand Down
4 changes: 4 additions & 0 deletions klippy/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def get_oid(self):
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):
Expand Down

0 comments on commit d4bf612

Please sign in to comment.