diff --git a/README.md b/README.md index 39bfa53..1755780 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,24 @@ the plugin manager. ## Configuration **TODO:** Describe your plugin's configuration options (if any). + + + + + + +## Regex for getting temperatures +\s*T:(?P\d{1,3}.\d{1,3}).*B:(?P\d{1,3}.\d{1,3}).* + +## extrude command from JS +OctoPrint.printer.issueToolCommand("extrude", {"amount":100, "speed":50}) + + +## Notification JS +new PNotify({ + title: "Success", + text: _.sprintf(text, { + command: _.escape(commandSpec.name) + }), + type: "success" +}); \ No newline at end of file diff --git a/octoprint_CalibrationTools/__init__.py b/octoprint_CalibrationTools/__init__.py index f86a3e6..ae4a4eb 100644 --- a/octoprint_CalibrationTools/__init__.py +++ b/octoprint_CalibrationTools/__init__.py @@ -9,13 +9,15 @@ from __future__ import absolute_import # # Take a look at the documentation on what other plugin mixins are available. + import octoprint.plugin import re from octoprint_CalibrationTools import ( api ) -class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin, +class CalibrationtoolsPlugin( + octoprint.plugin.StartupPlugin, octoprint.plugin.TemplatePlugin, octoprint.plugin.SettingsPlugin, octoprint.plugin.AssetPlugin, @@ -34,21 +36,18 @@ class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin, self._api = api.API(self) def on_after_startup(self): - self._logger.info("----------------[CalibrationTools]----------------") + self._logger.debug("----------------[CalibrationTools]----------------") self.collectCommand = True self._printer.commands("M92") # API handling def get_api_commands(self): - self._logger.info("get_api_commands") return self._api.get_api_commands() def on_api_command(self, command, data): - self._logger.info("on_api_command") return self._api.on_api_command(command, data) def on_api_get(self, request): - self._logger.info("on_api_get") return self._api.on_api_get(request) ##~~ AssetPlugin mixin @@ -60,9 +59,7 @@ class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin, "css": ["css/style.css"] } -# self._printer.commands(commands) -# extrude(amount, speed=None, tags=None, *args, **kwargs) -# set_temperature(heater, value, tags=None, *args, **kwargs) + ##~~ Softwareupdate hook def comm_protocol_gcode_received(self, comm, line, *args, **kwargs): if not self.collectCommand: return line @@ -83,20 +80,20 @@ class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin, self.m92Data["E"] = float(eValue) # Send the new data to the UI to be reloaded - self._logger.info(line) - self._logger.info("gCode: %s", command) - self._logger.info("X: %s", xValue) - self._logger.info("Y: %s", yValue) - self._logger.info("Z: %s", zValue) - self._logger.info("E: %s", eValue) - self._logger.info("Finished data collection, updating UI") + self._logger.debug(line) + self._logger.debug("gCode: %s", command) + self._logger.debug("X: %s", xValue) + self._logger.debug("Y: %s", yValue) + self._logger.debug("Z: %s", zValue) + self._logger.debug("E: %s", eValue) + self._logger.debug("Finished data collection") self.collectCommand = False return line def comm_protocol_gcode_sending(self, comm, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs): - # https://docs.octoprint.org/en/master/plugins/hooks.html#protocol_gcodephase_hook + self._logger.debug("sending GCODE") if cmd == "M92": - self._logger.info("{} detected, collecting data".format(cmd)) + self._logger.debug("{} detected, collecting data".format(cmd)) self.collectCommand = True def get_update_information(self): @@ -138,5 +135,8 @@ def __plugin_load__(): global __plugin_hooks__ __plugin_hooks__ = { - "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information + "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information, + "octoprint.comm.protocol.gcode.received": __plugin_implementation__.comm_protocol_gcode_received, + "octoprint.comm.protocol.gcode.sending": __plugin_implementation__.comm_protocol_gcode_sending + # "octoprint.comm.protocol.atcommand.sending": __plugin_implementation__.comm_protocol_atcommand_sending } diff --git a/octoprint_CalibrationTools/api.py b/octoprint_CalibrationTools/api.py index 3045df5..757e16d 100644 --- a/octoprint_CalibrationTools/api.py +++ b/octoprint_CalibrationTools/api.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, division, unicode_literals import flask -CMD_LOAD_STEPS_EEPROM = "loadSteps" +CMD_LOAD_STEPS = "loadSteps" class API: @@ -16,11 +16,11 @@ class API: @staticmethod def get_api_commands(): return { - CMD_LOAD_STEPS_EEPROM: [] + CMD_LOAD_STEPS: [] } def on_api_get(self, request): - self._logger.info("on api get") + self._logger.debug("api.on_api_get") return flask.jsonify( { "data": self.m92Data @@ -28,8 +28,8 @@ class API: ) def on_api_command(self, command, data): - if command == CMD_LOAD_STEPS_EEPROM: - self._logger.info("CMD_LOAD_STEPS_EEPROM") + self._logger.debug("api command [%s] received", command) + if command == CMD_LOAD_STEPS: self._printer.commands("M92") return flask.jsonify({ "data": self.m92Data diff --git a/octoprint_CalibrationTools/static/css/style.css b/octoprint_CalibrationTools/static/css/style.css index 69b2a86..f000823 100644 --- a/octoprint_CalibrationTools/static/css/style.css +++ b/octoprint_CalibrationTools/static/css/style.css @@ -14,7 +14,7 @@ border-radius: 4px; } -#tab_plugin_CalibrationTools .tab-content { +#tab_plugin_CalibrationTools .tab-content, #tab_plugin_CalibrationTools .tab-content > .tab-pane { border: none; } diff --git a/octoprint_CalibrationTools/static/js/CalibrationTools.js b/octoprint_CalibrationTools/static/js/CalibrationTools.js index 12d171b..478448b 100644 --- a/octoprint_CalibrationTools/static/js/CalibrationTools.js +++ b/octoprint_CalibrationTools/static/js/CalibrationTools.js @@ -1,14 +1,3 @@ -//Notification -// new PNotify({ -// title: "Success", -// text: _.sprintf(text, { -// command: _.escape(commandSpec.name) -// }), -// type: "success" -// }); - - - $(function () { function CalibrationToolsViewModel(parameters) { var self = this; @@ -54,19 +43,7 @@ $(function () { self.steps["E"](response.data.E); } - self.calibrateESteps = function () { - // OctoPrint.simpleApiCommand("loadSteps") - // OctoPrint.control.sendGcodeWithParameters("M92").done(function (responseM92) { - // OctoPrint.simpleApiGet("CalibrationTools").done(function (response) { - // console.log("CalibrationTools"); - // self.from_json(response); - // }); - // }); - console.log("calibrateESteps"); - console.log(self.steps.E(), self.results.remainedLength(), self.results.newSteps()); - } - - self.loadStepsFromEPROM = function () { + self.loadESteps = function () { OctoPrint.simpleApiCommand("CalibrationTools","loadSteps").done(function (response) { self.from_json(response); }) diff --git a/octoprint_CalibrationTools/templates/macros.jinja2 b/octoprint_CalibrationTools/templates/macros.jinja2 index cc8b19a..5d1ed33 100644 --- a/octoprint_CalibrationTools/templates/macros.jinja2 +++ b/octoprint_CalibrationTools/templates/macros.jinja2 @@ -17,17 +17,17 @@ {% endmacro %} -{% macro field(label, number, binding, enable, unit) %} +{% macro field(label, title, number, binding, enable, unit) %}
-
- - {{ _(unit) }} + + {{ _(unit) }}
diff --git a/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 index 0250774..7d4d586 100644 --- a/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 +++ b/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 @@ -2,11 +2,12 @@ {{ snipped.subSection("EEPROM values") }} -{{ snipped.field("E steps", "number", "$root.steps.E", "false", "steps/mm") }} +{{ snipped.field("E steps", "Number of steps/mm currently set in EEPROM", "number", "$root.steps.E", "false", "steps/mm") }}
- @@ -15,16 +16,28 @@ {{ snipped.subSection("Compute", true) }} -{{ snipped.field("Actual extrusion", "number", "$root.results.actualExtrusion", "false", "mm") }} -{{ snipped.field("New steps value", "number", "$root.results.newSteps", "false", "steps/mm") }} -{{ snipped.field("Extrusion marking length", "number", "$root.results.markLength", "true", "mm") }} -{{ snipped.field("Measured value", "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") }} +{{ snipped.field("Extrusion marking length", "The length marked on filament before extrusion", "number", "$root.results.markLength", "true", "mm") }} +{{ snipped.field("Measured value", "The length between filament mark and extruder entry after extrusion", "number", "$root.results.remainedLength", "true", "mm") }}
-
@@ -33,6 +46,6 @@ {{ 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 minimise restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be +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