add annotations necessary to allow object cancellation during print
This commit is contained in:
parent
c6355dfa61
commit
4d6b72d81d
7 changed files with 103 additions and 23 deletions
|
|
@ -14,14 +14,20 @@ const { getRangeParameters } = FDM;
|
|||
const debug = false;
|
||||
|
||||
FDM.export = function(print, online, ondone, ondebug) {
|
||||
const { settings, belty, tools, firstTool } = print;
|
||||
const { widgets, settings, belty, tools, firstTool } = print;
|
||||
const { bounds, controller, device, process, filter, mode } = settings;
|
||||
const { extruders, fwRetract } = device;
|
||||
const { bedWidth, bedDepth, bedRound, bedBelt, maxHeight } = device;
|
||||
const { gcodeFan, gcodeLayer, gcodeTrack, gcodePause, gcodeFeature } = device;
|
||||
|
||||
let model_labels = [];
|
||||
for (let widget of widgets) {
|
||||
model_labels.push(widget.track.grid_id);
|
||||
}
|
||||
|
||||
let layers = print.output,
|
||||
extras = device.extras || {},
|
||||
isBambu = extras.bbl,
|
||||
{ extrudeAbs } = device,
|
||||
{ exportThumb } = controller,
|
||||
extused = Object.keys(print.extruders).map(v => parseInt(v)),
|
||||
|
|
@ -108,7 +114,8 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
layers: layers.length,
|
||||
progress: 0,
|
||||
nozzle: tool,
|
||||
tool: tool
|
||||
tool: tool,
|
||||
model_labels: model_labels.sort().join(',')
|
||||
},
|
||||
pidx, path, out, speedMMM, emitMM, emitPerMM, lastp, laste, dist,
|
||||
lines = 0,
|
||||
|
|
@ -588,11 +595,36 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
moveTo({z:zpos}, seekMMM);
|
||||
}
|
||||
|
||||
function encodeOffset(index) {
|
||||
let bytes = new Uint8Array(8);
|
||||
let byteIndex = Math.floor(index / 8);
|
||||
let bitPosition = index % 8;
|
||||
bytes[byteIndex] |= (1 << bitPosition);
|
||||
return btoa(String.fromCharCode(...bytes));
|
||||
}
|
||||
|
||||
let cwidget;
|
||||
// iterate through layer outputs
|
||||
for (pidx=0; pidx<path.length; pidx++) {
|
||||
out = path[pidx];
|
||||
speedMMM = (out.speed || process.outputFeedrate) * 60; // range
|
||||
|
||||
// hint to controller that we're working on a specific object
|
||||
// so that gcode between start/stop comments can be cancelled
|
||||
if (out.widget !== cwidget) {
|
||||
if (cwidget) {
|
||||
append(`; end object id: ${cwidget.track.grid_id}`);
|
||||
isBambu && append('M625');
|
||||
}
|
||||
if (out.widget) {
|
||||
let off = model_labels.indexOf(out.widget.track.grid_id);
|
||||
let b64 = encodeOffset(off);
|
||||
append(`; start object id: ${out.widget.track.grid_id}`);
|
||||
isBambu && append(`M624 ${b64}`);
|
||||
}
|
||||
cwidget = out.widget;
|
||||
}
|
||||
|
||||
// emit comment on output type chage
|
||||
if (last && out.type !== last.type) {
|
||||
lastType = subst.feature = out.type;
|
||||
|
|
@ -791,6 +823,11 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
laste = out.emit;
|
||||
}
|
||||
layer++;
|
||||
if (cwidget) {
|
||||
append(`; end object id: ${cwidget.track.grid_id}`);
|
||||
isBambu && append('M625');
|
||||
cwidget = undefined;
|
||||
}
|
||||
|
||||
// end open loop when detected
|
||||
while (endloop-- > 0) {
|
||||
|
|
@ -949,6 +986,7 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
print.lines = lines;
|
||||
print.bytes = bytes + lines - 1;
|
||||
print.time = time;
|
||||
print.labels = model_labels;
|
||||
|
||||
if (debug) {
|
||||
console.log('segments', segments);
|
||||
|
|
|
|||
|
|
@ -549,6 +549,7 @@ FDM.prepare = async function(widgets, settings, update) {
|
|||
let beltStart = slice.belt && slice.belt.touch;// && (widgets.length === 1);
|
||||
// output seek to start point between mesh slices if previous data
|
||||
print.setType('layer');
|
||||
print.setWidget(lastWidget);
|
||||
printPoint = slicePrintPath(
|
||||
print,
|
||||
slice,
|
||||
|
|
@ -579,6 +580,7 @@ FDM.prepare = async function(widgets, settings, update) {
|
|||
}
|
||||
}
|
||||
);
|
||||
print.setWidget(null);
|
||||
|
||||
lastOut = slice;
|
||||
lastExt = lastOut.extruder;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,19 @@ FDM.sliceAll = function(settings, onupdate) {
|
|||
.sort((a,b) => {
|
||||
return a.slices[0].z - b.slices[0].z
|
||||
});
|
||||
// assign grid_id which can be embedded in gcode and
|
||||
// used by the controller to cancel objects during print
|
||||
let { bounds } = settings;
|
||||
for (let widget of widgets) {
|
||||
let { pos, box } = widget.track;
|
||||
// calculate top/left coordinate for widget
|
||||
// relative to bounding box for all widgets
|
||||
let tl = {
|
||||
x: Math.round((pos.x - box.w/2 - bounds.min.x) / 10) + 1,
|
||||
y: Math.round((pos.y - box.h/2 - bounds.min.y) / 10) + 1
|
||||
};
|
||||
widget.track.grid_id = tl.x * 100 + tl.y;
|
||||
}
|
||||
// count extruders used
|
||||
let ext = [];
|
||||
for (let w of widgets) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue