diff --git a/packages/axidraw/src/api.ts b/packages/axidraw/src/api.ts index 294c20e8b1..7ad5a6f067 100644 --- a/packages/axidraw/src/api.ts +++ b/packages/axidraw/src/api.ts @@ -36,6 +36,9 @@ export type MoveXYCommand = ["m", ReadonlyVec, number?]; /** Explicit delay (in ms) */ export type WaitCommand = ["w", number]; +/** Ignored, but will be logged (if logging enabled) */ +export type CommentCommand = ["comment", string]; + export type DrawCommand = | StartCommand | StopCommand @@ -45,7 +48,8 @@ export type DrawCommand = | PenConfigCommand | PenUpDownCommand | MoveXYCommand - | WaitCommand; + | WaitCommand + | CommentCommand; /** * Global plotter drawing configuration. Also see {@link DEFAULT_OPTS}. @@ -176,6 +180,32 @@ export const ON: MotorCommand = ["on"]; export const OFF: MotorCommand = ["off"]; +/** + * Creates a {@link MoveXYCommand} command. + * + * @param pos + * @param speed + */ +export const MOVE = (pos: ReadonlyVec, speed = 1): MoveXYCommand => [ + "m", + pos, + speed, +]; + +/** + * Creates a {@link WaitCommand}. + * + * @param delay + */ +export const WAIT = (delay = 1000): WaitCommand => ["w", delay]; + +/** + * Creates a {@link CommentCommand}. + * + * @param msg + */ +export const COMMENT = (msg = ""): CommentCommand => ["comment", msg]; + /** * FSM state enum for (interactive) control for processing of drawing commands. * See {@link AxiDraw.draw} and {@link AxiDrawControl} for details. diff --git a/packages/axidraw/src/axidraw.ts b/packages/axidraw/src/axidraw.ts index 1fe84f3f42..4357c8625b 100644 --- a/packages/axidraw/src/axidraw.ts +++ b/packages/axidraw/src/axidraw.ts @@ -222,6 +222,9 @@ export class AxiDraw implements IReset { [wait, dist] = this.moveTo(a, b); $recordDist(dist); break; + case "comment": + logger.info(`comment: ${a}`); + break; default: unsupported(`unknown command: ${$cmd}`); }