Skip to content

Commit

Permalink
added BLVPROCESSINGON/BLVPROCESSINGOFF received gcode commands via M1…
Browse files Browse the repository at this point in the history
…18, #447
  • Loading branch information
jneilliii committed Jun 20, 2021
1 parent bddcf96 commit 4289073
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions octoprint_bedlevelvisualizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 21 additions & 4 deletions octoprint_bedlevelvisualizer/static/js/bedlevelvisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* http://beautifytools.com/javascript-validator.php
*
*/

var ko = window.ko;

$(function () {
function bedlevelvisualizerViewModel(parameters) {
var self = this;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -127,22 +130,36 @@ $(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) {
var x_data = [];
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)));
}
}

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)));
Expand Down Expand Up @@ -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: '<div class="row-fluid">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.</div>',type: 'error',hide: false});}, (mesh_data.timeout_override*1000));
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4289073

Please sign in to comment.