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 [ACCEL_TO_DECEL=<value>] [JUNCTION_DEVIATION=<value>]`: Modify the
printer's velocity limits. Note that one may only set values less printer's velocity limits. Note that one may only set values less
than or equal to the limits specified in the config file. 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>]`: [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 - `RESTART`: This will cause the host software to reload its config
and perform an internal reset. This command will not clear error and perform an internal reset. This command will not clear error
state from the micro-controller (see FIRMWARE_RESTART) nor will it state from the micro-controller (see FIRMWARE_RESTART) nor will it

View File

@ -46,9 +46,14 @@ class PrinterExtruder:
'pressure_advance_lookahead_time', 0.010, minval=0.) 'pressure_advance_lookahead_time', 0.010, minval=0.)
self.need_motor_enable = True self.need_motor_enable = True
self.extrude_pos = 0. self.extrude_pos = 0.
self.printer.lookup_object('gcode').register_command( gcode = self.printer.lookup_object('gcode')
"SET_PRESSURE_ADVANCE", self.cmd_SET_PRESSURE_ADVANCE, if self.name in ('extruder', 'extruder0'):
desc=self.cmd_SET_PRESSURE_ADVANCE_help) 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): def get_heater(self):
return self.heater return self.heater
def set_active(self, print_time, is_active): def set_active(self, print_time, is_active):
@ -225,6 +230,9 @@ class PrinterExtruder:
start_pos -= retract_d start_pos -= retract_d
self.extrude_pos = start_pos self.extrude_pos = start_pos
cmd_SET_PRESSURE_ADVANCE_help = "Set pressure advance parameters" 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): def cmd_SET_PRESSURE_ADVANCE(self, params):
self.printer.lookup_object('toolhead').get_last_move_time() self.printer.lookup_object('toolhead').get_last_move_time()
gcode = self.printer.lookup_object('gcode') gcode = self.printer.lookup_object('gcode')

View File

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