add range() function in gcode macro expressions

This commit is contained in:
Stewart Allen 2021-05-10 14:31:41 -04:00
commit aa0ccdaab2
2 changed files with 3 additions and 1 deletions

View file

@ -1278,7 +1278,8 @@
for (let [k,v] of Object.entries(consts)) {
eva.push(`let ${k} = "${v}";`);
}
eva.push(`try {( ${tok} )} catch (e) {0}`);
eva.push(`function range(a,b) { return (a + (layer / layers) * (b-a)).round(3) }`)
eva.push(`try {( ${tok} )} catch (e) {console.log(e);0}`);
let scr = eva.join('');
let evl = eval(`{ ${scr} }`);
nutok = evl;

View file

@ -92,6 +92,7 @@
bottom: offset ? 0 : -device.bedDepth/2,
z_max: device.maxHeight,
layers: layers.length,
progress: 0,
nozzle: 0,
tool: 0
},