Command handeling
This commit is contained in:
0
scripts/create-cert.sh
Normal file → Executable file
0
scripts/create-cert.sh
Normal file → Executable file
@@ -36,6 +36,14 @@ class FluidNCClient extends EventEmitter {
|
||||
this.ws.on("error", (err) => {
|
||||
console.log("[FluidNC] WS Error:", err.message);
|
||||
});
|
||||
|
||||
this.ws.on("unexpected-response", (req, res) => {
|
||||
console.log("[FluidNC] WS Unexpected Response:", res.statusCode, res.statusMessage);
|
||||
});
|
||||
|
||||
this.ws.on("disconnect", () => {
|
||||
console.log("[FluidNC] WS Disconnected");
|
||||
});
|
||||
}
|
||||
|
||||
sendLine(cmd) {
|
||||
@@ -48,8 +56,12 @@ class FluidNCClient extends EventEmitter {
|
||||
this.sendLine("?");
|
||||
}
|
||||
|
||||
jog(axis, value) {
|
||||
const cmd = `$J=G91 ${axis}${value} F2000`;
|
||||
jog(relative, axis, value) {
|
||||
// $J= um den Befehl als Jog zu kennzeichnen
|
||||
// G91 für relative Bewegungen (G90 für absolute)
|
||||
// G1 Linearbewegung
|
||||
const cmd = relative? `$J=G91 G1 ${axis}${value} F2000\r\n`: `$J=G90 G1 ${axis}${value} F2000\r\n`;
|
||||
console.log("[FluidNC] Jog Command:", cmd);
|
||||
this.sendLine(cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ wss.on("connection", (ws) => {
|
||||
|
||||
console.log("Message from WSS: " + msg);
|
||||
if (data.type === "jog") {
|
||||
fluid.jog(data.axis, data.value);
|
||||
fluid.jog(data.relative, data.axis, data.value);
|
||||
}
|
||||
|
||||
if (data.type === "gcode") {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>2D Robot Control</title>
|
||||
<title>FluidNC Robot Control</title>
|
||||
<style>
|
||||
body {
|
||||
background: #234;
|
||||
@@ -91,6 +91,7 @@
|
||||
|
||||
<div id="posBox">
|
||||
<div>X: <span id="posX">0.000</span></div>
|
||||
<div>Y: <span id="posY">0.000</span></div>
|
||||
<div>Z: <span id="posZ">0.000</span></div>
|
||||
</div>
|
||||
|
||||
@@ -103,6 +104,12 @@
|
||||
<button onclick="jog('X', 1)">X +1</button>
|
||||
<button onclick="jog('X', 10)">X +10</button>
|
||||
|
||||
<button onclick="jog('Y', -10)">Y -10</button>
|
||||
<button onclick="jog('Y', -1)">Y -1</button>
|
||||
<button class="noMouseHover"></button>
|
||||
<button onclick="jog('Y', 1)">Y +1</button>
|
||||
<button onclick="jog('Y', 10)">Y +10</button>
|
||||
|
||||
<button onclick="jog('Z', -10)">Z -10</button>
|
||||
<button onclick="jog('Z', -1)">Z -1</button>
|
||||
<button class="noMouseHover"></button>
|
||||
@@ -180,8 +187,8 @@
|
||||
// 1) Versuche WPos direkt zu lesen
|
||||
const wposMatch = line.match(/WPos:([^|>]+)/);
|
||||
if (wposMatch) {
|
||||
const [x, , z] = wposMatch[1].split(",").map(Number);
|
||||
updateXZ(x, z);
|
||||
const [x, y, z] = wposMatch[1].split(",").map(Number);
|
||||
updateXZ(x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,16 +201,19 @@
|
||||
const wco = wcoMatch[1].split(",").map(Number);
|
||||
|
||||
const x = (mpos[0] ?? 0) - (wco[0] ?? 0);
|
||||
const y = (mpos[1] ?? 0) - (wco[1] ?? 0);
|
||||
const z = (mpos[2] ?? 0) - (wco[2] ?? 0);
|
||||
|
||||
updateXZ(x, z);
|
||||
updateXZ(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
function updateXZ(x, z) {
|
||||
function updateXZ(x, y, z) {
|
||||
const elX = document.getElementById("posX");
|
||||
const elY = document.getElementById("posY");
|
||||
const elZ = document.getElementById("posZ");
|
||||
if (elX) elX.textContent = Number.isFinite(x) ? x.toFixed(3) : "—";
|
||||
if (elY) elY.textContent = Number.isFinite(y) ? y.toFixed(3) : "—";
|
||||
if (elZ) elZ.textContent = Number.isFinite(z) ? z.toFixed(3) : "—";
|
||||
}
|
||||
|
||||
@@ -226,7 +236,7 @@
|
||||
}
|
||||
|
||||
function setZero() {
|
||||
sendGcode("G92 X0 Z0");
|
||||
sendGcode("G92 X0 Y0 Z0");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user