Fix issue #7 (#10)

* Fix save 0 steps/mm- now it shows an error if steps<-0
This commit is contained in:
Sergiu Toporjinschi
2022-02-14 22:57:26 +02:00
committed by GitHub
parent 6a02270135
commit 29ff606e33
16 changed files with 75 additions and 216 deletions
+3 -3
View File
@@ -15,9 +15,9 @@ Before start using this plugin I strongly recommend reading some documentation a
## Screens
![E-Steps](assets/eSteps.png)
![X-Y-Z Steps](assets/XYZSteps.png)
![PID Autotune](assets/PID-autotune.png)
![E-Steps](extras/assets/img/plugins/CalibrationTools/eSteps.png)
![X-Y-Z Steps](extras/assets/img/plugins/CalibrationTools/featuredimage.png)
![PID Autotune](extras/assets/img/plugins/CalibrationTools/PID-autotune.png)
## Setup
-102
View File
@@ -1,102 +0,0 @@
---
layout: plugin
id: CalibrationTools
title: OctoPrint-CalibrationTools
description: Calibration tools
authors:
- Sergiu Toporjinschi
license: GNUv3
# TODO
date: today's date in format YYYY-MM-DD, e.g. 2015-04-21
homepage: https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools
source: https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools
archive: https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools/archive/master.zip
# TODO
# Set this to true if your plugin uses the dependency_links setup parameter to include
# library versions not yet published on PyPi. SHOULD ONLY BE USED IF THERE IS NO OTHER OPTION!
#follow_dependency_links: false
# TODO
tags:
- a list
- of tags
- that apply
- to your plugin
- (take a look at the existing plugins for what makes sense here)
# TODO
screenshots:
- url: url of a screenshot, /assets/img/...
alt: alt-text of a screenshot
caption: caption of a screenshot
- url: url of another screenshot, /assets/img/...
alt: alt-text of another screenshot
caption: caption of another screenshot
- ...
# TODO
featuredimage: url of a featured image for your plugin, /assets/img/...
# TODO
# You only need the following if your plugin requires specific OctoPrint versions or
# specific operating systems to function - you can safely remove the whole
# "compatibility" block if this is not the case.
compatibility:
# List of compatible versions
#
# A single version number will be interpretated as a minimum version requirement,
# e.g. "1.3.1" will show the plugin as compatible to OctoPrint versions 1.3.1 and up.
# More sophisticated version requirements can be modelled too by using PEP440
# compatible version specifiers.
#
# You can also remove the whole "octoprint" block. Removing it will default to all
# OctoPrint versions being supported.
octoprint:
- 1.2.0
# List of compatible operating systems
#
# Valid values:
#
# - windows
# - linux
# - macos
# - freebsd
#
# There are also two OS groups defined that get expanded on usage:
#
# - posix: linux, macos and freebsd
# - nix: linux and freebsd
#
# You can also remove the whole "os" block. Removing it will default to all
# operating systems being supported.
os:
- linux
- windows
- macos
- freebsd
# Compatible Python version
#
# Plugins should aim for compatibility for Python 2 and 3 for now, in which case the value should be ">=2.7,<4".
#
# Plugins that only wish to support Python 3 should set it to ">=3,<4".
#
# If your plugin only supports Python 2 (worst case, not recommended for newly developed plugins since Python 2
# is EOL), leave at ">=2.7,<3" - be aware that your plugin will not be allowed to register on the
# plugin repository if it only support Python 2.
python: ">=2.7,<3"
---
**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at
http://plugins.octoprint.org/plugin/CalibrationTools/
-8
View File
@@ -1,8 +0,0 @@
Currently Cookiecutter generates the following helpful extras to this folder:
CalibrationTools.md
Data file for plugins.octoprint.org. Fill in the missing TODOs once your
plugin is ready for release and file a PR as described at
http://plugins.octoprint.org/help/registering/ to get it published.
This folder may be safely removed if you don't need it.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

+9 -12
View File
@@ -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")
+8 -6
View File
@@ -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&nbsp;&nbsp;&nbsp;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="">&nbsp;&nbsp;&nbsp;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="">&nbsp;&nbsp;&nbsp;Z</span>
+1 -1
View File
@@ -14,7 +14,7 @@ plugin_package = "octoprint_CalibrationTools"
plugin_name = "OctoPrint-CalibrationTools"
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.0.1"
plugin_version = "1.0.2"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module