Skip to content

Commit

Permalink
Use profile penUp instead of hardcoded values. Closes #178
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed Aug 17, 2023
1 parent d40ae9b commit 0cb1b05
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,22 +598,19 @@ 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) => {
paths.forEach((p) => {
const m = constantAccelerationPlan(p, profile.penDownProfile);
const penUpPos = i === paths.length - 1 ? Axidraw.penPctToPos(penMaxUpPos) : profile.penUpPos;
motions.push(
constantAccelerationPlan([curPos, m.p1], profile.penUpProfile),
new PenMotion(profile.penUpPos, profile.penDownPos, profile.penDropDuration),
m,
new PenMotion(profile.penDownPos, penUpPos, profile.penLiftDuration)
new PenMotion(profile.penDownPos, profile.penUpPos, profile.penLiftDuration)
);
curPos = m.p2;
});
// finally, move back to (0, 0).
motions.push(constantAccelerationPlan([curPos, {x: 0, y: 0}], profile.penUpProfile));
motions.push(new PenMotion(Axidraw.penPctToPos(penMaxUpPos), profile.penUpPos, profile.penDropDuration));
return new Plan(motions);
}

0 comments on commit 0cb1b05

Please sign in to comment.