add metric/inch conversion in and out for gcode
This commit is contained in:
parent
d5490290f1
commit
bb2824a743
2 changed files with 26 additions and 13 deletions
|
|
@ -1834,6 +1834,7 @@
|
|||
time = 0,
|
||||
lines = 0,
|
||||
bytes = 0,
|
||||
factor = 1,
|
||||
output = [],
|
||||
spindle = 0,
|
||||
modes = CPRO,
|
||||
|
|
@ -1911,6 +1912,11 @@
|
|||
line = line.substring(0, cidx).trim();
|
||||
if (line.length === 0) continue;
|
||||
}
|
||||
if (line.indexOf('G20') === 0) {
|
||||
factor = 1/25.4;
|
||||
} else if (line.indexOf('G21') === 0) {
|
||||
factor = 1;
|
||||
}
|
||||
append(line);
|
||||
}
|
||||
}
|
||||
|
|
@ -1921,7 +1927,7 @@
|
|||
if (d < 0) {
|
||||
return s + '.0';
|
||||
} else {
|
||||
return s;
|
||||
return val.toFixed(decimals);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2000,19 +2006,19 @@
|
|||
pos.x = newpos.x;
|
||||
runbox.min.x = Math.min(runbox.min.x, pos.x);
|
||||
runbox.max.x = Math.max(runbox.max.x, pos.x);
|
||||
nl.append(space).append("X").append(add0(pos.x));
|
||||
nl.append(space).append("X").append(add0(pos.x * factor));
|
||||
}
|
||||
if (newpos.y !== pos.y) {
|
||||
pos.y = newpos.y;
|
||||
runbox.min.y = Math.min(runbox.min.y, pos.y);
|
||||
runbox.max.y = Math.max(runbox.max.y, pos.y);
|
||||
nl.append(space).append("Y").append(add0(pos.y));
|
||||
nl.append(space).append("Y").append(add0(pos.y * factor));
|
||||
}
|
||||
if (newpos.z !== pos.z) {
|
||||
pos.z = newpos.z;
|
||||
runbox.min.z = Math.min(runbox.min.z, pos.z);
|
||||
runbox.max.z = Math.max(runbox.max.z, pos.z);
|
||||
nl.append(space).append("Z").append(add0(pos.z));
|
||||
nl.append(space).append("Z").append(add0(pos.z * factor));
|
||||
}
|
||||
if (feed && feed !== pos.f) {
|
||||
pos.f = feed;
|
||||
|
|
|
|||
Loading…
Reference in a new issue