resolve gcode as array/text
This commit is contained in:
parent
c4e921ea1f
commit
91514aeb86
6 changed files with 44 additions and 19 deletions
|
|
@ -2,8 +2,8 @@
|
||||||
"mode": "CAM",
|
"mode": "CAM",
|
||||||
"internal": 0,
|
"internal": 0,
|
||||||
"bedHeight": 2.5,
|
"bedHeight": 2.5,
|
||||||
"bedWidth": 300,
|
"bedWidth": 360,
|
||||||
"bedDepth": 300,
|
"bedDepth": 240,
|
||||||
"originCenter": false,
|
"originCenter": false,
|
||||||
"spindleMax": 12000,
|
"spindleMax": 12000,
|
||||||
"gcodePre": [
|
"gcodePre": [
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,6 @@ CAM.init = function(kiri, api) {
|
||||||
});
|
});
|
||||||
|
|
||||||
func.opGCode = (label, field = 'gcode') => {
|
func.opGCode = (label, field = 'gcode') => {
|
||||||
console.log({label});
|
|
||||||
API.dialog.show('any');
|
API.dialog.show('any');
|
||||||
const { c_gcode } = h.bind(
|
const { c_gcode } = h.bind(
|
||||||
$('mod-any'), h.div({ id: "camop_dialog" }, [
|
$('mod-any'), h.div({ id: "camop_dialog" }, [
|
||||||
|
|
@ -506,9 +505,10 @@ console.log({label});
|
||||||
} })
|
} })
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
c_gcode.value = poppedRec[field] || '';
|
let av = poppedRec[field] || [];
|
||||||
|
c_gcode.value = typeof(av) === 'string' ? av : av.join('\n');
|
||||||
c_gcode.onkeyup = (el) => {
|
c_gcode.onkeyup = (el) => {
|
||||||
poppedRec[field] = c_gcode.value;
|
poppedRec[field] = c_gcode.value.trim().split('\n');
|
||||||
};
|
};
|
||||||
c_gcode.focus();
|
c_gcode.focus();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ CAM.export = function(print, online) {
|
||||||
point,
|
point,
|
||||||
points = 0,
|
points = 0,
|
||||||
lasering = false,
|
lasering = false,
|
||||||
|
laserOp,
|
||||||
currentOp,
|
currentOp,
|
||||||
stock = settings.stock || { },
|
stock = settings.stock || { },
|
||||||
hasStock = spro.camStockOn && stock.x && stock.y && stock.z,
|
hasStock = spro.camStockOn && stock.x && stock.y && stock.z,
|
||||||
|
|
@ -167,17 +168,21 @@ CAM.export = function(print, online) {
|
||||||
pos.t = out.tool;
|
pos.t = out.tool;
|
||||||
consts.tool = pos.t;
|
consts.tool = pos.t;
|
||||||
consts.tool_name = toolNameByNumber(out.tool);
|
consts.tool_name = toolNameByNumber(out.tool);
|
||||||
filterEmit(cmdToolChange, { ...consts, spindle: newSpindle } );
|
if (!lasering) {
|
||||||
|
filterEmit(cmdToolChange, { ...consts, spindle: newSpindle } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on spindle change (deferred from layer transition so it's post-toolchange)
|
// on spindle change (deferred from layer transition so it's post-toolchange)
|
||||||
if ((changeTool && spindleMax) || (newSpindle && newSpindle !== spindle)) {
|
if ((changeTool && spindleMax) || (newSpindle && newSpindle !== spindle)) {
|
||||||
spindle = newSpindle;
|
spindle = newSpindle;
|
||||||
if (spindle > 0) {
|
if (!lasering) {
|
||||||
let speed = Math.abs(spindle);
|
if (spindle > 0) {
|
||||||
filterEmit(cmdSpindle, { speed, spindle: speed, rpm: speed });
|
let speed = Math.abs(spindle);
|
||||||
} else {
|
filterEmit(cmdSpindle, { speed, spindle: speed, rpm: speed });
|
||||||
append("M4");
|
} else {
|
||||||
|
append("M4");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,7 +255,7 @@ CAM.export = function(print, online) {
|
||||||
|
|
||||||
if (!lasering && laser) {
|
if (!lasering && laser) {
|
||||||
// enable laser
|
// enable laser
|
||||||
filterEmit(currentOp.camLaserOn, consts);
|
filterEmit(laserOp.on, consts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (laser && pos.emit !== out.emit) {
|
// if (laser && pos.emit !== out.emit) {
|
||||||
|
|
@ -264,7 +269,7 @@ CAM.export = function(print, online) {
|
||||||
|
|
||||||
if (lasering && !laser) {
|
if (lasering && !laser) {
|
||||||
// disable laser
|
// disable laser
|
||||||
filterEmit(currentOp.camLaserOff, consts);
|
filterEmit(laserOp.off, consts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update lasering state
|
// update lasering state
|
||||||
|
|
@ -302,14 +307,21 @@ CAM.export = function(print, online) {
|
||||||
let toolz = {}, ctool;
|
let toolz = {}, ctool;
|
||||||
// remap points as necessary for origins, offsets, inversions
|
// remap points as necessary for origins, offsets, inversions
|
||||||
print.output.forEach(function(layer) {
|
print.output.forEach(function(layer) {
|
||||||
if (layer.op) {
|
|
||||||
console.log({ op: layer.op });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Array.isArray(layer)) {
|
if (!Array.isArray(layer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
layer.forEach(function(out) {
|
layer.forEach(function(out) {
|
||||||
|
if (out.op) {
|
||||||
|
if (out.op.type === 'laser on') {
|
||||||
|
laserOp = out.op;
|
||||||
|
// lasering = true;
|
||||||
|
// console.log('laser on');
|
||||||
|
} else if (out.op.type === 'laser off') {
|
||||||
|
// lasering = false;
|
||||||
|
// console.log('laser off');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (out.tool && out.tool !== ctool) {
|
if (out.tool && out.tool !== ctool) {
|
||||||
ctool = toolByNumber(out.tool);
|
ctool = toolByNumber(out.tool);
|
||||||
toolz[out.tool] = ctool;
|
toolz[out.tool] = ctool;
|
||||||
|
|
@ -354,7 +366,7 @@ CAM.export = function(print, online) {
|
||||||
if (mode) {
|
if (mode) {
|
||||||
section(`op-${opnum++}-${mode}`);
|
section(`op-${opnum++}-${mode}`);
|
||||||
}
|
}
|
||||||
if (!stripComments) {
|
if (!stripComments && mode) {
|
||||||
append("; starting " + mode + " op");
|
append("; starting " + mode + " op");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class OpLaserOn extends CamOp {
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
ops.addGCode(this.op.enable);
|
ops.addGCode(this.op.enable);
|
||||||
ops.setLasering(true, this.op.power);
|
ops.setLasering(true, this.op.power);
|
||||||
|
ops.newLayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@ class OpLaserOff extends CamOp {
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
ops.addGCode(this.op.disable);
|
ops.addGCode(this.op.disable);
|
||||||
ops.setLasering(false);
|
ops.setLasering(false);
|
||||||
|
ops.newLayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,8 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
};
|
};
|
||||||
}) : zmax;
|
}) : zmax;
|
||||||
|
|
||||||
|
newOutput.push(layerOut);
|
||||||
|
|
||||||
function newLayer() {
|
function newLayer() {
|
||||||
if (layerOut.length < 2) {
|
if (layerOut.length < 2) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -134,6 +136,9 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
if (!text || text.length === 0) {
|
if (!text || text.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Array.isArray(text)) {
|
||||||
|
text = text.join('\r\n');
|
||||||
|
}
|
||||||
newOutput.push(text);
|
newOutput.push(text);
|
||||||
if (layerOut.length) {
|
if (layerOut.length) {
|
||||||
layerOut = [];
|
layerOut = [];
|
||||||
|
|
@ -420,7 +425,8 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
nextIsMove = true;
|
nextIsMove = true;
|
||||||
lastMode = op.op.type;
|
lastMode = op.op.type;
|
||||||
let weight = op.weight();
|
let weight = op.weight();
|
||||||
layerOut.push({ op });
|
newLayer();
|
||||||
|
layerOut.push({ op: op.op });
|
||||||
op.prepare(ops, (progress, message) => {
|
op.prepare(ops, (progress, message) => {
|
||||||
update((opSum + (progress * weight)) / opTot, message || op.type(), message);
|
update((opSum + (progress * weight)) / opTot, message || op.type(), message);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,11 @@ async function path(levels, update, opts = {}) {
|
||||||
lastOut = out;
|
lastOut = out;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!lastOut) {
|
||||||
|
// laser levels alone
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lastEnd = lastOut;
|
lastEnd = lastOut;
|
||||||
|
|
||||||
// all moves with an emit at the very end (common in contouring)
|
// all moves with an emit at the very end (common in contouring)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue