fix starting extruder for anchors, purge tower scaling on belt

This commit is contained in:
Stewart Allen 2021-11-17 13:46:01 -05:00
commit 1bdea68a00
4 changed files with 55 additions and 44 deletions

View file

@ -470,17 +470,25 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
let driveInfo = {}; let driveInfo = {};
let volume = {}; let volume = {};
let length = {}; let length = {};
// clean up and round pings
pings.forEach(p => {
p.length = p.length.round(2);
p.extrusion = p.extrusion.round(2);
});
// add length push filament to the last segment // add length push filament to the last segment
// console.log({device, pinfo});
segments.peek().emitted += pinfo.push; segments.peek().emitted += pinfo.push;
let lastEmit = 0;
for (let seg of segments) { for (let seg of segments) {
let seginfo = driveInfo[seg.tool] = driveInfo[seg.tool] || { length: 0, volume: 0 }; let seginfo = driveInfo[seg.tool] = driveInfo[seg.tool] || { length: 0, volume: 0 };
seginfo.length += seg.emitted; seginfo.length += seg.emitted - lastEmit;
seginfo.volume += seg.emitted * Math.PI; seginfo.volume = seginfo.length * Math.PI;
volume[seg.tool+1] = seginfo.volume + 2; // prepad 2mm volume[seg.tool+1] = (seginfo.volume + 2).round(2); // prepad 2mm
length[seg.tool+1] = seginfo.length; length[seg.tool+1] = seginfo.length.round(2);
lastEmit = seg.emitted;
} }
let totalVolume = Object.values(volume).reduce((a,v) => a+v); let totalLength = Object.values(length).reduce((a,v) => a+v).round(2);
let totalVolume = Object.values(volume).reduce((a,v) => a+v).round(2);
// console.log({info, device, pinfo, segments, volume, length, totalLength});
let meta = { let meta = {
version: "3.2", version: "3.2",
printerProfile: { printerProfile: {
@ -554,7 +562,7 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
KIRI.work.png({}, data => { KIRI.work.png({}, data => {
png = data.png; png = data.png;
}); });
// console.log({meta,palette}); console.log({meta,palette});
downloadPalette.onclick = function() { downloadPalette.onclick = function() {
KIRI.client.zip([ KIRI.client.zip([
{name:"meta.json", data:JSON.stringify(meta,undefined,4)}, {name:"meta.json", data:JSON.stringify(meta,undefined,4)},

View file

@ -1666,7 +1666,7 @@
], {modes:FDM, class:"dev-buttons ext-buttons"}), ], {modes:FDM, class:"dev-buttons ext-buttons"}),
palette: UC.newGroup(LANG.dv_gr_pal, $('palette3'), {group:"dext", inline:true, modes:FDM}), palette: UC.newGroup(LANG.dv_gr_pal, $('palette3'), {group:"dext", inline:true, modes:FDM}),
paletteId: UC.newInput(LANG.dv_paid_s, {title:LANG.dv_paid_l, modes:FDM, size:15}), paletteId: UC.newInput(LANG.dv_paid_s, {title:LANG.dv_paid_l, modes:FDM, size:15, text:true}),
palettePing: UC.newInput(LANG.dv_paps_s, {title:LANG.dv_paps_l, modes:FDM, convert:UC.toInt}), palettePing: UC.newInput(LANG.dv_paps_s, {title:LANG.dv_paps_l, modes:FDM, convert:UC.toInt}),
paletteFeed: UC.newInput(LANG.dv_pafe_s, {title:LANG.dv_pafe_l, modes:FDM, convert:UC.toInt}), paletteFeed: UC.newInput(LANG.dv_pafe_s, {title:LANG.dv_pafe_l, modes:FDM, convert:UC.toInt}),
palettePush: UC.newInput(LANG.dv_papl_s, {title:LANG.dv_papl_l, modes:FDM, convert:UC.toInt}), palettePush: UC.newInput(LANG.dv_papl_s, {title:LANG.dv_papl_l, modes:FDM, convert:UC.toInt}),

View file

@ -244,40 +244,42 @@
} }
// determine size/location of purge blocks // determine size/location of purge blocks
let blokw = Math.sqrt(purgeTower), let blokw = Math.sqrt(purgeTower);
blokh = blokw; let blokh = blokw;
let stepw = blokw + nozzle / 2;
let blokpos, walkpos, blok; let blokpos, walkpos, blok;
function mkblok(w,h) {
let stepw = w + nozzle / 2;
if (bounds.min.x < bounds.min.y && !isBelt) { if (bounds.min.x < bounds.min.y && !isBelt) {
let mx = (bounds.max.x + bounds.min.x) / 2; let mx = (bounds.max.x + bounds.min.x) / 2;
let px = mx - (extcount * blokw) / 2 + (blokw / 2); let px = mx - (extcount * w) / 2 + (w / 2);
let dx = ((bounds.max.x - bounds.min.x) - (extcount * blokw)) / 2; let dx = ((bounds.max.x - bounds.min.x) - (extcount * w)) / 2;
blokpos = { x:px, y: bounds.max.y + 2 + blokh / 2}; blokpos = { x:px, y: bounds.max.y + 2 + h / 2};
walkpos = { x:stepw, y:0 }; walkpos = { x:stepw, y:0 };
blok = { x:blokw, y:blokh }; blok = { x:w, y:h };
} else { } else {
let my = (bounds.max.y + bounds.min.y) / 2; let my = (bounds.max.y + bounds.min.y) / 2;
let mp = (extcount * blokw) / 2 + (blokw / 2); let mp = (extcount * w) / 2 + (w / 2);
let py = my - mp; let py = my - mp;
blokpos = { x:bounds.max.x + 2 + blokh / 2, y:isBelt ? -mp : py}; blokpos = { x:bounds.max.x + 2 + h / 2, y:isBelt ? -mp : py};
walkpos = { x:0, y:stepw }; walkpos = { x:0, y:stepw };
blok = { x:blokh, y:blokw }; blok = { x:h, y:w };
}
} }
// replace extruders array with object array containing more info function mkrec(i, angle = 45) {
extruders = extruders.map((ext,i) => { blokpos.x += walkpos.x * i;
if (!ext) return ext; blokpos.y += walkpos.y * i;
let exi = device.extruders[i], let exi = device.extruders[i],
noz = exi.extNozzle, noz = exi.extNozzle,
pos = {x:blokpos.x, y:blokpos.y, z:0}, pos = {x:blokpos.x, y:blokpos.y, z:0},
rect = newPolygon().centerRectangle(pos, blok.x, blok.y), rect = newPolygon().centerRectangle(pos, blok.x, blok.y),
full = linesToPoly(POLY.fillArea([ full = linesToPoly(POLY.fillArea([
newPolygon().centerRectangle(pos, blok.x - noz, blok.y - noz) newPolygon().centerRectangle(pos, blok.x - noz, blok.y - noz)
], 45, noz)), ], angle, noz)),
sparse = linesToPoly(POLY.fillArea([ sparse = linesToPoly(POLY.fillArea([
newPolygon().centerRectangle(pos, blok.x - noz, blok.y - noz) newPolygon().centerRectangle(pos, blok.x - noz, blok.y - noz)
], 135, noz * 5)), ], angle + 90, noz * 5)),
rec = { rec = {
extruder: i, extruder: i,
diameter: exi.extNozzle, diameter: exi.extNozzle,
@ -285,9 +287,14 @@
full, full,
sparse sparse
}; };
blokpos.x += walkpos.x;
blokpos.y += walkpos.y;
return rec; return rec;
}
mkblok(blokw, blokh);
// replace extruders array with object array containing more info
extruders = extruders.map((ext,i) => {
return ext ? mkrec(i) : ext;
}); });
function linesToPoly(points) { function linesToPoly(points) {
@ -326,19 +333,14 @@
layer.last().retract = true; layer.last().retract = true;
} }
let purgeOn = (!isBelt && first) || !thin; let purgeOn = (!isBelt && first) || !thin;
if (isBelt && z < 0) {
let scale = 1 + ((z / blokw));
mkblok(blokw * scale, blokh);
rec = mkrec(rec.extruder, 0);
}
let box = rec.rect.clone().setZ(z); let box = rec.rect.clone().setZ(z);
let fill = (purgeOn ? rec.full : rec.sparse).clone().setZ(z); let fill = (z >= 0 && purgeOn ? rec.full : rec.sparse).clone().setZ(z);
if (isBelt) { if (isBelt) {
let scale = z >= 0 ? 0 : 1 + ((z / blokw));
if (scale) {
box.scale({x:1, y:scale, z:1});
let inset = box.offset(rec.diameter/2);
if (inset) {
fill = linesToPoly(POLY.fillArea(inset, 90, rec.diameter * 5));
} else {
fill = undefined;
}
}
// offset by nozzle diameter + half step (shell) then angled // offset by nozzle diameter + half step (shell) then angled
let exo = rec.diameter * beltfact * 1.5; let exo = rec.diameter * beltfact * 1.5;
box.move({x:0, y:z - exo, z:0}); box.move({x:0, y:z - exo, z:0});
@ -354,7 +356,7 @@
simple: true, simple: true,
open: false, open: false,
}); });
if (fill) start = print.polyPrintPath(fill, start, layer, { if (fill && fill.length) start = print.polyPrintPath(fill, start, layer, {
tool, tool,
rate, rate,
simple: true, simple: true,

View file

@ -390,6 +390,7 @@
let addto = start.down; let addto = start.down;
if (!addto) { if (!addto) {
addto = newSlice(start.z - sliceHeight); addto = newSlice(start.z - sliceHeight);
addto.extruder = extruder;
addto.belt = { }; addto.belt = { };
addto.height = start.height; addto.height = start.height;
addto.up = start; addto.up = start;