allow nested M808 loops. expand object values in gcode. bump rev 3.0.D29

This commit is contained in:
Stewart Allen 2021-10-06 10:59:23 -04:00
commit 8cd62d8b44
5 changed files with 43 additions and 37 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "grid-apps", "name": "grid-apps",
"version": "3.0.28D", "version": "3.0.29D",
"description": "grid.space 3d slice & modeling tools", "description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>", "author": "Stewart Allen <sa@grid.space>",
"license": "MIT", "license": "MIT",

View file

@ -6,7 +6,7 @@
if (!self.kiri) { if (!self.kiri) {
self.kiri = { self.kiri = {
beta: 3028, beta: 3029,
driver: {}, // driver modules driver: {}, // driver modules
loader: [] // module loading: array of functions loader: [] // module loading: array of functions
}; };

View file

@ -3,7 +3,7 @@
let terms = { let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution", LICENSE: "See the license.md file included with the source distribution",
VERSION: "3.0.D28" VERSION: "3.0.D29"
}; };
if (typeof(module) === 'object') { if (typeof(module) === 'object') {

View file

@ -242,7 +242,7 @@
append(`; Target: ${settings.filter[settings.mode]}`); append(`; Target: ${settings.filter[settings.mode]}`);
append("; --- process ---"); append("; --- process ---");
for (let pk in spro) { for (let pk in spro) {
if (pk !== "ops") { if (pk !== "ops" && pk !== "op2") {
append("; " + pk + " = " + spro[pk]); append("; " + pk + " = " + spro[pk]);
} }
} }

View file

@ -108,7 +108,7 @@
bytes = 0, bytes = 0,
bcos = Math.cos(Math.PI/4), bcos = Math.cos(Math.PI/4),
icos = 1 / bcos, icos = 1 / bcos,
inLoop, inloops = 0,
arcQ = [], arcQ = [],
minz = { x: Infinity, y: Infinity, z: Infinity }; minz = { x: Infinity, y: Infinity, z: Infinity };
@ -142,16 +142,17 @@
}); });
} }
// collect loops from ranges and synth range array
let rloops = []; let rloops = [];
if (loops > 0) { if (loops > 0) {
// if loops set, loop entire part
rloops.push({ rloops.push({
start: layers[0].slice.index, start: layers[0].slice.index,
end: layers.last().slice.index, end: layers.last().slice.index,
iter: loops - 1 iter: loops - 1
}); });
} }
if (process.ranges) if (process.ranges) {
// collect loops from ranges and synth range array
for (let range of process.ranges) { for (let range of process.ranges) {
if (range.fields.outputLoops) { if (range.fields.outputLoops) {
rloops.push({ rloops.push({
@ -161,8 +162,9 @@
}); });
} }
} }
}
loops = isBelt && rloops.length ? rloops : undefined; loops = isBelt && rloops.length ? rloops : undefined;
console.log({loops});
(process.gcodePauseLayers || "").split(",").forEach(function(lv) { (process.gcodePauseLayers || "").split(",").forEach(function(lv) {
let v = parseInt(lv); let v = parseInt(lv);
if (v >= 0) pause.push(v); if (v >= 0) pause.push(v);
@ -200,6 +202,13 @@
arr.forEach(function(line) { appendSub(line, pad) }); arr.forEach(function(line) { appendSub(line, pad) });
} }
function appendTok() {
let arg = [...arguments].map(v => {
return typeof(v) === 'object' ? JSON.stringify(v) : v;
});
append(arg.join(''));
}
append(`; Generated by Kiri:Moto ${KIRI.version}`); append(`; Generated by Kiri:Moto ${KIRI.version}`);
append(`; ${new Date().toString()}`); append(`; ${new Date().toString()}`);
appendSub("; Bed left:{left} right:{right} top:{top} bottom:{bottom}"); appendSub("; Bed left:{left} right:{right} top:{top} bottom:{bottom}");
@ -217,7 +226,8 @@
} }
append("; --- process ---"); append("; --- process ---");
for (let pk in process) { for (let pk in process) {
append("; " + pk + " = " + process[pk]); // append("; " + pk + " = " + process[pk]);
appendTok("; ", pk, " = ", process[pk]);
} }
append("; --- startup ---"); append("; --- startup ---");
let t0 = false; let t0 = false;
@ -397,26 +407,23 @@
appendAllSub(pauseCmd) appendAllSub(pauseCmd)
} }
let endloop = false; let endloop = 0;
if (loops) { if (loops) {
if (inLoop) {
if (layerno === inLoop.end) {
endloop = true;
// append(`M808`);
// inLoop = undefined;
}
} else {
for (let loop of loops) { for (let loop of loops) {
if (layerno === loop.start) { if (layerno === loop.start && !loop.started) {
loop.started = true;
append(`M808 L${loop.iter}`); append(`M808 L${loop.iter}`);
if (extrudeAbs) { if (extrudeAbs) {
append(`G92 Z${lout.z.round(decimals)} E${outputLength.round(decimals)}`); append(`G92 Z${lout.z.round(decimals)} E${outputLength.round(decimals)}`);
} else { } else {
append(`G92 Z${lout.z.round(decimals)}`); append(`G92 Z${lout.z.round(decimals)}`);
} }
inLoop = loop; inloops++;
break;
} }
if (layerno === loop.end && !loop.ended) {
loop.ended = true;
endloop++;
inloops--;
} }
} }
} }
@ -649,9 +656,8 @@
layer++; layer++;
// end open loop when detected // end open loop when detected
if (endloop) { while (endloop-- > 0) {
append(`M808`); append(`M808`);
inLoop = undefined;
} }
drainQ(); drainQ();
} }
@ -784,7 +790,7 @@
} }
if (inLoop) { if (inloops) {
append(`M808`); append(`M808`);
} }