diff --git a/octoprint_CalibrationTools/api.py b/octoprint_CalibrationTools/api.py
index 4e22888..28556fd 100644
--- a/octoprint_CalibrationTools/api.py
+++ b/octoprint_CalibrationTools/api.py
@@ -11,6 +11,7 @@ CMD_LOAD_STEPS = "loadSteps"
CMD_START_EXTRUSION = "startExtrusion"
CMD_SAVE_E_STEPS = "saveESteps"
+
class API(octoprint.plugin.SimpleApiPlugin):
@staticmethod
def get_api_commands():
@@ -52,7 +53,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
})
if command == CMD_START_EXTRUSION:
- self._logger.debug("Heating the tools")
+ self._logger.debug("Heating the extruder [%s]", data)
if not self._printer.is_ready():
self._logger.warning("Printer not ready, operation canceled")
return flask.abort(503, {
@@ -60,14 +61,18 @@ class API(octoprint.plugin.SimpleApiPlugin):
})
# Register event to be trigger when temp is achieved
- self.registerEventTemp("T0", 180, self.startExtrusion)
+ self.registerEventTemp("T0", int(data["extrudeTemp"]), self.startExtrusion, data["extrudeLength"], data["extrudeSpeed"])
# Heating the tool
- self._printer.commands("M104 S180")
+ self._printer.commands("M104 S%(extrudeTemp)s" % data)
return
if command == CMD_SAVE_E_STEPS:
- self._printer.commands(["M92 E%(newESteps)s" % data, "M500"])
+ cmds = ["M92 E%(newESteps)s" % data, "M500"]
+ if self.
+ cmds = cmds + ["M104 S0"]
+ self._printer.commands()
+
return
if command == CMD_TEST:
@@ -76,11 +81,12 @@ class API(octoprint.plugin.SimpleApiPlugin):
############## HANDLERS ##############
@staticmethod
- def startExtrusion(self, temps, *args):
- self._logger.debug("Temperature achieved, extrusion started %s, %s", temps, args)
+ def startExtrusion(self, temps, extrudeLength, extrudeSpeed, *args):
+ self._logger.debug("Temperature achieved, extrusion started [temps:%s, extrudeLength:%s, extrudeSpeed:%s, args:%s]",
+ temps, extrudeLength, extrudeSpeed, args)
# Extrude
- self._printer.extrude(amount=120, speed=50)
+ self._printer.extrude(amount=int(extrudeLength), speed=int(extrudeSpeed))
@staticmethod
def m92GCodeResponse(self, line, event):
@@ -100,4 +106,4 @@ class API(octoprint.plugin.SimpleApiPlugin):
self._logger.debug("Finished data collection")
self.collectCommand = False
if event:
- event.set()
\ No newline at end of file
+ event.set()
diff --git a/octoprint_CalibrationTools/hooks.py b/octoprint_CalibrationTools/hooks.py
index 28e4917..1738668 100644
--- a/octoprint_CalibrationTools/hooks.py
+++ b/octoprint_CalibrationTools/hooks.py
@@ -62,6 +62,7 @@ class Hooks():
self.events.remove(event)
# Registering a temp event
+ # Trigger a function when the temparature
def registerEventTemp(self, tool, targetTemp, func, *arguments):
if func is None or not isinstance(func, collections.Callable):
self._logger.warn("registerEventTemp: Attempt to register event without a function")
diff --git a/octoprint_CalibrationTools/static/js/CalibrationTools.js b/octoprint_CalibrationTools/static/js/CalibrationTools.js
index 475eb5a..a259c44 100644
--- a/octoprint_CalibrationTools/static/js/CalibrationTools.js
+++ b/octoprint_CalibrationTools/static/js/CalibrationTools.js
@@ -62,15 +62,25 @@ $(function () {
}
self.startExtrusion = function () {
- OctoPrint.simpleApiCommand("CalibrationTools", "startExtrusion").done(function (response) {
+ OctoPrint.simpleApiCommand("CalibrationTools", "startExtrusion", {
+ "extrudeTemp": self.testParam.extrudeTemp(),
+ "extrudeLength": self.testParam.extrudeLength(),
+ "extrudeSpeed": self.testParam.extrudeSpeed()
+ }).done(function (response) {
new PNotify({
title: "E axe calibration started",
text: "Heating nuzzle has started!!!
When extrusion stops you have to fulfil Length after extrusion and save the new value ",
- type: "warning",
- hide: false
+ type: "warning"
});
console.log(response);
- })
+ }).fail(function (response) {
+ new PNotify({
+ title: "Error on starting extrusion ",
+ text: response.responseJSON.error,
+ type: "error",
+ hide: false
+ });
+ })
}
self.tempRestart = function () {