This commit is contained in:
minicx 2025-12-22 17:32:59 +01:00 committed by GitHub
commit 03119d46f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View file

@ -459,6 +459,13 @@ parameters of an extruder stepper (as defined in an
If EXTRUDER is not specified, it defaults to the stepper defined in
the active hotend.
#### SET_NOZZLE_DIAMETER
`SET_NOZZLE_DIAMETER [EXTRUDER=<config_name>] DIAMETER=<diameter>`:
Set a new value for the nozzle diameter of the specified extruder
(as defined in an [extruder](Config_Reference.md#extruder) config section).
If EXTRUDER is not specified, it defaults to the active hotend.
Changed settings are not retained on Klipper reset.
#### SET_EXTRUDER_ROTATION_DISTANCE
`SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=<config_name>
[DISTANCE=<distance>]`: Set a new value for the provided extruder

View file

@ -186,9 +186,15 @@ class PrinterExtruder:
toolhead.set_extruder(self, 0.)
gcode.register_command("M104", self.cmd_M104)
gcode.register_command("M109", self.cmd_M109)
gcode.register_mux_command("SET_NOZZLE_DIAMETER", "EXTRUDER", None,
self.cmd_default_SET_NOZZLE_DIAMETER,
desc=self.cmd_SET_NOZZLE_DIAMETER_help)
gcode.register_mux_command("ACTIVATE_EXTRUDER", "EXTRUDER",
self.name, self.cmd_ACTIVATE_EXTRUDER,
desc=self.cmd_ACTIVATE_EXTRUDER_help)
gcode.register_mux_command("SET_NOZZLE_DIAMETER", "EXTRUDER",
self.name, self.cmd_SET_NOZZLE_DIAMETER,
desc=self.cmd_SET_NOZZLE_DIAMETER_help)
def get_status(self, eventtime):
sts = self.heater.get_status(eventtime)
sts['can_extrude'] = self.heater.can_extrude
@ -287,6 +293,25 @@ class PrinterExtruder:
toolhead.flush_step_generation()
toolhead.set_extruder(self, self.last_position)
self.printer.send_event("extruder:activate_extruder")
cmd_SET_NOZZLE_DIAMETER_help = "Set nozzle diameter"
def cmd_default_SET_NOZZLE_DIAMETER(self, gcmd):
extruder = self.printer.lookup_object('toolhead').get_extruder()
extruder.cmd_SET_NOZZLE_DIAMETER(gcmd)
def cmd_SET_NOZZLE_DIAMETER(self, gcmd):
diameter = gcmd.get_float('DIAMETER', above=.0)
toolhead = self.printer.lookup_object('toolhead')
toolhead.flush_step_generation()
self.nozzle_diameter = diameter
def_max_cross_section = 4. * self.nozzle_diameter**2
self.max_extrude_ratio = def_max_cross_section / self.filament_area
logging.info("Nozzle diameter changed to %.2f, max_extrude_ratio=%.6f",
self.nozzle_diameter, self.max_extrude_ratio)
gcmd.respond_info("Nozzle diameter set to %.2fmm\n"
"Max extrude ratio: %.6f"
% (diameter, self.max_extrude_ratio))
# Dummy extruder class used when a printer has no extruder at all
class DummyExtruder: