patch up laser mode and layer transitions
This commit is contained in:
parent
91514aeb86
commit
829139c440
7 changed files with 57 additions and 52 deletions
|
|
@ -55,7 +55,6 @@ CAM.export = function(print, online) {
|
||||||
points = 0,
|
points = 0,
|
||||||
lasering = false,
|
lasering = false,
|
||||||
laserOp,
|
laserOp,
|
||||||
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,
|
||||||
ztOff = hasStock ? stock.z - widget.track.top : 0,
|
ztOff = hasStock ? stock.z - widget.track.top : 0,
|
||||||
|
|
@ -99,7 +98,12 @@ CAM.export = function(print, online) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterEmit(array, consts) {
|
function filterEmit(array, consts) {
|
||||||
if (!array) return;
|
if (!array) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof(array) === 'string') {
|
||||||
|
array = array.split('\n');
|
||||||
|
}
|
||||||
for (i=0; i<array.length; i++) {
|
for (i=0; i<array.length; i++) {
|
||||||
line = print.constReplace(array[i], consts);
|
line = print.constReplace(array[i], consts);
|
||||||
if (!isRML && stripComments && (cidx = line.indexOf(";")) >= 0) {
|
if (!isRML && stripComments && (cidx = line.indexOf(";")) >= 0) {
|
||||||
|
|
@ -168,7 +172,7 @@ 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);
|
||||||
if (!lasering) {
|
if (!laserOp) {
|
||||||
filterEmit(cmdToolChange, { ...consts, spindle: newSpindle } );
|
filterEmit(cmdToolChange, { ...consts, spindle: newSpindle } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +180,7 @@ CAM.export = function(print, online) {
|
||||||
// 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 (!lasering) {
|
if (!laserOp) {
|
||||||
if (spindle > 0) {
|
if (spindle > 0) {
|
||||||
let speed = Math.abs(spindle);
|
let speed = Math.abs(spindle);
|
||||||
filterEmit(cmdSpindle, { speed, spindle: speed, rpm: speed });
|
filterEmit(cmdSpindle, { speed, spindle: speed, rpm: speed });
|
||||||
|
|
@ -306,20 +310,12 @@ CAM.export = function(print, online) {
|
||||||
// collect tool info to add to header
|
// collect tool info to add to header
|
||||||
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(layer => {
|
||||||
if (!Array.isArray(layer)) {
|
if (!Array.isArray(layer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
layer.forEach(function(out) {
|
layer.forEach(out => {
|
||||||
if (out.op) {
|
if (out.gcode) {
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
if (out.tool && out.tool !== ctool) {
|
if (out.tool && out.tool !== ctool) {
|
||||||
|
|
@ -354,34 +350,47 @@ CAM.export = function(print, online) {
|
||||||
|
|
||||||
// emit all points in layer/point order
|
// emit all points in layer/point order
|
||||||
for (let layerout of print.output) {
|
for (let layerout of print.output) {
|
||||||
if (!Array.isArray(layerout)) {
|
const newmode = layerout.mode;
|
||||||
append(layerout.toString().trim());
|
if (newmode) {
|
||||||
continue;
|
if (newmode.type === 'laser on') {
|
||||||
}
|
laserOp = newmode;
|
||||||
if (mode !== layerout.mode || consts.tool !== layerout[0].tool) {
|
} else if (newmode.type === 'laser off') {
|
||||||
if (mode && !stripComments) {
|
laserOp = undefined;
|
||||||
append("; ending " + mode + " op after " + Math.round(time/60) + " seconds");
|
// force tool change in case laser tool matches next tool
|
||||||
|
pos.t = undefined;
|
||||||
}
|
}
|
||||||
mode = layerout.mode;
|
}
|
||||||
|
const firstOut = layerout[0];
|
||||||
|
if (newmode && !newmode.silent && mode !== newmode) {
|
||||||
|
if (mode && !stripComments) {
|
||||||
|
append("; ending " + mode.type + " op after " + Math.round(time/60) + " seconds");
|
||||||
|
}
|
||||||
|
mode = newmode;
|
||||||
if (mode) {
|
if (mode) {
|
||||||
section(`op-${opnum++}-${mode}`);
|
section(`op-${opnum++}-${mode.type}`);
|
||||||
}
|
}
|
||||||
if (!stripComments && mode) {
|
if (!stripComments && mode) {
|
||||||
append("; starting " + mode + " op");
|
append("; starting " + mode.type + " op");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newSpindle = layerout.spindle;
|
newSpindle = layerout.spindle;
|
||||||
|
// iterate over layer output records
|
||||||
for (let out of layerout) {
|
for (let out of layerout) {
|
||||||
if (out.op) {
|
if (out.gcode && Array.isArray(out.gcode)) {
|
||||||
currentOp = out.op;
|
filterEmit(out.gcode, consts);
|
||||||
continue;
|
} else {
|
||||||
|
moveTo(out);
|
||||||
}
|
}
|
||||||
moveTo(out);
|
}
|
||||||
|
if (lasering && laserOp) {
|
||||||
|
// disable laser
|
||||||
|
filterEmit(laserOp.off, consts);
|
||||||
|
lasering = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode && !stripComments) {
|
if (mode && !stripComments) {
|
||||||
append("; ending " + mode + " op after " + Math.round(time/60) + " seconds");
|
append("; ending " + mode.type + " op after " + Math.round(time/60) + " seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit gcode post
|
// emit gcode post
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,9 @@ class OpLaserOn extends CamOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
|
this.op.silent = true;
|
||||||
ops.addGCode(this.op.enable);
|
ops.addGCode(this.op.enable);
|
||||||
ops.setLasering(true, this.op.power);
|
ops.setLasering(true, this.op.power);
|
||||||
ops.newLayer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,9 +66,9 @@ class OpLaserOff extends CamOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
|
this.op.silent = true;
|
||||||
ops.addGCode(this.op.disable);
|
ops.addGCode(this.op.disable);
|
||||||
ops.setLasering(false);
|
ops.setLasering(false);
|
||||||
ops.newLayer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,26 +120,23 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
};
|
};
|
||||||
}) : zmax;
|
}) : zmax;
|
||||||
|
|
||||||
newOutput.push(layerOut);
|
function newLayer(op) {
|
||||||
|
if (layerOut.length || layerOut.mode) {
|
||||||
function newLayer() {
|
newOutput.push(layerOut);
|
||||||
if (layerOut.length < 2) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
newOutput.push(layerOut);
|
|
||||||
layerOut = [];
|
layerOut = [];
|
||||||
layerOut.mode = lastMode;
|
layerOut.mode = op || lastMode;
|
||||||
layerOut.spindle = spindle;
|
layerOut.spindle = spindle;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addGCode(text) {
|
function addGCode(text) {
|
||||||
if (!text || text.length === 0) {
|
if (!text && text.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Array.isArray(text)) {
|
if (!Array.isArray(text)) {
|
||||||
text = text.join('\r\n');
|
text = text.trim().split('\n');
|
||||||
}
|
}
|
||||||
newOutput.push(text);
|
newOutput.push([{ gcode: text }]);
|
||||||
if (layerOut.length) {
|
if (layerOut.length) {
|
||||||
layerOut = [];
|
layerOut = [];
|
||||||
layerOut.mode = lastMode;
|
layerOut.mode = lastMode;
|
||||||
|
|
@ -423,10 +420,9 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
for (let op of widget.camops) {
|
for (let op of widget.camops) {
|
||||||
setTolerance(0);
|
setTolerance(0);
|
||||||
nextIsMove = true;
|
nextIsMove = true;
|
||||||
lastMode = op.op.type;
|
lastMode = op.op;
|
||||||
let weight = op.weight();
|
let weight = op.weight();
|
||||||
newLayer();
|
newLayer(op.op);
|
||||||
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);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
|
|
||||||
let opList = [
|
let opList = [
|
||||||
// silently preface op list with OpShadow
|
// silently preface op list with OpShadow
|
||||||
new CAM.OPS.shadow(state, { type: "shadow" })
|
new CAM.OPS.shadow(state, { type: "shadow", silent: true })
|
||||||
];
|
];
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
|
|
|
||||||
|
|
@ -527,10 +527,10 @@ const conf = exports({
|
||||||
camRegisterThru: 5,
|
camRegisterThru: 5,
|
||||||
camFlipAxis: "X",
|
camFlipAxis: "X",
|
||||||
camFlipOther: "",
|
camFlipOther: "",
|
||||||
camLaserEnable: "M321",
|
camLaserEnable: ["M321"],
|
||||||
camLaserDisable: "M322",
|
camLaserDisable: ["M322"],
|
||||||
camLaserOn: "M3",
|
camLaserOn: ["M3"],
|
||||||
camLaserOff: "M5",
|
camLaserOff: ["M5"],
|
||||||
camLaserSpeed: 100,
|
camLaserSpeed: 100,
|
||||||
camLaserPower: 1,
|
camLaserPower: 1,
|
||||||
// camDrillReg: "none",
|
// camDrillReg: "none",
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ function prepareSlices(callback, scale = 1, offset = 0) {
|
||||||
process.beltAnchor = Math.max(
|
process.beltAnchor = Math.max(
|
||||||
process.firstLayerBeltLead,
|
process.firstLayerBeltLead,
|
||||||
Math.sqrt(process.outputPurgeTower) * extruders.length * (1/Math.sqrt(2)));
|
Math.sqrt(process.outputPurgeTower) * extruders.length * (1/Math.sqrt(2)));
|
||||||
} else {
|
} else if (isBelt) {
|
||||||
process.beltAnchor = process.firstLayerBeltLead;
|
process.beltAnchor = process.firstLayerBeltLead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,8 +141,8 @@ async function path(levels, update, opts = {}) {
|
||||||
let emits = 0;
|
let emits = 0;
|
||||||
|
|
||||||
level.forEach(out => {
|
level.forEach(out => {
|
||||||
// skip cam op records
|
// skip cam gcode records
|
||||||
if (out.op) {
|
if (out.gcode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (retracted && out.emit) {
|
if (retracted && out.emit) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue