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
@@ -91,6 +91,7 @@ date of first contribution):
|
||||
* [Ganey](https://github.com/ganey)
|
||||
* [Sven Lohrmann](https://github.com/malnvenshorn)
|
||||
* [Andy Castille](https://github.com/klikini)
|
||||
* [Gaston Dombiak](https://github.com/gdombiak)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -362,6 +362,8 @@ Issue a tool command
|
||||
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
|
||||
|
||||
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
||||
* ``speed``: Optional. Speed at which to extrude. If not provided, maximum speed for E axis from printer
|
||||
profile will be used. Otherwise interpreted as an integer signifying the speed in mm/s, to append to the command.
|
||||
|
||||
flowrate
|
||||
Changes the flow rate factor to apply to extrusion of the tool.
|
||||
|
||||
@@ -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