2018-01-24 19:12:57 +03:00
|
|
|
$(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")
|
2018-01-24 21:05:28 +03:00
|
|
|
self.moveToPoint(self.activePoint());
|
2018-01-24 19:12:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
self.stopLeveling = function() {
|
|
|
|
self.activePoint(-1);
|
2018-01-24 21:05:28 +03:00
|
|
|
OctoPrint.control.sendGcode("G1 Z" + (self.settings.settings.plugins.klipper.probeHeight()*1 + self.settings.settings.plugins.klipper.probeLift()*1));
|
2018-01-24 19:12:57 +03:00
|
|
|
OctoPrint.control.sendGcode("G28")
|
|
|
|
}
|
|
|
|
|
|
|
|
self.nextPoint = function() {
|
|
|
|
self.activePoint(self.activePoint()+1);
|
2018-01-24 21:05:28 +03:00
|
|
|
self.moveToPoint(self.activePoint());
|
2018-01-24 19:12:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
self.previousPoint = function() {
|
|
|
|
self.activePoint(self.activePoint()-1);
|
2018-01-24 21:05:28 +03:00
|
|
|
self.moveToPoint(self.activePoint());
|
2018-01-24 19:12:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
self.pointCount = function() {
|
|
|
|
return self.settings.settings.plugins.klipper.probePoints().length;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.moveToPoint = function(index) {
|
2018-01-24 20:39:48 +03:00
|
|
|
var point = self.settings.settings.plugins.klipper.probePoints()[index];
|
2018-01-24 19:12:57 +03:00
|
|
|
|
2018-01-24 21:05:28 +03:00
|
|
|
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() +
|
|
|
|
" F" + self.settings.settings.plugins.klipper.probeSpeedXy()
|
|
|
|
);
|
|
|
|
OctoPrint.control.sendGcode(
|
|
|
|
"G1 Z" + self.settings.settings.plugins.klipper.probeHeight() +
|
|
|
|
" F" + self.settings.settings.plugins.klipper.probeSpeedZ()
|
|
|
|
);
|
2018-01-24 19:12:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OCTOPRINT_VIEWMODELS.push({
|
|
|
|
construct: KlipperLevelingViewModel,
|
|
|
|
dependencies: ["settingsViewModel", "loginStateViewModel", "connectionViewModel"],
|
2018-01-25 02:16:45 +03:00
|
|
|
elements: ["#klipper_leveling_dialog"]
|
2018-01-24 19:12:57 +03:00
|
|
|
});
|
|
|
|
});
|