Skip to content

Commit

Permalink
fix: invert last pen-motion when up/down positions are inverted
Browse files Browse the repository at this point in the history
Closes #87
  • Loading branch information
nornagon committed Jul 4, 2021
1 parent cb8e0c4 commit c6bd5a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,12 @@ export function plan(
): Plan {
const motions: Motion[] = [];
let curPos = { x: 0, y: 0 };
const penMaxUpPos = profile.penUpPos < profile.penDownPos ? 100 : 0
// for each path: move to the initial point, put the pen down, draw the path,
// then pick the pen up.
paths.forEach((p, i) => {
const m = constantAccelerationPlan(p, profile.penDownProfile);
const penUpPos = i === paths.length - 1 ? Device.Axidraw.penPctToPos(0) : profile.penUpPos;
const penUpPos = i === paths.length - 1 ? Device.Axidraw.penPctToPos(penMaxUpPos) : profile.penUpPos;
motions.push(
constantAccelerationPlan([curPos, m.p1], profile.penUpProfile),
new PenMotion(profile.penUpPos, profile.penDownPos, profile.penDropDuration),
Expand All @@ -578,6 +579,6 @@ export function plan(
});
// finally, move back to (0, 0).
motions.push(constantAccelerationPlan([curPos, {x: 0, y: 0}], profile.penUpProfile));
motions.push(new PenMotion(Device.Axidraw.penPctToPos(0), profile.penUpPos, profile.penDropDuration));
motions.push(new PenMotion(Device.Axidraw.penPctToPos(penMaxUpPos), profile.penUpPos, profile.penDropDuration));
return new Plan(motions);
}

0 comments on commit c6bd5a7

Please sign in to comment.