gcode: Remove builtin T0/T1/T2/... command support

The builtin Tn command is not sufficiently flexible to control some
multi-extruder printers.  Remove the command and encourage users to
define individual gcode_macros for each Tn instance.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-24 19:59:36 -05:00
parent c06618193d
commit fcee27fc19
6 changed files with 24 additions and 58 deletions

View File

@ -677,19 +677,6 @@
# config section should define the heater and the extruder4 section # config section should define the heater and the extruder4 section
# should specify "shared_heater: extruder3". The default is to not # should specify "shared_heater: extruder3". The default is to not
# reuse an existing heater. # reuse an existing heater.
#deactivate_gcode:
# A list of G-Code commands to execute on a G-Code tool change
# command (eg, "T1") that deactivates this extruder and activates
# some other extruder. See docs/Command_Templates.md for G-Code
# format. It only makes sense to define this section on
# multi-extruder printers. The default is to not run any special
# G-Code commands on deactivation.
#activate_gcode:
# A list of G-Code commands to execute on a G-Code tool change
# command (eg, "T0") that activates this extruder. See
# docs/Command_Templates.md for G-Code format. It only makes sense
# to define this section on multi-extruder printers. The default is
# to not run any special G-Code commands on activation.
# Support for cartesian printers with dual carriages on a single # Support for cartesian printers with dual carriages on a single
# axis. The active carriage is set via the SET_DUAL_CARRIAGE extended # axis. The active carriage is set via the SET_DUAL_CARRIAGE extended

View File

@ -6,6 +6,12 @@ All dates in this document are approximate.
# Changes # Changes
20191210: The builtin T0, T1, T2, ... commands have been removed. The
extruder activate_gcode and deactivate_gcode config options have been
removed. If these commands (and scripts) are needed then define
individual [gcode_macro T0] style macros that call the
ACTIVATE_EXTRUDER command.
20191210: Support for the M206 command has been removed. Replace with 20191210: Support for the M206 command has been removed. Replace with
calls to SET_GCODE_OFFSET. If support for M206 is needed, add a calls to SET_GCODE_OFFSET. If support for M206 is needed, add a
[gcode_macro M206] config section that calls SET_GCODE_OFFSET. (For [gcode_macro M206] config section that calls SET_GCODE_OFFSET. (For

View File

@ -9,7 +9,6 @@ Klipper supports the following standard G-Code commands:
- Move to origin: `G28 [X] [Y] [Z]` - Move to origin: `G28 [X] [Y] [Z]`
- Turn off motors: `M18` or `M84` - Turn off motors: `M18` or `M84`
- Wait for current moves to finish: `M400` - Wait for current moves to finish: `M400`
- Select tool: `T<index>`
- Use absolute/relative distances for extrusion: `M82`, `M83` - Use absolute/relative distances for extrusion: `M82`, `M83`
- Use absolute/relative coordinates: `G90`, `G91` - Use absolute/relative coordinates: `G90`, `G91`
- Set position: `G92 [X<pos>] [Y<pos>] [Z<pos>] [E<pos>]` - Set position: `G92 [X<pos>] [Y<pos>] [Z<pos>] [E<pos>]`
@ -44,7 +43,7 @@ If one requires a less common G-Code command then it may be possible
to implement it with a custom Klipper gcode_macro (see to implement it with a custom Klipper gcode_macro (see
[example-extras.cfg](https://github.com/KevinOConnor/klipper/tree/master/config/example-extras.cfg) [example-extras.cfg](https://github.com/KevinOConnor/klipper/tree/master/config/example-extras.cfg)
for details). For example, one might use this to implement: `G12`, for details). For example, one might use this to implement: `G12`,
`G29`, `G30`, `G31`, `M42`, `M80`, `M81`, etc. `G29`, `G30`, `G31`, `M42`, `M80`, `M81`, `T1`, etc.
## G-Code SD card commands ## G-Code SD card commands

View File

@ -433,11 +433,7 @@ class GCodeParser:
if not cmd: if not cmd:
logging.debug(params['#original']) logging.debug(params['#original'])
return return
if cmd[0] == 'T' and len(cmd) > 1 and cmd[1].isdigit(): if cmd.startswith("M117 "):
# Tn command has to be handled specially
self.cmd_Tn(params)
return
elif cmd.startswith("M117 "):
# Handle M117 gcode with numeric and special characters # Handle M117 gcode with numeric and special characters
handler = self.gcode_handlers.get("M117", None) handler = self.gcode_handlers.get("M117", None)
if handler is not None: if handler is not None:
@ -448,27 +444,6 @@ class GCodeParser:
# Don't warn about requests to turn off fan when fan not present # Don't warn about requests to turn off fan when fan not present
return return
self.respond_info('Unknown command:"%s"' % (cmd,)) self.respond_info('Unknown command:"%s"' % (cmd,))
def cmd_Tn(self, params):
# Select Tool
index = self.get_int('T', params, minval=0)
section = 'extruder'
if index:
section = 'extruder%d' % (index,)
new_extruder = self.printer.lookup_object(section, None)
if new_extruder is None:
raise self.error("Unknown extruder %d on Tn command" % (index,))
old_extruder = self.toolhead.get_extruder()
if old_extruder is new_extruder:
return
self.run_script_from_command(old_extruder.get_activate_gcode(False))
print_time = self.toolhead.get_last_move_time()
old_extruder.set_active(print_time, False)
extrude_pos = new_extruder.set_active(print_time, True)
self.toolhead.set_extruder(new_extruder, extrude_pos)
self.reset_last_position()
self.extrude_factor = 1.
self.base_position[3] = self.last_position[3]
self.run_script_from_command(new_extruder.get_activate_gcode(True))
def _cmd_mux(self, params): def _cmd_mux(self, params):
key, values = self.mux_commands[params['#command']] key, values = self.mux_commands[params['#command']]
if None in values: if None in values:

View File

@ -41,11 +41,6 @@ class PrinterExtruder:
'max_extrude_only_distance', 50., minval=0.) 'max_extrude_only_distance', 50., minval=0.)
self.instant_corner_v = config.getfloat( self.instant_corner_v = config.getfloat(
'instantaneous_corner_velocity', 1., minval=0.) 'instantaneous_corner_velocity', 1., minval=0.)
gcode_macro = self.printer.try_load_module(config, 'gcode_macro')
self.activate_gcode = gcode_macro.load_template(
config, 'activate_gcode', '')
self.deactivate_gcode = gcode_macro.load_template(
config, 'deactivate_gcode', '')
self.pressure_advance = self.pressure_advance_smooth_time = 0. self.pressure_advance = self.pressure_advance_smooth_time = 0.
pressure_advance = config.getfloat('pressure_advance', 0., minval=0.) pressure_advance = config.getfloat('pressure_advance', 0., minval=0.)
smooth_time = config.getfloat('pressure_advance_smooth_time', smooth_time = config.getfloat('pressure_advance_smooth_time',
@ -99,12 +94,6 @@ class PrinterExtruder:
return self.name return self.name
def get_heater(self): def get_heater(self):
return self.heater return self.heater
def set_active(self, print_time, is_active):
return self.extrude_pos
def get_activate_gcode(self, is_active):
if is_active:
return self.activate_gcode.render()
return self.deactivate_gcode.render()
def stats(self, eventtime): def stats(self, eventtime):
return self.heater.stats(eventtime) return self.heater.stats(eventtime)
def check_move(self, move): def check_move(self, move):
@ -184,8 +173,6 @@ class PrinterExtruder:
# Dummy extruder class used when a printer has no extruder at all # Dummy extruder class used when a printer has no extruder at all
class DummyExtruder: class DummyExtruder:
def set_active(self, print_time, is_active):
return 0.
def update_move_time(self, flush_time): def update_move_time(self, flush_time):
pass pass
def check_move(self, move): def check_move(self, move):

View File

@ -55,10 +55,16 @@ pid_Ki: 1.08
pid_Kd: 114 pid_Kd: 114
min_temp: 0 min_temp: 0
max_temp: 250 max_temp: 250
deactivate_gcode:
[gcode_macro PARK_extruder0]
gcode:
G90 G90
G1 X0 G1 X0
activate_gcode:
[gcode_macro T0]
gcode:
PARK_{printer.toolhead.extruder}
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_DUAL_CARRIAGE CARRIAGE=0 SET_DUAL_CARRIAGE CARRIAGE=0
[extruder1] [extruder1]
@ -77,12 +83,18 @@ pid_Ki: 1.08
pid_Kd: 114 pid_Kd: 114
min_temp: 0 min_temp: 0
max_temp: 250 max_temp: 250
deactivate_gcode:
[gcode_macro PARK_extruder1]
gcode:
SET_SERVO SERVO=my_servo angle=100 SET_SERVO SERVO=my_servo angle=100
G90 G90
G1 X200 G1 X200
activate_gcode:
[gcode_macro T1]
gcode:
PARK_{printer.toolhead.extruder}
SET_SERVO SERVO=my_servo angle=50 SET_SERVO SERVO=my_servo angle=50
ACTIVATE_EXTRUDER EXTRUDER=extruder1
SET_DUAL_CARRIAGE CARRIAGE=1 SET_DUAL_CARRIAGE CARRIAGE=1
[servo my_servo] [servo my_servo]