mirror of https://github.com/Desuuuu/klipper.git
stepper_enable: Add SET_STEPPER_ENABLE gcode command (#2463)
Signed-off-by: David Smith <davidosmith@gmail.com>
This commit is contained in:
parent
7d76067ff9
commit
596f5e3e3a
|
@ -161,6 +161,12 @@ The following standard commands are supported:
|
||||||
[SMOOTH_TIME=<pressure_advance_smooth_time>]`: Set pressure advance
|
[SMOOTH_TIME=<pressure_advance_smooth_time>]`: Set pressure advance
|
||||||
parameters. If EXTRUDER is not specified, it defaults to the active
|
parameters. If EXTRUDER is not specified, it defaults to the active
|
||||||
extruder.
|
extruder.
|
||||||
|
- `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
|
||||||
|
reset the homing information. Manually moving a disabled stepper may
|
||||||
|
cause the machine to operate the motor outside of safe limits. This
|
||||||
|
can lead to damage to axis components, hot ends, and print surface.
|
||||||
- `STEPPER_BUZZ STEPPER=<config_name>`: Move the given stepper forward
|
- `STEPPER_BUZZ STEPPER=<config_name>`: Move the given stepper forward
|
||||||
one mm and then backward one mm, repeated 10 times. This is a
|
one mm and then backward one mm, repeated 10 times. This is a
|
||||||
diagnostic tool to help verify stepper connectivity.
|
diagnostic tool to help verify stepper connectivity.
|
||||||
|
|
|
@ -74,9 +74,12 @@ class PrinterStepperEnable:
|
||||||
self.printer.register_event_handler("gcode:request_restart",
|
self.printer.register_event_handler("gcode:request_restart",
|
||||||
self._handle_request_restart)
|
self._handle_request_restart)
|
||||||
# Register M18/M84 commands
|
# Register M18/M84 commands
|
||||||
gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
gcode.register_command("M18", self.cmd_M18)
|
self.gcode.register_command("M18", self.cmd_M18)
|
||||||
gcode.register_command("M84", self.cmd_M18)
|
self.gcode.register_command("M84", self.cmd_M18)
|
||||||
|
self.gcode.register_command("SET_STEPPER_ENABLE",
|
||||||
|
self.cmd_SET_STEPPER_ENABLE,
|
||||||
|
desc = self.cmd_SET_STEPPER_ENABLE_help)
|
||||||
def register_stepper(self, stepper, pin):
|
def register_stepper(self, stepper, pin):
|
||||||
name = stepper.get_name()
|
name = stepper.get_name()
|
||||||
self.enable_lines[name] = EnableTracking(self.printer, stepper, pin)
|
self.enable_lines[name] = EnableTracking(self.printer, stepper, pin)
|
||||||
|
@ -89,11 +92,33 @@ class PrinterStepperEnable:
|
||||||
self.printer.send_event("stepper_enable:motor_off", print_time)
|
self.printer.send_event("stepper_enable:motor_off", print_time)
|
||||||
toolhead.dwell(DISABLE_STALL_TIME)
|
toolhead.dwell(DISABLE_STALL_TIME)
|
||||||
logging.debug('; Max time of %f', print_time)
|
logging.debug('; Max time of %f', print_time)
|
||||||
|
def motor_debug_enable(self, stepper=None, enable=1):
|
||||||
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
toolhead.dwell(DISABLE_STALL_TIME)
|
||||||
|
print_time = toolhead.get_last_move_time()
|
||||||
|
if stepper in self.enable_lines:
|
||||||
|
el = self.enable_lines.get(stepper, "")
|
||||||
|
if enable:
|
||||||
|
el.motor_enable(print_time)
|
||||||
|
logging.info("%s has been manually enabled", stepper)
|
||||||
|
else:
|
||||||
|
el.motor_disable(print_time)
|
||||||
|
logging.info("%s has been manually disabled", stepper)
|
||||||
|
else:
|
||||||
|
self.gcode.respond_info('SET_STEPPER_ENABLE: Invalid stepper "%s"'
|
||||||
|
% (stepper))
|
||||||
|
toolhead.dwell(DISABLE_STALL_TIME)
|
||||||
|
logging.debug('; Max time of %f', print_time)
|
||||||
def _handle_request_restart(self, print_time):
|
def _handle_request_restart(self, print_time):
|
||||||
self.motor_off()
|
self.motor_off()
|
||||||
def cmd_M18(self, params):
|
def cmd_M18(self, params):
|
||||||
# Turn off motors
|
# Turn off motors
|
||||||
self.motor_off()
|
self.motor_off()
|
||||||
|
cmd_SET_STEPPER_ENABLE_help = "Enable/disable individual stepper by name"
|
||||||
|
def cmd_SET_STEPPER_ENABLE(self, params):
|
||||||
|
stepper_name = self.gcode.get_str('STEPPER', params, None)
|
||||||
|
stepper_enable = self.gcode.get_int('ENABLE', params, 1)
|
||||||
|
self.motor_debug_enable(stepper_name, stepper_enable)
|
||||||
def lookup_enable(self, name):
|
def lookup_enable(self, name):
|
||||||
if name not in self.enable_lines:
|
if name not in self.enable_lines:
|
||||||
raise self.printer.config_error("Unknown stepper '%s'" % (name,))
|
raise self.printer.config_error("Unknown stepper '%s'" % (name,))
|
||||||
|
|
Loading…
Reference in New Issue