From b5411c26fcfa374fd2c7240107ee0080a004544a Mon Sep 17 00:00:00 2001 From: Martin Muehlhaeuser Date: Fri, 2 Feb 2018 15:57:29 +0000 Subject: [PATCH] leveling: Enabled direct move to point --- .../static/js/klipper_leveling.js | 38 ++++++++++++------- .../templates/klipper_leveling_dialog.jinja2 | 10 ++--- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/octoprint_klipper/static/js/klipper_leveling.js b/octoprint_klipper/static/js/klipper_leveling.js index 8136174..40d661a 100644 --- a/octoprint_klipper/static/js/klipper_leveling.js +++ b/octoprint_klipper/static/js/klipper_leveling.js @@ -12,40 +12,45 @@ $(function() { } self.startLeveling = function() { - self.activePoint(0); OctoPrint.control.sendGcode("G28") - self.moveToPoint(self.activePoint()); + self.moveToPoint(0); } self.stopLeveling = function() { self.activePoint(-1); - OctoPrint.control.sendGcode("G1 Z" + (self.settings.settings.plugins.klipper.probeHeight()*1 + self.settings.settings.plugins.klipper.probeLift()*1)); + OctoPrint.control.sendGcode("G1 Z" + + (self.settings.settings.plugins.klipper.probeHeight()*1 + + self.settings.settings.plugins.klipper.probeLift()*1) + ); OctoPrint.control.sendGcode("G28") } self.nextPoint = function() { - self.activePoint(self.activePoint()+1); - self.moveToPoint(self.activePoint()); + self.moveToPoint(self.activePoint()+1); } self.previousPoint = function() { - self.activePoint(self.activePoint()-1); - self.moveToPoint(self.activePoint()); + self.moveToPoint(self.activePoint()-1); + } + + self.jumpToPoint = function(item) { + self.moveToPoint( + self.settings.settings.plugins.klipper.probePoints().indexOf(item) + ); } self.pointCount = function() { return self.settings.settings.plugins.klipper.probePoints().length; } - self.moveToPoint = function(index) { - var point = self.settings.settings.plugins.klipper.probePoints()[index]; - - OctoPrint.control.sendGcode( - "G1 Z" + (self.settings.settings.plugins.klipper.probeHeight()*1 + self.settings.settings.plugins.klipper.probeLift()*1) + + self.moveToPosition = function(x, y) { + OctoPrint.control.sendGcode( + "G1 Z" + (self.settings.settings.plugins.klipper.probeHeight() * 1 + + self.settings.settings.plugins.klipper.probeLift()*1) + " F" + self.settings.settings.plugins.klipper.probeSpeedZ() ); OctoPrint.control.sendGcode( - "G1 X" + point.x() + " Y" + point.y() + + "G1 X" + x + " Y" + y + " F" + self.settings.settings.plugins.klipper.probeSpeedXy() ); OctoPrint.control.sendGcode( @@ -53,6 +58,13 @@ $(function() { " F" + self.settings.settings.plugins.klipper.probeSpeedZ() ); } + + self.moveToPoint = function(index) { + var point = self.settings.settings.plugins.klipper.probePoints()[index]; + + self.moveToPosition(point.x(), point.y()); + self.activePoint(index); + } } OCTOPRINT_VIEWMODELS.push({ diff --git a/octoprint_klipper/templates/klipper_leveling_dialog.jinja2 b/octoprint_klipper/templates/klipper_leveling_dialog.jinja2 index 3d298bf..aa00ab5 100644 --- a/octoprint_klipper/templates/klipper_leveling_dialog.jinja2 +++ b/octoprint_klipper/templates/klipper_leveling_dialog.jinja2 @@ -6,16 +6,16 @@