From 05a8166fa1ada3b386a4e0cce30c60f396587476 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Sun, 24 Nov 2024 19:55:13 +0100 Subject: implement printer controls; implement calibration data collection --- Main.qml | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 192 insertions(+), 5 deletions(-) (limited to 'Main.qml') diff --git a/Main.qml b/Main.qml index 8d87aab..65fa5a0 100644 --- a/Main.qml +++ b/Main.qml @@ -15,8 +15,8 @@ ApplicationWindow { height: 480 visible: true // visibility: Window.Maximized - // visibility: ApplicationWindow.Maximized - visibility: ApplicationWindow.FullScreen + visibility: ApplicationWindow.Maximized + // visibility: ApplicationWindow.FullScreen title: qsTr("Hello World") @@ -135,13 +135,37 @@ ApplicationWindow { console.log("response status: ", response.status); return; } + }); + } - // console.log("resetEncoder result:", response.content); + function startCalibration() { + var url = apiRoot + "/commands/startCalibration"; + console.log("startCalibration:", url); - // var json = JSON.parse(response.content); + XHR.sendRequest("POST", url, function(response) { + + if (response.status != "200") { + console.log("response status: ", response.status); + return; + } }); } + function sendGCode(gcode) { + var url = apiRoot + "/commands/gCode"; + console.log("gCode:", url); + + var withFeedRate = gcode + " F" + feedRateSpinBox.value + + XHR.sendRequest("POST", url, function(response) { + + if (response.status != "200") { + console.log("response status: ", response.status); + return; + } + }, withFeedRate); + } + RowLayout { id: horizontalLayout @@ -154,7 +178,7 @@ ApplicationWindow { Layout.fillHeight: true Layout.fillWidth: true - Layout.minimumWidth: 150 + Layout.minimumWidth: 250 ColumnLayout { id: columnLayout @@ -278,6 +302,10 @@ ApplicationWindow { onValueChanged: writeParams() } + Label { + text: qsTr("Laser level (1/50K):") + } + SpinBox { id: laserLevelSpinBox @@ -300,9 +328,168 @@ ApplicationWindow { onCheckedChanged: writeParams() } + Label { + text: qsTr("Printer distance (mm):") + } + + TextField { + id: printerDistanceMmTextField + + Layout.fillWidth: true + + text: "10" + // onValueChanged: writeParams() + } + + Label { + text: qsTr("Feed rate (%):") + } + + SpinBox { + id: feedRateSpinBox + + Layout.fillWidth: true + + from: 1 + to: 500 + stepSize: 50 + editable: true + + value: 300 + } + + GridLayout { + id: printerControlGridLayout + + columns: 4 + + Label { + Layout.row: 0 + Layout.column: 1 + + text: "X/Y" + } + + Label { + Layout.row: 0 + Layout.column: 3 + + text: "Z" + } + + Button { + id: yUpButton + + Layout.row: 1 + Layout.column: 1 + + text: "\u2191" + onClicked: sendGCode("G1 Y" + printerDistanceMmTextField.text) + + highlighted: true + } + + Button { + id: zUpButton + + Layout.row: 1 + Layout.column: 3 + + text: "\u2191" + onClicked: sendGCode("G1 Z" + printerDistanceMmTextField.text) + + highlighted: true + } + + Button { + id: xDownButton + + Layout.row: 2 + Layout.column: 0 + + text: "\u2190" + onClicked: sendGCode("G1 X-" + printerDistanceMmTextField.text) + + highlighted: true + } + + Button { + id: xyHomeButton + + Layout.row: 2 + Layout.column: 1 + + text: "\u2302" + // onClicked: sendGCode("G1 X-" + printerDistanceMmSpinBox.text) + + highlighted: true + } + + Button { + id: xUpButton + + Layout.row: 2 + Layout.column: 2 + + text: "\u2192" + onClicked: sendGCode("G1 X" + printerDistanceMmTextField.text) + + highlighted: true + } + + Button { + id: zHomeButton + + Layout.row: 2 + Layout.column: 3 + + text: "\u2302" + // onClicked: sendGCode("G1 X-" + printerDistanceMmSpinBox.text) + + highlighted: true + } + + Button { + id: yDownButton + + Layout.row: 3 + Layout.column: 1 + + text: "\u2193" + onClicked: sendGCode("G1 Y-" + printerDistanceMmTextField.text) + + highlighted: true + } + + Button { + id: zDownButton + + Layout.row: 3 + Layout.column: 3 + + text: "\u2193" + onClicked: sendGCode("G1 Z-" + printerDistanceMmTextField.text) + + highlighted: true + } + } + Button { + Layout.fillWidth: true + text: qsTr("Reset encoder") onClicked: resetEncoder() + + highlighted: true + } + + Button { + Layout.fillWidth: true + + text: qsTr("Start calibration") + onClicked: startCalibration() + + highlighted: true } Item { -- cgit v1.2.3-70-g09d2