Added assisted leveling dialog

This commit is contained in:
mfm 2018-01-24 17:12:57 +01:00
parent a2fa85faf0
commit 38bda28c99
2 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,51 @@
$(function() {
function KlipperLevelingViewModel(parameters) {
var self = this;
self.settings = parameters[0];
self.loginState = parameters[1];
self.connectionState = parameters[2];
self.activePoint = ko.observable();
self.onStartup = function() {
self.activePoint(-1);
}
self.startLeveling = function() {
self.activePoint(0);
OctoPrint.control.sendGcode("G28")
}
self.stopLeveling = function() {
self.activePoint(-1);
OctoPrint.control.sendGcode("G28")
}
self.nextPoint = function() {
self.activePoint(self.activePoint()+1);
self.moveToPoint(self.activePoint);
}
self.previousPoint = function() {
self.activePoint(self.activePoint()-1);
}
self.pointCount = function() {
return self.settings.settings.plugins.klipper.probePoints().length;
}
self.moveToPoint = function(index) {
var point = self.settings.settings.plugins.klipper.probePoints()[0];
OctoPrint.control.sendGcode("G1 Z" + self.settings.settings.plugins.klipper.probeHeight() + self.settings.settings.plugins.klipper.probeLift());
OctoPrint.control.sendGcode("G1 X" + point.x() + " Y" + point.y());
OctoPrint.control.sendGcode("G1 Z" + self.settings.settings.plugins.klipper.probeHeight());
}
}
OCTOPRINT_VIEWMODELS.push({
construct: KlipperLevelingViewModel,
dependencies: ["settingsViewModel", "loginStateViewModel", "connectionViewModel"],
elements: ["#tab_plugin_klipper_leveling", "#klipper_leveling_dialog"]
});
});

View File

@ -1 +1,24 @@
test
<div id="klipper_leveling_dialog" class="modal hide fade small" tabindex="-1" role="dialog" aria-labelledby="leveling_dialog_label" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h3 id="leveling_dialog_label">Assisted Bed Leveling</h3>
</div>
<div class="modal-body">
<div class="row-fluid">
<div class="span3">
<button class="btn btn-block" data-bind="click: startLeveling">Start</button>
<button class="btn btn-block" data-bind="click: previousPoint, enable: (activePoint() > 0)">Previous</button>
<button class="btn btn-block" data-bind="click: nextPoint, enable: (activePoint() < pointCount()-1)">Next</button>
<button class="btn btn-block" data-bind="click: stopLeveling" data-dismiss="modal">Close</button>
</div>
<div class="span8">
<div data-bind="foreach: settings.settings.plugins.klipper.probePoints" >
<div class="row-fluid">
<div class="span1"><i class="fa fa-arrow-right" data-bind="visible: ($index()==$parent.activePoint())"></i></div>
<div class="span9">[<span data-bind="text: x"></span>,<span data-bind="text: y"></span>]</div>
</div>
</div>
</div>
</div>
</div>
</div>