From f045c5d1ddb8f828b485a04a7cbb49869f92b044 Mon Sep 17 00:00:00 2001 From: sergiuToporjinschi Date: Sun, 30 Jan 2022 20:07:23 +0200 Subject: [PATCH] E-Steps is working --- octoprint_CalibrationTools/__init__.py | 2 ++ octoprint_CalibrationTools/api.py | 4 ++- octoprint_CalibrationTools/hooks.py | 3 +- .../static/js/CalibrationTools.js | 23 ++++++++++--- .../CalibrationTools_settings.jinja2 | 33 +++++++++---------- .../templates/macros.jinja2 | 5 +-- .../templates/tabs/tab-doc.jinja2 | 1 + .../templates/tabs/tab-esteps.jinja2 | 33 ++++++++++++++----- 8 files changed, 67 insertions(+), 37 deletions(-) diff --git a/octoprint_CalibrationTools/__init__.py b/octoprint_CalibrationTools/__init__.py index 98134b0..ec98fc9 100644 --- a/octoprint_CalibrationTools/__init__.py +++ b/octoprint_CalibrationTools/__init__.py @@ -7,6 +7,8 @@ from octoprint_CalibrationTools import (api, hooks, models) defaultSettings = { "eSteps": { + "userControlsTemp": True, + "turnOffHeater": True, "extrudeTemp": 210, "extrudeLength": 100, "extrudeSpeed": 50, diff --git a/octoprint_CalibrationTools/api.py b/octoprint_CalibrationTools/api.py index b778c6f..41a926e 100644 --- a/octoprint_CalibrationTools/api.py +++ b/octoprint_CalibrationTools/api.py @@ -34,8 +34,9 @@ class API(octoprint.plugin.SimpleApiPlugin): ) def on_api_command(self, command, data): - self._logger.debug("api command [%s] received", command) + self._logger.debug("api command [%s] received payload [%s]", command, data) if command == CMD_LOAD_STEPS: + 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, { @@ -64,6 +65,7 @@ class API(octoprint.plugin.SimpleApiPlugin): return if command == CMD_SAVE_E_STEPS: + self._printer.commands(["M92 E%(newESteps)s" % data, "M500"]) return if command == CMD_TEST: diff --git a/octoprint_CalibrationTools/hooks.py b/octoprint_CalibrationTools/hooks.py index 0713afe..2f5ab47 100644 --- a/octoprint_CalibrationTools/hooks.py +++ b/octoprint_CalibrationTools/hooks.py @@ -13,8 +13,7 @@ class Hooks(): events = [] def gCodeReceived(self, comm, line, *args, **kwargs): - if not self.collectCommand: - return line + if not self.collectCommand: return line self._logger.debug("collectCommand is true, collecting info") reg = re.compile("echo:\s*(?P(?PM\d{1,3}) X(?P\d{1,3}.\d{1,3}) Y(?P\d{1,3}.\d{1,3}) Z(?P\d{1,3}.\d{1,3}) E(?P\d{1,3}.\d{1,3}))") diff --git a/octoprint_CalibrationTools/static/js/CalibrationTools.js b/octoprint_CalibrationTools/static/js/CalibrationTools.js index 68e6f9a..8eea900 100644 --- a/octoprint_CalibrationTools/static/js/CalibrationTools.js +++ b/octoprint_CalibrationTools/static/js/CalibrationTools.js @@ -14,7 +14,6 @@ $(function () { self.steps["Y"] = ko.observable(); self.steps["Z"] = ko.observable(); self.steps["E"] = ko.observable(); - self.results = {}; self.testParam = {}; self.testParam["extrudeTemp"] = ko.observable(210); @@ -22,17 +21,23 @@ $(function () { self.testParam["extrudeSpeed"] = ko.observable(50); self.testParam["markLength"] = ko.observable(120); + self.results = {}; self.results["remainedLength"] = ko.observable(20); - self.results["actualExtrusion"] = ko.computed(function () { return (self.testParam.markLength() - self.results.remainedLength()).toFixed(3); }); - 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() ; + }); self.onBeforeBinding = self.onUserLoggedIn = self.onUserLoggedOut = function () { + self.testParam.extrudeTemp(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeTemp()); + self.testParam.extrudeLength(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeLength()); + self.testParam.extrudeSpeed(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeSpeed()); + self.testParam.markLength(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.markLength()); self.is_admin(self.loginStateViewModel.isAdmin()); } @@ -51,7 +56,7 @@ $(function () { } self.loadESteps = function () { - OctoPrint.simpleApiCommand("CalibrationTools","loadSteps").done(function (response) { + OctoPrint.simpleApiCommand("CalibrationTools", "loadSteps").done(function (response) { self.from_json(response); }) } @@ -71,7 +76,15 @@ $(function () { OctoPrint.system.executeCommand("core", "restart"); } self.saveESteps = function () { - OctoPrint.system.executeCommand("core", "restart"); + OctoPrint.simpleApiCommand("CalibrationTools", "saveESteps", { + "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.onAllBound = self.onEventConnected = function () { diff --git a/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 b/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 index e18dfb9..8d02883 100644 --- a/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 +++ b/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 @@ -1,29 +1,26 @@ {% import "macros.jinja2" as snipped %} {{ snipped.subSection("E-Steps default settings", true) }} +
+
+
+
+
+
+
+
{{ snipped.field("Extrusion temperature", "The temperature used to extrude in testing Is better to be a bit higher then usual for reducing the nuzzle pressure", - "number", "settings.plugins.CalibrationTools.eSteps.extrudeTemp", "true", "ºC", 1) }} +"number", "settings.plugins.CalibrationTools.eSteps.extrudeTemp", "true", "ºC", 1) }} {{ snipped.field("Filament extrusion length", "The length of filament to be extruded in testing", - "number", "settings.plugins.CalibrationTools.eSteps.extrudeLength", "true", "mm", 1) }} +"number", "settings.plugins.CalibrationTools.eSteps.extrudeLength", "true", "mm", 1) }} {{ snipped.field("Filament extrusion speed", "How fast the filament should be extruded in test A lower value is recommended for avoiding skipping steps", - "number", "settings.plugins.CalibrationTools.eSteps.extrudeSpeed", "true", "mm/s", 1) }} +"number", "settings.plugins.CalibrationTools.eSteps.extrudeSpeed", "true", "mm/s", 1) }} {{ snipped.field("Filament mark length", "The length marked on filament", - "number", "settings.plugins.CalibrationTools.eSteps.markLength", "true", "mm") }} +"number", "settings.plugins.CalibrationTools.eSteps.markLength", "true", "mm") }} - +{{ snipped.subSection("X-Y-Z-Steps", true) }} + +{{ snipped.subSection("PID", true) }} \ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/macros.jinja2 b/octoprint_CalibrationTools/templates/macros.jinja2 index 8752094..918a27a 100644 --- a/octoprint_CalibrationTools/templates/macros.jinja2 +++ b/octoprint_CalibrationTools/templates/macros.jinja2 @@ -11,9 +11,10 @@ {% endmacro %} -{% macro quote(content, class) %} +{% macro quote(content, cite, class) %}

{{ _(content) }}

+ {{ cite }}
{% endmacro %} @@ -27,7 +28,7 @@
- + {{ _(unit) }}
diff --git a/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 index c1cc65a..871f4d3 100644 --- a/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 +++ b/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 @@ -1,3 +1,4 @@ Something in documentation tab... + \ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 index a21bf76..8dd7cda 100644 --- a/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 +++ b/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 @@ -2,7 +2,7 @@ {{ snipped.subSection("Test parameters", true) }} - +
- M104    S + M104   S
+
- G1   E + G1   E -    F +    F
@@ -72,7 +73,22 @@ {{ snipped.field("Length after extrusion", "The remained length between filament mark and extruder entry", "number", "$root.results.remainedLength", "true", "mm") }} {{ snipped.field("Actual extrusion", "How much filament has been extruded", "number", "$root.results.actualExtrusion", "false", "mm") }} -{{ snipped.field("New steps/mm", "The new number of steps/mm which should be set on EEPROM", "number", "$root.results.newSteps", "false", "steps/mm") }} + + +
+
+ +
+
+
+ + M500 +
+
+
+
@@ -87,10 +103,9 @@ {{ snipped.subSection("Process description", true) }} {{ snipped.quote(" -First Read this

This calibration is best done with the extruder detached from the hot end, so no restriction is present on the movement. If it is convenient, you can partially disassemble the printer so the output of the extruder is open and the filament exits in free air. If this is inconvenient, the process below aims to minimize restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be reliable. -", "text-warning" ) }} - - \ No newline at end of file +", " +teachingtechyt.github.io +", "text-warning") }} \ No newline at end of file