From 4289073c836b0be56d9e486b75db0ae6fd35a83e Mon Sep 17 00:00:00 2001 From: jneilliii Date: Sat, 19 Jun 2021 23:39:11 -0400 Subject: [PATCH] added BLVPROCESSINGON/BLVPROCESSINGOFF received gcode commands via M118, #447 --- octoprint_bedlevelvisualizer/__init__.py | 3 +++ .../static/js/bedlevelvisualizer.js | 25 ++++++++++++++++--- setup.py | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/octoprint_bedlevelvisualizer/__init__.py b/octoprint_bedlevelvisualizer/__init__.py index 3234e27..76b6ce2 100644 --- a/octoprint_bedlevelvisualizer/__init__.py +++ b/octoprint_bedlevelvisualizer/__init__.py @@ -226,6 +226,9 @@ def process_gcode(self, comm, line, *args, **kwargs): thread.daemon = True thread.start() return line + if line.startswith("BLV"): + self._plugin_manager.send_plugin_message(self._identifier, {"BLV": line.strip()}) + return line if not self.processing: return line diff --git a/octoprint_bedlevelvisualizer/static/js/bedlevelvisualizer.js b/octoprint_bedlevelvisualizer/static/js/bedlevelvisualizer.js index 16e5cad..c5c3722 100644 --- a/octoprint_bedlevelvisualizer/static/js/bedlevelvisualizer.js +++ b/octoprint_bedlevelvisualizer/static/js/bedlevelvisualizer.js @@ -7,6 +7,9 @@ * http://beautifytools.com/javascript-validator.php * */ + +var ko = window.ko; + $(function () { function bedlevelvisualizerViewModel(parameters) { var self = this; @@ -91,7 +94,7 @@ $(function () { $('#bedlevelvisualizer_tabs a').on('show.bs.tab', function(event){ if($(event.target).text() === 'Current Mesh Data'){ self.settings_active(true); - return + return; } if ($(event.relatedTarget).text() === 'Current Mesh Data'){ self.settings_active(false); @@ -127,6 +130,20 @@ $(function () { if (plugin !== "bedlevelvisualizer") { return; } + + if (mesh_data.BLV) { + switch(mesh_data.BLV) { + case "BLVPROCESSINGON": + self.processing(true); + break; + case "BLVPROCESSINGOFF": + self.processing(false); + break; + default: + console.log("Unknown BLV Command: " + mesh_data.BLV); + } + } + var i; if (mesh_data.mesh) { if (mesh_data.mesh.length > 0) { @@ -134,7 +151,7 @@ $(function () { var y_data = []; for( i = 0;i <= (mesh_data.mesh[0].length - 1);i++) { - if ((mesh_data.bed.type == "circular") || self.settingsViewModel.settings.plugins.bedlevelvisualizer.use_center_origin()) { + if ((mesh_data.bed.type === "circular") || self.settingsViewModel.settings.plugins.bedlevelvisualizer.use_center_origin()) { x_data.push(Math.round(mesh_data.bed.x_min - (mesh_data.bed.x_max/2)+i/(mesh_data.mesh[0].length - 1)*(mesh_data.bed.x_max - mesh_data.bed.x_min))); } else { x_data.push(Math.round(mesh_data.bed.x_min+i/(mesh_data.mesh[0].length - 1)*(mesh_data.bed.x_max - mesh_data.bed.x_min))); @@ -142,7 +159,7 @@ $(function () { } for( i = 0;i <= (mesh_data.mesh.length - 1);i++) { - if ((mesh_data.bed.type == "circular") || self.settingsViewModel.settings.plugins.bedlevelvisualizer.use_center_origin()) { + if ((mesh_data.bed.type === "circular") || self.settingsViewModel.settings.plugins.bedlevelvisualizer.use_center_origin()) { y_data.push(Math.round(mesh_data.bed.y_min - (mesh_data.bed.y_max/2)+i/(mesh_data.mesh.length - 1)*(mesh_data.bed.y_max - mesh_data.bed.y_min))); } else { y_data.push(Math.round(mesh_data.bed.y_min+i/(mesh_data.mesh.length - 1)*(mesh_data.bed.y_max - mesh_data.bed.y_min))); @@ -170,7 +187,7 @@ $(function () { self.processing(true); } if (mesh_data.timeout_override) { - console.log('Resetting timeout to ' + mesh_data.timeout_override + ' seconds.') + console.log('Resetting timeout to ' + mesh_data.timeout_override + ' seconds.'); clearTimeout(self.timeout); self.timeout = setTimeout(function() {self.cancelMeshUpdate();new PNotify({title: 'Bed Visualizer Error',text: '
Timeout occured before processing completed. Processing may still be running or there may be a configuration error. Consider increasing the Processing Timeout value in settings and restart OctoPrint.
',type: 'error',hide: false});}, (mesh_data.timeout_override*1000)); } diff --git a/setup.py b/setup.py index 1ddd525..75ad668 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "Bed Visualizer" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.1.0rc6" +plugin_version = "1.1.0rc7" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module