Added support to specify extrude/retract speed. Only at REST API. No UI changes were made
This commit is contained in:
1 parent
2f89082df2
commit
00aa4876e9
5 files changed
+17
-4
No files matched your search
@@ -231,12 +231,14 @@ class PrinterInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def extrude(self, amount, tags=None, *args, **kwargs):
|
||||
def extrude(self, amount, speed=None, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Extrude ``amount`` millimeters of material from the tool.
|
||||
|
||||
Arguments:
|
||||
amount (int, float): The amount of material to extrude in mm
|
||||
speed (int, None): Speed at which to extrude (F parameter). If set to ``None`` (or left out)
|
||||
the maximum speed of E axis from the printer profile will be used.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -361,12 +361,19 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), validated_axes)), "G90"],
|
||||
tags=kwargs.get("tags", set) | {"trigger:printer.home"})
|
||||
|
||||
def extrude(self, amount, *args, **kwargs):
|
||||
def extrude(self, amount, speed=None, *args, **kwargs):
|
||||
if not isinstance(amount, (int, long, float)):
|
||||
raise ValueError("amount must be a valid number: {amount}".format(amount=amount))
|
||||
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
extrusion_speed = printer_profile["axes"]["e"]["speed"]
|
||||
|
||||
# Use specified speed (if any)
|
||||
extrusion_speed = speed
|
||||
|
||||
if speed is None:
|
||||
# No speed was specified so default to value configured in printer profile
|
||||
extrusion_speed = printer_profile["axes"]["e"]["speed"]
|
||||
|
||||
self.commands(["G91", "G1 E%s F%d" % (amount, extrusion_speed), "G90"],
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.extrude"})
|
||||
|
||||
|
||||
@@ -129,9 +129,10 @@ def printerToolCommand():
|
||||
return make_response("Printer is currently printing", 409)
|
||||
|
||||
amount = data["amount"]
|
||||
speed = data.get("speed", None)
|
||||
if not isinstance(amount, (int, long, float)):
|
||||
return make_response("Not a number for extrusion amount: %r" % amount, 400)
|
||||
printer.extrude(amount, tags=tags)
|
||||
printer.extrude(amount, speed=speed, tags=tags)
|
||||
|
||||
elif command == "flowrate":
|
||||
factor = data["factor"]
|
||||
|
||||
Reference in new issue
Block a user