Skip to content

Commit

Permalink
Add pen cli command to move the pen to a percent position (#92)
Browse files Browse the repository at this point in the history
* Add pen cli command to move the pen to a percent position

---------

Co-authored-by: Jonathan Dahan <[email protected]>
Co-authored-by: Alex Ruddick <[email protected]>
  • Loading branch information
3 people committed Oct 26, 2023
1 parent 391f6ab commit 5c3ba8b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as fs from "fs";
import {flattenSVG} from "flatten-svg";
import { Vec2 } from "./vec";
import { formatDuration } from "./util";
import { PlanOptions, defaultPlanOptions } from "./planning";
import { Device, PlanOptions, defaultPlanOptions } from "./planning";
import { PaperSize } from "./paper-size";

function parseSvg(svg: string) {
Expand Down Expand Up @@ -246,6 +246,21 @@ export function cli(argv: string[]): void {
await ebb.close()
}
)
.command('pen [percent]', 'put the pen to [percent]', yargs => yargs
.positional('percent', { type: 'number', description: 'percent height between 0 and 100', required: true})
.check(args => args.percent >= 0 && args.percent <= 100),
async args => {
console.log('connecting to plotter...')
const ebb = await connectEBB(args.device)
if (!ebb) {
console.error("Couldn't connect to device!")
process.exit(1)
}
await ebb.setPenHeight(Device.Axidraw.penPctToPos(args.percent), 1000)

console.log(`moving to ${args.percent}%...`)
await ebb.close()
})
.parse(argv);
}

Expand Down

0 comments on commit 5c3ba8b

Please sign in to comment.