extruder: Fix SET_PRESSURE_ADVANCE so that it works with multiple extruders

Use the new gcode.register_mux_command() so that SET_PRESSURE_ADVANCE
works correctly with multiple extruders.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-05-20 12:52:19 -04:00
parent 75a1e9ea21
commit 2ab47cd20c
3 changed files with 16 additions and 5 deletions

View File

@ -84,9 +84,10 @@ The following standard commands are supported:
[ACCEL_TO_DECEL=<value>] [JUNCTION_DEVIATION=<value>]`: Modify the
printer's velocity limits. Note that one may only set values less
than or equal to the limits specified in the config file.
- `SET_PRESSURE_ADVANCE [ADVANCE=<pressure_advance>]
- `SET_PRESSURE_ADVANCE [EXTRUDER=<config_name>] [ADVANCE=<pressure_advance>]
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
Set pressure advance parameters.
Set pressure advance parameters. If EXTRUDER is not specified, it
defaults to the active extruder.
- `RESTART`: This will cause the host software to reload its config
and perform an internal reset. This command will not clear error
state from the micro-controller (see FIRMWARE_RESTART) nor will it

View File

@ -46,8 +46,13 @@ class PrinterExtruder:
'pressure_advance_lookahead_time', 0.010, minval=0.)
self.need_motor_enable = True
self.extrude_pos = 0.
self.printer.lookup_object('gcode').register_command(
"SET_PRESSURE_ADVANCE", self.cmd_SET_PRESSURE_ADVANCE,
gcode = self.printer.lookup_object('gcode')
if self.name in ('extruder', 'extruder0'):
gcode.register_mux_command("SET_PRESSURE_ADVANCE", "EXTRUDER", None,
self.cmd_default_SET_PRESSURE_ADVANCE,
desc=self.cmd_SET_PRESSURE_ADVANCE_help)
gcode.register_mux_command("SET_PRESSURE_ADVANCE", "EXTRUDER", self.name,
self.cmd_SET_PRESSURE_ADVANCE,
desc=self.cmd_SET_PRESSURE_ADVANCE_help)
def get_heater(self):
return self.heater
@ -225,6 +230,9 @@ class PrinterExtruder:
start_pos -= retract_d
self.extrude_pos = start_pos
cmd_SET_PRESSURE_ADVANCE_help = "Set pressure advance parameters"
def cmd_default_SET_PRESSURE_ADVANCE(self, params):
extruder = self.printer.lookup_object('toolhead').get_extruder()
extruder.cmd_SET_PRESSURE_ADVANCE(params)
def cmd_SET_PRESSURE_ADVANCE(self, params):
self.printer.lookup_object('toolhead').get_last_move_time()
gcode = self.printer.lookup_object('gcode')

View File

@ -372,6 +372,8 @@ class ToolHead:
self.extruder = extruder
self.move_queue.set_extruder(extruder)
self.commanded_pos[3] = extrude_pos
def get_extruder(self):
return self.extruder
# Misc commands
def stats(self, eventtime):
for m in self.all_mcus: