add separate speed for polishing moves

This commit is contained in:
Stewart Allen 2020-03-05 22:26:33 -05:00
commit de525f00fa
3 changed files with 30 additions and 16 deletions

View file

@ -161,7 +161,7 @@ var gs_kiri_fdm = exports;
}, "infill"); }, "infill");
} }
let polish = spro.layerPolishing; let polish = spro.polishLayers;
// experimental polishing // experimental polishing
if (polish) { if (polish) {
let polish_layer = Math.floor(polish); let polish_layer = Math.floor(polish);
@ -198,7 +198,13 @@ var gs_kiri_fdm = exports;
// console.log({polish_update}); // console.log({polish_update});
}); });
// apply polishing finishes to layers // apply polishing finishes to layers
forSlices(1.0, 1.0, slice => { forSlices(1.0, 1.0, (slice) => {
if (polish_layer >= 2) {
let sai = (slice.index - polish_layer);
if (sai % (polish_layer-1) !== 0) {
return;
}
}
if (slice.index >= polish_layer) { if (slice.index >= polish_layer) {
let sd = slice; let sd = slice;
for (let i=0; i<polish_layer; i++) { for (let i=0; i<polish_layer; i++) {
@ -228,10 +234,12 @@ var gs_kiri_fdm = exports;
return; return;
} }
// order points lowest to highest // order points lowest to highest
let swap = false;
if (p1.z > p2.z) { if (p1.z > p2.z) {
let t = p2; let t = p2;
p2 = p1; p2 = p1;
p1 = t; p1 = t;
swap = true;
} }
let trimlo = false; let trimlo = false;
let trimhi = false; let trimhi = false;
@ -250,8 +258,8 @@ var gs_kiri_fdm = exports;
p2 = BASE.newPoint(p2.x,p2.z,p2.y); p2 = BASE.newPoint(p2.x,p2.z,p2.y);
} }
let slope = BASE.newSlope(p1, p2); let slope = BASE.newSlope(p1, p2);
let angle = Math.abs(slope.angle); let angle = slope.angle;
if (angle > 40 && angle < 140) { if (angle > 80 && angle < 100) {
return; return;
} }
let len = p1.distTo2D(p2); let len = p1.distTo2D(p2);
@ -281,7 +289,8 @@ var gs_kiri_fdm = exports;
if (!lastp) { if (!lastp) {
poly.push(p1); poly.push(p1);
poly.push(p2); poly.push(p2);
} else if (p1.isEqual(lastp)) { } else if (p1.isMergable2D(lastp)) {
// } else if (p1.isEqual(lastp)) {
poly.push(p2); poly.push(p2);
cont++; cont++;
} else if (poly.length) { } else if (poly.length) {
@ -296,17 +305,17 @@ var gs_kiri_fdm = exports;
}); });
pout.push(polys); pout.push(polys);
polys = []; polys = [];
}); });
if (pout.length && slice.tops.length) { if (pout.length && slice.tops.length) {
slice.tops[0].polish = { slice.tops[0].polish = {
x: pout[0] x: pout[0]
.map(a => BASE.newPolygon(a).setOpen()) .map(a => BASE.newPolygon(a).setOpen())
.filter(p => p.perimeter() > sdev.nozzleSize), // .filter(p => p.perimeter() > sdev.nozzleSize)
,
y: pout[1] y: pout[1]
.map(a => BASE.newPolygon(a).setOpen()) .map(a => BASE.newPolygon(a).setOpen())
.filter(p => p.perimeter() > sdev.nozzleSize) // .filter(p => p.perimeter() > sdev.nozzleSize)
}; };
} }
} }
@ -812,7 +821,9 @@ var gs_kiri_fdm = exports;
moveTo({x:x, y:y, e:emitMM}, speedMMM); moveTo({x:x, y:y, e:emitMM}, speedMMM);
emitted += emitMM; emitted += emitMM;
} else { } else {
moveTo({x:x, y:y, z:z}, seekMMM); // when making z moves (like polishing) allow slowdown vs fast seek
let moveSpeed = (lastp && lastp.z !== z) ? speedMMM : seekMMM;
moveTo({x:x, y:y, z:z}, moveSpeed);
} }
// retract filament // retract filament

View file

@ -597,7 +597,7 @@ var gs_kiri_print = exports;
/** /**
* @param {Polygon[]} polys * @param {Polygon[]} polys
*/ */
function outputSparse(polys, extrude) { function outputSparse(polys, extrude, speed) {
if (!polys) return; if (!polys) return;
var proxy = polys.map(function(poly) { var proxy = polys.map(function(poly) {
return {poly: poly, first: poly.first(), last: poly.last()}; return {poly: poly, first: poly.first(), last: poly.last()};
@ -611,7 +611,7 @@ var gs_kiri_print = exports;
if (i === 0 && lp && lp.distTo2D(p) > retractDist && intersectsTop(lp,p)) { if (i === 0 && lp && lp.distTo2D(p) > retractDist && intersectsTop(lp,p)) {
retract(); retract();
} }
addOutput(preout, p, i === 0 ? 0 : extrude, printSpeed); addOutput(preout, p, i === 0 ? 0 : extrude, speed || printSpeed);
lp = p; lp = p;
}); });
}); });
@ -806,10 +806,10 @@ var gs_kiri_print = exports;
if (slice.tops.length && slice.tops[0].polish) { if (slice.tops.length && slice.tops[0].polish) {
let {x,y} = slice.tops[0].polish; let {x,y} = slice.tops[0].polish;
if (x) { if (x) {
outputSparse(x, 0); outputSparse(x, 0, process.polishSpeed);
} }
if (y) { if (y) {
outputSparse(y, 0); outputSparse(y, 0, process.polishSpeed);
} }
} }

View file

@ -103,7 +103,8 @@ self.kiri.license = exports.LICENSE;
// detectThinWalls: 1, // detectThinWalls: 1,
antiBacklash: 1, antiBacklash: 1,
zHopDistance: 1, zHopDistance: 1,
layerPolishing: 1, polishLayers: 1,
polishSpeed: 1,
outputLayerRetract: 1, outputLayerRetract: 1,
gcodeNozzle: 1, gcodeNozzle: 1,
gcodePauseLayers: 1, gcodePauseLayers: 1,
@ -339,7 +340,8 @@ self.kiri.license = exports.LICENSE;
detectThinWalls: false, detectThinWalls: false,
antiBacklash: 1, antiBacklash: 1,
zHopDistance: 0.2, zHopDistance: 0.2,
layerPolishing: 0, polishLayers: 0,
polishSpeed: 40,
outputLayerRetract: false, outputLayerRetract: false,
gcodeNozzle: 0, gcodeNozzle: 0,
gcodePauseLayers: "", gcodePauseLayers: "",
@ -2898,7 +2900,8 @@ self.kiri.license = exports.LICENSE;
zHopDistance: UC.newInput("z hop dist", {title: "amount to raise z\non retraction moves\nin millimeters\n0 to disable", bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM, expert: true}), zHopDistance: UC.newInput("z hop dist", {title: "amount to raise z\non retraction moves\nin millimeters\n0 to disable", bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM, expert: true}),
antiBacklash: UC.newInput("anti-backlash", {title: "use micro-movements to cancel\nbacklash during fills\nin millimeters", bound:UC.bound(0,3), convert:UC.toInt, modes:FDM, expert: true}), antiBacklash: UC.newInput("anti-backlash", {title: "use micro-movements to cancel\nbacklash during fills\nin millimeters", bound:UC.bound(0,3), convert:UC.toInt, modes:FDM, expert: true}),
// detectThinWalls: UC.newBoolean("thin wall fill", onBooleanClick, {title: "detect and fill thin openings\nbetween shells walls", modes:FDM, expert: true}) // detectThinWalls: UC.newBoolean("thin wall fill", onBooleanClick, {title: "detect and fill thin openings\nbetween shells walls", modes:FDM, expert: true})
layerPolishing: LOCAL ? UC.newInput("layer polish", {title:"polish up to specified\n# of layers at a time", bound:UC.bound(0,10), convert:UC.toFloat, modes:FDM, expert: true}) : null, polishLayers: LOCAL ? UC.newInput("polish layers", {title:"polish up to specified\n# of layers at a time", bound:UC.bound(0,10), convert:UC.toFloat, modes:FDM, expert: true}) : null,
polishSpeed: LOCAL ? UC.newInput("polish speed", {title:"polishing speed\nin millimeters / minute", bound:UC.bound(10,2000), convert:UC.toInt, modes:FDM, expert: true}) : null,
outputLayerRetract: UC.newBoolean("layer retract", onBooleanClick, {title:"force filament retraction\nbetween layers", modes:FDM, expert: true}), outputLayerRetract: UC.newBoolean("layer retract", onBooleanClick, {title:"force filament retraction\nbetween layers", modes:FDM, expert: true}),
gcodeVars: UC.newGroup("gcode", null, {modes:FDM, expert: true}), gcodeVars: UC.newGroup("gcode", null, {modes:FDM, expert: true}),