* Fix save 0 steps/mm- now it shows an error if steps<-0
This commit is contained in:
committed by
GitHub
parent
6a02270135
commit
29ff606e33
@@ -26,9 +26,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
|
||||
self._logger.debug("Load steps from EEPROM")
|
||||
if not self._printer.is_ready():
|
||||
self._logger.warning("Printer not ready, operation canceled")
|
||||
return flask.abort(503, {
|
||||
"msg": "Printer not ready, operation canceled"
|
||||
})
|
||||
return flask.abort(503, 'Printer not ready, operation canceled')
|
||||
|
||||
# Register listener waiting response for M92 command
|
||||
m92Event = Event()
|
||||
@@ -46,9 +44,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
|
||||
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, {
|
||||
"msg": "Printer not ready, operation canceled"
|
||||
})
|
||||
return flask.abort(503,"Printer not ready, operation canceled")
|
||||
|
||||
# Register event to be trigger when temp is achieved
|
||||
self.registerEventTemp("T0", int(data["extrudeTemp"]), self.startExtrusion, data["extrudeLength"], data["extrudeSpeed"])
|
||||
@@ -56,11 +52,12 @@ class API(octoprint.plugin.SimpleApiPlugin):
|
||||
self._printer.commands("M104 S%(extrudeTemp)s" % data)
|
||||
|
||||
if command == CMD_ESTEPS_SAVE:
|
||||
if "newESteps" not in data and ("newXSteps" not in data and "newYSteps" not in data and "newZSteps" not in data):
|
||||
return flask.abort(400, {
|
||||
"msg": "Invalid arguments. No value provided for X,Y, Z or E steps"
|
||||
})
|
||||
|
||||
if (("newESteps" not in data or data["newESteps"] <= 0)
|
||||
and
|
||||
(("newXSteps" not in data or data["newXSteps"] <= 0) or
|
||||
("newYSteps" not in data or data["newYSteps"] <= 0) or
|
||||
("newZSteps" not in data or data["newZSteps"] <= 0))):
|
||||
return flask.abort(400, "Invalid arguments. No value provided for X,Y, Z or E steps")
|
||||
stopHeater = []
|
||||
if "newESteps" in data:
|
||||
eStepsSettings = self._settings.get(['eSteps'])
|
||||
@@ -90,7 +87,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
|
||||
|
||||
@staticmethod
|
||||
def m92GCodeResponse(self, line, regex, event):
|
||||
reg = re.compile("echo:\s*(?P<command>(?P<gCode>M\d{1,3}) X(?P<xVal>\d{1,3}.\d{1,3}) Y(?P<yVal>\d{1,3}.\d{1,3}) Z(?P<zVal>\d{1,3}.\d{1,3}) E(?P<eVal>\d{1,3}.\d{1,3}))")
|
||||
reg = re.compile("(echo:?)\s*(?P<command>(?P<gCode>M\d{1,3}) X(?P<xVal>\d{1,3}.\d{1,3}) Y(?P<yVal>\d{1,3}.\d{1,3}) Z(?P<zVal>\d{1,3}.\d{1,3}) E(?P<eVal>\d{1,3}.\d{1,3}))")
|
||||
isM92command = reg.match(line)
|
||||
if isM92command:
|
||||
command = isM92command.group("command")
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
import traceback
|
||||
|
||||
import flask
|
||||
from werkzeug.exceptions import HTTPException
|
||||
|
||||
from octoprint_CalibrationTools import EStepsApi, PIDAutoTune
|
||||
|
||||
@@ -35,9 +36,7 @@ class API(EStepsApi.API, PIDAutoTune.API):
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.error(traceback.format_exc())
|
||||
return flask.abort(500, {
|
||||
"msg": "An error curred"
|
||||
})
|
||||
return flask.abort(500, "An error curred")
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
try:
|
||||
@@ -47,6 +46,9 @@ class API(EStepsApi.API, PIDAutoTune.API):
|
||||
return api["cls"].apiGateWay(self, command, data)
|
||||
except Exception as e:
|
||||
self._logger.error(traceback.format_exc())
|
||||
return flask.abort(500, {
|
||||
"msg": "An error curred"
|
||||
})
|
||||
exCode = 500
|
||||
exMessage = "An error curred"
|
||||
if isinstance(e, HTTPException):
|
||||
exCode = e.code
|
||||
exMessage = e.description
|
||||
return flask.abort(exCode, exMessage)
|
||||
|
||||
@@ -30,14 +30,14 @@ $(function () {
|
||||
self.results = {};
|
||||
self.results["remainedLength"] = ko.observable(20);
|
||||
self.results["actualExtrusion"] = ko.computed(function () {
|
||||
return (self.testParam.markLength() - self.results.remainedLength()).toFixed(3);
|
||||
return self.generalVM.round(self.testParam.markLength() - self.results.remainedLength());
|
||||
});
|
||||
self.results["newSteps"] = ko.computed(function () {
|
||||
return (self.steps.E() / self.results.actualExtrusion() * 100).toFixed(3);
|
||||
});
|
||||
self.results["newStepsDisplay"] = ko.computed(function () {
|
||||
return "M92 E" + self.results.newSteps();
|
||||
return self.generalVM.round(self.steps.E() / self.results.actualExtrusion() * 100);
|
||||
});
|
||||
// self.results["newStepsDisplay"] = ko.computed(function () {
|
||||
// return "M92 E" + self.results.newSteps();
|
||||
// });
|
||||
|
||||
self.onBeforeBinding = self.onUserLoggedIn = self.onUserLoggedOut = function () {
|
||||
self.testParam.extrudeTemp(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeTemp());
|
||||
@@ -70,18 +70,9 @@ $(function () {
|
||||
"extrudeLength": self.testParam.extrudeLength(),
|
||||
"extrudeSpeed": self.testParam.extrudeSpeed()
|
||||
}).done(function (response) {
|
||||
new PNotify({
|
||||
title: "E axe calibration started",
|
||||
text: "<span style='font-weight:bold; color: red;'>Heating nuzzle has started!!!</span><br> When extrusion stops you have to fulfil <b>Length after extrusion</b> and save the new value ",
|
||||
type: "warning"
|
||||
});
|
||||
self.generalVM.notifyWarning("E axe calibration started", "<span style='font-weight:bold; color: red;'>Heating nuzzle has started!!!</span><br> When extrusion stops you have to fulfil <b>Length after extrusion</b> and save the new value ")
|
||||
}).fail(function (response) {
|
||||
new PNotify({
|
||||
title: "Error on starting extrusion ",
|
||||
text: response.responseJSON.error,
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
self.generalVM.notifyError("Error on starting extrusion ", response.responseJSON.error);
|
||||
}).always(function (response) {
|
||||
self.startExtrusionActive(false);
|
||||
});
|
||||
@@ -91,12 +82,8 @@ $(function () {
|
||||
OctoPrint.simpleApiCommand("CalibrationTools", "eSteps_save", {
|
||||
"newESteps": self.results.newSteps()
|
||||
}).done(function () {
|
||||
new PNotify({
|
||||
title: "Saved",
|
||||
text: self.results.newSteps() + " steps/mm had been set for E axe",
|
||||
type: "info"
|
||||
});
|
||||
});
|
||||
self.generalVM.notifyInfo("Saved", self.results.newSteps() + " steps/mm had been set for E axe");
|
||||
}).fail(self.generalVM.failedFunction);
|
||||
}
|
||||
|
||||
self.onAllBound = self.onEventConnected = function () {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
$(function () {
|
||||
function CalibrationToolsGeneralViewModel(parameters) {
|
||||
this.loginState = parameters[0];
|
||||
this.decimal3 = function (defaultVal) {
|
||||
var self = this;
|
||||
self.decimal3 = function (defaultVal) {
|
||||
return {
|
||||
numeric: {
|
||||
decimals: 3,
|
||||
@@ -9,7 +10,7 @@ $(function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.isSmall = ko.observable($("#tab_plugin_CalibrationTools").width() < 800);
|
||||
self.isSmall = ko.observable($("#tab_plugin_CalibrationTools").width() < 800);
|
||||
ko.extenders.numeric = function (target, options) {
|
||||
var returnObs = ko.pureComputed({
|
||||
read: target,
|
||||
@@ -24,9 +25,33 @@ $(function () {
|
||||
return returnObs;
|
||||
};
|
||||
|
||||
this.onStartupComplete = function () {
|
||||
self.onStartupComplete = function () {
|
||||
this.isSmall($("#tabs_content").width() < 800);
|
||||
}
|
||||
self.notify = function (title, message, type, hide) {
|
||||
new PNotify({
|
||||
title: title,
|
||||
text: message,
|
||||
type: type,
|
||||
hide: hide
|
||||
});
|
||||
}
|
||||
self.notifyError = function (title, message) {
|
||||
self.notify(title, message, 'error', false);
|
||||
}
|
||||
self.notifyInfo = function (title, message) {
|
||||
self.notify(title, message, 'info', true);
|
||||
}
|
||||
self.notifyWarning = function (title, message) {
|
||||
self.notify(title, message, 'warning', false);
|
||||
}
|
||||
self.failedFunction = function (response) {
|
||||
self.notifyError("Error", response.responseJSON.error);
|
||||
}
|
||||
self.round = function (number, decimals) {
|
||||
decimals = decimals ? decimals : 3;
|
||||
return +(Math.round(number + ("e+" + decimals)) + ("e-" + decimals));
|
||||
}
|
||||
}
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
// This is the constructor to call for instantiating the plugin
|
||||
|
||||
@@ -51,14 +51,7 @@ $(function () {
|
||||
self.pidCurrentValues.bed.P(response.data.bed.P);
|
||||
self.pidCurrentValues.bed.I(response.data.bed.I);
|
||||
self.pidCurrentValues.bed.D(response.data.bed.D);
|
||||
}).fail(function (response) {
|
||||
new PNotify({
|
||||
title: "Error on getting current PID values ",
|
||||
text: response.responseJSON.error,
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
});
|
||||
}).fail(self.generalVM.failFunction);
|
||||
};
|
||||
|
||||
self.onBeforeBinding = self.onUserLoggedIn = self.onUserLoggedOut = function () {
|
||||
@@ -79,19 +72,8 @@ $(function () {
|
||||
"hotEndIndex": Number(self.pid.hotEnd.hotEndIndex()),
|
||||
"targetTemp": Number(self.pid.hotEnd.targetTemp())
|
||||
}).done(function (response) {
|
||||
new PNotify({
|
||||
title: "PID HotEnd tuning has started",
|
||||
text: "In progress",
|
||||
type: "info"
|
||||
});
|
||||
}).fail(function (response) {
|
||||
new PNotify({
|
||||
title: "Error on starting PID autotune ",
|
||||
text: response.responseJSON.error,
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
});
|
||||
self.generalVM.notifyWarning("PID HotEnd tuning has started", "In progress");
|
||||
}).fail(self.generalVM.failFunction);
|
||||
}
|
||||
self.startPidBed = function () {
|
||||
OctoPrint.simpleApiCommand("CalibrationTools", "pid_start", {
|
||||
@@ -101,19 +83,8 @@ $(function () {
|
||||
"hotEndIndex": -1,
|
||||
"targetTemp": self.pid.bed.targetTemp()
|
||||
}).done(function (response) {
|
||||
new PNotify({
|
||||
title: "PID HotEnd tuning has started",
|
||||
text: "In progress",
|
||||
type: "info"
|
||||
});
|
||||
}).fail(function (response) {
|
||||
new PNotify({
|
||||
title: "Error on starting PID autotune ",
|
||||
text: response.responseJSON.error,
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
});
|
||||
self.generalVM.notifyWarning("PID Heated bed tuning has started", "In progress");
|
||||
}).fail(self.generalVM.failFunction);
|
||||
}
|
||||
}
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
|
||||
@@ -33,15 +33,15 @@ $(function () {
|
||||
Z: ko.observable().extend(self.generalVM.decimal3(0.000))
|
||||
}
|
||||
};
|
||||
|
||||
// self.generalVM.decimal3(10.000)
|
||||
self.eStepsXYZ.newSteps.X = ko.computed(function () {
|
||||
return parseFloat(self.eStepsXYZ.currentSteps.X() * self.eStepsXYZ.gCodeCubeSize.X() / self.eStepsXYZ.printedCubeSize.X()).toFixed(3);
|
||||
return self.generalVM.round(self.eStepsXYZ.currentSteps.X() * self.eStepsXYZ.gCodeCubeSize.X() / self.eStepsXYZ.printedCubeSize.X());
|
||||
}, self);
|
||||
self.eStepsXYZ.newSteps.Y = ko.computed(function () {
|
||||
return parseFloat(self.eStepsXYZ.currentSteps.Y() * self.eStepsXYZ.gCodeCubeSize.Y() / self.eStepsXYZ.printedCubeSize.Y()).toFixed(3);
|
||||
return self.generalVM.round(self.eStepsXYZ.currentSteps.Y() * self.eStepsXYZ.gCodeCubeSize.Y() / self.eStepsXYZ.printedCubeSize.Y());
|
||||
}, self);
|
||||
self.eStepsXYZ.newSteps.Z = ko.computed(function () {
|
||||
return parseFloat(self.eStepsXYZ.currentSteps.Z() * self.eStepsXYZ.gCodeCubeSize.Z() / self.eStepsXYZ.printedCubeSize.Z()).toFixed(3);
|
||||
return self.generalVM.round(self.eStepsXYZ.currentSteps.Z() * self.eStepsXYZ.gCodeCubeSize.Z() / self.eStepsXYZ.printedCubeSize.Z());
|
||||
}, self);
|
||||
|
||||
self.loadEStepsActive = ko.observable(true);
|
||||
@@ -58,20 +58,17 @@ $(function () {
|
||||
|
||||
self.saveEStepsXYZActive = ko.observable(true)
|
||||
self.saveEStepsXYZ = function () {
|
||||
console.log(self.eStepsXYZ.newSteps.X());
|
||||
self.saveEStepsXYZActive(false);
|
||||
OctoPrint.simpleApiCommand("CalibrationTools", "eSteps_save", {
|
||||
"newXSteps": self.eStepsXYZ.newSteps.X(),
|
||||
"newYSteps": self.eStepsXYZ.newSteps.Y(),
|
||||
"newZSteps": self.eStepsXYZ.newSteps.Z()
|
||||
}).done(function (response) {
|
||||
new PNotify({
|
||||
title: "Saved",
|
||||
text: "X: " + self.eStepsXYZ.newSteps.X() + "steps/mm<br>Y: " + self.eStepsXYZ.newSteps.Y() + "steps/mm<br>Z: " + self.eStepsXYZ.newSteps.Z() + " steps/mm<br> had been set for X/Y/Z axes",
|
||||
type: "info"
|
||||
});
|
||||
self.generalVM.notifyInfo("Saved", "X: " + self.eStepsXYZ.newSteps.X() + "steps/mm<br>Y: " + self.eStepsXYZ.newSteps.Y() + "steps/mm<br>Z: " + self.eStepsXYZ.newSteps.Z() + " steps/mm<br> had been set for X/Y/Z axes");
|
||||
}).always(function (response) {
|
||||
self.saveEStepsXYZActive(true);
|
||||
})
|
||||
}).fail(self.generalVM.failedFunction)
|
||||
};
|
||||
|
||||
// self.labelColumnCss = viewModel.profitStatus = ko.pureComputed(function () {
|
||||
@@ -88,7 +85,6 @@ $(function () {
|
||||
self.eStepsXYZ.printedCubeSize.X(self.settingsViewModel.settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.X());
|
||||
self.eStepsXYZ.printedCubeSize.Y(self.settingsViewModel.settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.Y());
|
||||
self.eStepsXYZ.printedCubeSize.Z(self.settingsViewModel.settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.Z());
|
||||
|
||||
}
|
||||
}
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
|
||||
@@ -55,18 +55,8 @@
|
||||
self.restart = function () { OctoPrint.system.executeCommand('core', 'restart') };
|
||||
self.test = function () {
|
||||
OctoPrint.simpleApiCommand("CalibrationTools", "pid_save").done(function (response) {
|
||||
new PNotify({
|
||||
title: "Saved",
|
||||
text: "PID values successfully saved",
|
||||
type: "info"
|
||||
});
|
||||
}).fail(function (response) {
|
||||
new PNotify({
|
||||
title: "Test request",
|
||||
text: response.responseJSON.error.msg,
|
||||
type: "error"
|
||||
});
|
||||
});
|
||||
self.generalVM.notifyInfo("Saved", "PID values successfully saved");
|
||||
}).fail(self.generalVM.failFunction);;
|
||||
};
|
||||
|
||||
self.onSettingsClick = function () {
|
||||
|
||||
@@ -106,7 +106,8 @@ reliable.
|
||||
<div data-bind="class: $root.columnFieldCls()">
|
||||
<div class="input-prepend input-append">
|
||||
{{ snipped.linkToMarlin("M092", "Marlin website") }}
|
||||
<span class="add-on" title="Command to change number of steps/mm for E axe" data-bind="text: $root.results.newStepsDisplay"></span>
|
||||
<span class="add-on" title="Command to change number of steps/mm for E axe">M92 E</span>
|
||||
<input type="number" title="Command to change number of steps/mm for E axe" class="input-small numberDisplay" step="0.01" min="10" max="400" data-bind="value: $root.results.newSteps(), enable:false">
|
||||
{{ snipped.m500Icon() }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -80,7 +80,7 @@ sized.","<a href='https://teachingtechyt.github.io/calibration.html#xyzsteps' ta
|
||||
<div class="input-prepend input-append">
|
||||
{{ snipped.linkToMarlin("M092", "Marlin website") }}
|
||||
<span class="add-on" title="">M92 X</span>
|
||||
<input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.X">
|
||||
<input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.X()">
|
||||
<span class="add-on" title=""> Y</span>
|
||||
<input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.Y">
|
||||
<span class="add-on" title=""> Z</span>
|
||||
|
||||
Reference in New Issue
Block a user