Merge branch 'gcodeoffset' into devel
This commit is contained in:
commit
e03fee54a4
|
@ -165,7 +165,11 @@ $(function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.logMessage = function (timestamp, type, message) {
|
self.logMessage = function (timestamp, type="info", message) {
|
||||||
|
if (!timestamp) {
|
||||||
|
var today = new Date();
|
||||||
|
var timestamp = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
||||||
|
}
|
||||||
self.logMessages.push({
|
self.logMessages.push({
|
||||||
time: timestamp,
|
time: timestamp,
|
||||||
type: type,
|
type: type,
|
||||||
|
|
|
@ -4,47 +4,73 @@
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
function KlipperOffsetDialogViewModel(parameters) {
|
function KlipperOffsetDialogViewModel(parameters) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.offsetX = ko.observable();
|
|
||||||
self.offsetY = ko.observable();
|
|
||||||
self.offsetZ = ko.observable();
|
|
||||||
self.adjust = ko.observable();
|
|
||||||
|
|
||||||
self.onStartup = function() {
|
|
||||||
self.offsetX(0);
|
|
||||||
self.offsetY(0);
|
|
||||||
self.offsetZ(0);
|
|
||||||
self.adjust(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.setOffset = function() {
|
|
||||||
if(self.adjust()) {
|
|
||||||
OctoPrint.control.sendGcode("SET_GCODE_OFFSET X_ADJUST=" + self.offsetX() +
|
|
||||||
" Y_ADJUST=" + self.offsetY() +
|
|
||||||
" Z_ADJUST=" + self.offsetZ());
|
|
||||||
} else {
|
|
||||||
OctoPrint.control.sendGcode("SET_GCODE_OFFSET X=" + self.offsetX() +
|
|
||||||
" Y=" + self.offsetY() +
|
|
||||||
" Z=" + self.offsetZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push({
|
self.klipperViewModel = parameters[0];
|
||||||
construct: KlipperOffsetDialogViewModel,
|
|
||||||
dependencies: [],
|
self.offsetX = ko.observable();
|
||||||
elements: ["#klipper_offset_dialog"]
|
self.offsetY = ko.observable();
|
||||||
});
|
self.offsetZ = ko.observable();
|
||||||
|
self.adjust = ko.observable();
|
||||||
|
|
||||||
|
self.onStartup = function () {
|
||||||
|
self.offsetX(0);
|
||||||
|
self.offsetY(0);
|
||||||
|
self.offsetZ(0);
|
||||||
|
self.adjust(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setOffset = function () {
|
||||||
|
if (self.adjust()) {
|
||||||
|
self.klipperViewModel.logMessage("","info", "SET_GCODE_OFFSET X_ADJUST=" +
|
||||||
|
self.offsetX() +
|
||||||
|
" Y_ADJUST=" +
|
||||||
|
self.offsetY() +
|
||||||
|
" Z_ADJUST=" +
|
||||||
|
self.offsetZ())
|
||||||
|
OctoPrint.control.sendGcode(
|
||||||
|
"SET_GCODE_OFFSET X_ADJUST=" +
|
||||||
|
self.offsetX() +
|
||||||
|
" Y_ADJUST=" +
|
||||||
|
self.offsetY() +
|
||||||
|
" Z_ADJUST=" +
|
||||||
|
self.offsetZ()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
self.klipperViewModel.logMessage("","info", "SET_GCODE_OFFSET X=" +
|
||||||
|
self.offsetX() +
|
||||||
|
" Y=" +
|
||||||
|
self.offsetY() +
|
||||||
|
" Z=" +
|
||||||
|
self.offsetZ())
|
||||||
|
OctoPrint.control.sendGcode(
|
||||||
|
"SET_GCODE_OFFSET X=" +
|
||||||
|
self.offsetX() +
|
||||||
|
" Y=" +
|
||||||
|
self.offsetY() +
|
||||||
|
" Z=" +
|
||||||
|
self.offsetZ()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
|
construct: KlipperOffsetDialogViewModel,
|
||||||
|
dependencies: ["klipperViewModel"],
|
||||||
|
elements: ["#klipper_offset_dialog"],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button class="btn btn-block" data-bind="click: setOffset"><i class="icon-cross"></i> {{ _('Set Offset') }}</button>
|
<button class="btn btn-block" data-bind="click: setOffset" data-dismiss="modal"><i class="icon-cross"></i> {{ _('Set Offset') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue