@thi.ng/axidraw 0.5.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -1
- package/README.md +147 -15
- package/api.d.ts +57 -11
- package/api.js +0 -9
- package/axidraw.d.ts +17 -1
- package/axidraw.js +111 -21
- package/commands.d.ts +73 -0
- package/commands.js +94 -0
- package/dip.d.ts +70 -0
- package/dip.js +52 -0
- package/index.d.ts +4 -1
- package/index.js +4 -1
- package/package.json +19 -8
- package/palettes.d.ts +145 -0
- package/palettes.js +145 -0
- package/polyline.d.ts +1 -14
- package/polyline.js +8 -25
- package/{utils.d.ts → registration.d.ts} +2 -2
- package/registration.js +36 -0
- package/serial.d.ts +2 -0
- package/serial.js +6 -0
- package/utils.js +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-03-
|
|
3
|
+
- **Last updated**: 2023-03-22T22:24:21Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,70 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/axidraw@1.1.0) (2023-03-22)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add save/restore commands ([317f8e0](https://github.com/thi-ng/umbrella/commit/317f8e0))
|
|
17
|
+
- add/update command types
|
|
18
|
+
- add SAVE/RESTORE to store/restore pen levels
|
|
19
|
+
- update AxiDraw.draw() to restore state after one-off pen config
|
|
20
|
+
- update DipOpts & dip() ([52d8924](https://github.com/thi-ng/umbrella/commit/52d8924))
|
|
21
|
+
- rename `down` => `downDelay`, `up` => `upDelay`
|
|
22
|
+
- add `down`/`up` level opts
|
|
23
|
+
- update dip() impl to store/restore pen state if using custom
|
|
24
|
+
up/down levels for dipping
|
|
25
|
+
- add palette command seq gens ([0e453c1](https://github.com/thi-ng/umbrella/commit/0e453c1))
|
|
26
|
+
- add linearPalette() & radialPalette() and config options
|
|
27
|
+
- update pkg export maps
|
|
28
|
+
- add global clipping bounds option ([a99a58e](https://github.com/thi-ng/umbrella/commit/a99a58e))
|
|
29
|
+
- add AxiDrawOpts.clip
|
|
30
|
+
- add support for paper sizes, home offset ([c44510f](https://github.com/thi-ng/umbrella/commit/c44510f))
|
|
31
|
+
- update AxiDrawOpts.bounds to accept paper sizes ([@thi.ng/units](https://github.com/thi-ng/umbrella/tree/main/packages/units) quantities)
|
|
32
|
+
- add AxiDrawOpts.home
|
|
33
|
+
- update AxiDraw ctor & move/sendMove methods
|
|
34
|
+
- add AxiDraw.setHome()
|
|
35
|
+
- update pkg deps
|
|
36
|
+
|
|
37
|
+
#### ♻️ Refactoring
|
|
38
|
+
|
|
39
|
+
- remove obsolete clamping ([50978ba](https://github.com/thi-ng/umbrella/commit/50978ba))
|
|
40
|
+
- update linearPalette()
|
|
41
|
+
- update bounds handling/clamping ([7850ed6](https://github.com/thi-ng/umbrella/commit/7850ed6))
|
|
42
|
+
- precalc scale factor & bounds in ctor
|
|
43
|
+
|
|
44
|
+
# [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/axidraw@1.0.0) (2023-03-19)
|
|
45
|
+
|
|
46
|
+
#### 🛑 Breaking changes
|
|
47
|
+
|
|
48
|
+
- add/update command presets ([610f873](https://github.com/thi-ng/umbrella/commit/610f873))
|
|
49
|
+
- BREAKING CHANGE: update DrawCommands and cmd presets
|
|
50
|
+
- update MoveXYCommand to use `"M"`
|
|
51
|
+
- add MoveRelCommand (using `"m"`)
|
|
52
|
+
- add/update AxiDraw.moveTo()/moveRelative()
|
|
53
|
+
- migrate command presets to commands.ts
|
|
54
|
+
- refactor parametric command type presets as functions:
|
|
55
|
+
- PEN(), UP(), DOWN(), MOVE(), MOVE_REL(), WAIT(), COMMENT()
|
|
56
|
+
- add DIP() command sequence gen
|
|
57
|
+
|
|
58
|
+
#### 🚀 Features
|
|
59
|
+
|
|
60
|
+
- add command fns, add COMMENT cmd ([0d64b55](https://github.com/thi-ng/umbrella/commit/0d64b55))
|
|
61
|
+
- add MOVE(), WAIT(), COMMENT()
|
|
62
|
+
- add CommentCommand
|
|
63
|
+
- update AxiDraw.draw() to log comments
|
|
64
|
+
- add disconnect() ([af93177](https://github.com/thi-ng/umbrella/commit/af93177))
|
|
65
|
+
- add disconnect() for ISerial & AxiDraw
|
|
66
|
+
- update MockSerial impl
|
|
67
|
+
- update commands, docs & pkg exports ([1324cb8](https://github.com/thi-ng/umbrella/commit/1324cb8))
|
|
68
|
+
- update dip(), update imports. restructure /src ([b108760](https://github.com/thi-ng/umbrella/commit/b108760))
|
|
69
|
+
- add DipOpts, extend dip() functionality
|
|
70
|
+
- move dip() to own file dip.ts
|
|
71
|
+
- move complete() to commands.ts
|
|
72
|
+
- move registrationMark() to own file registration.ts
|
|
73
|
+
- update all imports
|
|
74
|
+
- update pkg exports map
|
|
75
|
+
|
|
12
76
|
## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/axidraw@0.5.0) (2023-02-05)
|
|
13
77
|
|
|
14
78
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ This project is part of the
|
|
|
11
11
|
|
|
12
12
|
- [About](#about)
|
|
13
13
|
- [Declarative vs. imperative](#declarative-vs-imperative)
|
|
14
|
-
- [Units, limits &
|
|
14
|
+
- [Units, limits & clamping](#units-limits--clamping)
|
|
15
15
|
- [Path planning](#path-planning)
|
|
16
16
|
- [thi.ng/geom support](#thinggeom-support)
|
|
17
17
|
- [SVG support](#svg-support)
|
|
@@ -22,9 +22,12 @@ This project is part of the
|
|
|
22
22
|
- [Installation](#installation)
|
|
23
23
|
- [Dependencies](#dependencies)
|
|
24
24
|
- [API](#api)
|
|
25
|
+
- [Available draw commands](#available-draw-commands)
|
|
26
|
+
- [Command sequence generators](#command-sequence-generators)
|
|
25
27
|
- [Example usage](#example-usage)
|
|
26
28
|
- [Basics](#basics)
|
|
27
29
|
- [geom-axidraw example](#geom-axidraw-example)
|
|
30
|
+
- [Brush & paint palette](#brush--paint-palette)
|
|
28
31
|
- [Authors](#authors)
|
|
29
32
|
- [License](#license)
|
|
30
33
|
|
|
@@ -32,6 +35,10 @@ This project is part of the
|
|
|
32
35
|
|
|
33
36
|
Minimal AxiDraw plotter/drawing machine controller for Node.js.
|
|
34
37
|
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
<small>AXI-SCAPE \#000, 12-layer watercolor painting/plot of cellular automata, © 2023 Karsten Schmidt</small>
|
|
41
|
+
|
|
35
42
|
This package provides a super-lightweight alternative to control an [AxiDraw
|
|
36
43
|
plotter](https://axidraw.com/) directly from Node.js, using a small custom set
|
|
37
44
|
of medium/high-level drawing commands. Structurally, these custom commands are
|
|
@@ -51,15 +58,30 @@ following the pattern of other packages in the
|
|
|
51
58
|
until the very last moment before being sent to the machine for physical
|
|
52
59
|
output...
|
|
53
60
|
|
|
54
|
-
### Units, limits &
|
|
61
|
+
### Units, limits & clamping
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
By default, bounds checking and coordinate clamping are applied (against a user
|
|
64
|
+
defined bounding rect or paper size), however this can be disabled (in which
|
|
65
|
+
case all given coordinates are expected to be valid and within machine limits).
|
|
66
|
+
Coordinates can be given in any unit, but if not using millimeters (default), a
|
|
67
|
+
conversion factor to inches (`unitsPerInch`) **MUST** be provided as part of the
|
|
68
|
+
[options
|
|
60
69
|
object](https://docs.thi.ng/umbrella/axidraw/interfaces/AxiDrawOpts.html) given
|
|
61
|
-
to the `AxiDraw` constructor.
|
|
62
|
-
geom-axidraw packages
|
|
70
|
+
to the `AxiDraw` constructor. Actual geometry clipping can be handled by the
|
|
71
|
+
[geom or geom-axidraw](#thinggeom-support) packages...
|
|
72
|
+
|
|
73
|
+
The bounding rect can be either defined by a tuple of `[[minX,minY],
|
|
74
|
+
[maxX,maxY]]` (in worldspace units) or as paper size defined as a
|
|
75
|
+
[`quantity()`](https://docs.thi.ng/umbrella/units/functions/quantity-1.html). The
|
|
76
|
+
default value is DIN A3 landscape.
|
|
77
|
+
|
|
78
|
+
If given as paper size (e.g. via
|
|
79
|
+
[thi.ng/units](https://github.com/thi-ng/umbrella/blob/develop/packages/units/)
|
|
80
|
+
presets), the actual units used to define these dimensions are irrelevant and
|
|
81
|
+
will be automatically converted.
|
|
82
|
+
|
|
83
|
+
[List of paper
|
|
84
|
+
sizes/presets](https://github.com/thi-ng/umbrella/blob/develop/packages/units/README.md#constants)
|
|
63
85
|
|
|
64
86
|
### Path planning
|
|
65
87
|
|
|
@@ -164,7 +186,7 @@ For Node.js REPL:
|
|
|
164
186
|
const axidraw = await import("@thi.ng/axidraw");
|
|
165
187
|
```
|
|
166
188
|
|
|
167
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
189
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 3.13 KB
|
|
168
190
|
|
|
169
191
|
## Dependencies
|
|
170
192
|
|
|
@@ -174,7 +196,9 @@ Package sizes (brotli'd, pre-treeshake): ESM: 2.15 KB
|
|
|
174
196
|
- [@thi.ng/date](https://github.com/thi-ng/umbrella/tree/develop/packages/date)
|
|
175
197
|
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
|
|
176
198
|
- [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
|
|
199
|
+
- [@thi.ng/math](https://github.com/thi-ng/umbrella/tree/develop/packages/math)
|
|
177
200
|
- [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
|
|
201
|
+
- [@thi.ng/units](https://github.com/thi-ng/umbrella/tree/develop/packages/units)
|
|
178
202
|
- [@thi.ng/vectors](https://github.com/thi-ng/umbrella/tree/develop/packages/vectors)
|
|
179
203
|
- [serialport](git://github.com/serialport/node-serialport.git)
|
|
180
204
|
|
|
@@ -182,6 +206,46 @@ Package sizes (brotli'd, pre-treeshake): ESM: 2.15 KB
|
|
|
182
206
|
|
|
183
207
|
[Generated API docs](https://docs.thi.ng/umbrella/axidraw/)
|
|
184
208
|
|
|
209
|
+
## Available draw commands
|
|
210
|
+
|
|
211
|
+
All
|
|
212
|
+
[`DrawCommand`s](https://docs.thi.ng/umbrella/axidraw/types/DrawCommand.html)
|
|
213
|
+
are expressed as S-expression-like, [thi.ng/hiccup]()-style elements, aka JS
|
|
214
|
+
arrays/tuples of `[command, ...args]`. The following commands are supported. All
|
|
215
|
+
also as predefined constants or factory functions for the parametric ones:
|
|
216
|
+
|
|
217
|
+
| Command | Preset/factory | Description |
|
|
218
|
+
|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------|
|
|
219
|
+
| `["comment", msg]` | [`COMMENT`](https://docs.thi.ng/umbrella/axidraw/functions/COMMENT.html) | Ignored, but logged during plotting |
|
|
220
|
+
| `["d", delay?, level?]` / `["u", delay?, level?]` | [`DOWN`](https://docs.thi.ng/umbrella/axidraw/functions/DOWN.html) / [`UP`](https://docs.thi.ng/umbrella/axidraw/functions/UP.html) | Move pen up/down w/ optional delay & level (0-100) |
|
|
221
|
+
| `["home"]` | `HOME` | Move to home position (origin) |
|
|
222
|
+
| `["m", [x,y], speed?]` | [`MOVE_REL`](https://docs.thi.ng/umbrella/axidraw/functions/MOVE_REL.html) | Move to relative position w/ optional speed factor |
|
|
223
|
+
| `["M", [x,y], speed?]` | [`MOVE`](https://docs.thi.ng/umbrella/axidraw/functions/MOVE.html) | Move to absolute position w/ optional speed factor |
|
|
224
|
+
| `["on"]` / `["off"]` | `ON` / `OFF` | Turn motors on/off |
|
|
225
|
+
| `["pen", down, up]` | [`PEN`](https://docs.thi.ng/umbrella/axidraw/functions/PEN.html) | Pen config (up/down levels) |
|
|
226
|
+
| `["reset"]` | `RESET` | Execute user defined reset sequence<sup>(1)</sup> |
|
|
227
|
+
| `["restore"]` | `RESTORE` | Restore saved pen up/down levels |
|
|
228
|
+
| `["save"]` | `SAVE` | Save current pen up/down levels |
|
|
229
|
+
| `["start"]` | `START` | Execute user defined start sequence<sup>(1)</sup> |
|
|
230
|
+
| `["stop"]` | `STOP` | Execute user defined stop sequence<sup>(1)</sup> |
|
|
231
|
+
| `["w", delay]` | [`WAIT`](https://docs.thi.ng/umbrella/axidraw/functions/WAIT.html) | Wait N milliseconds |
|
|
232
|
+
|
|
233
|
+
- <sup>(1)</sup> See
|
|
234
|
+
[AxiDrawOpts](https://docs.thi.ng/umbrella/axidraw/interfaces/AxiDrawOpts.html)
|
|
235
|
+
for details.
|
|
236
|
+
|
|
237
|
+
### Command sequence generators
|
|
238
|
+
|
|
239
|
+
Additionally, the following command sequence generators are provided (see their
|
|
240
|
+
docs for details and code examples):
|
|
241
|
+
|
|
242
|
+
- [`complete()`](https://docs.thi.ng/umbrella/axidraw/functions/complete.html)
|
|
243
|
+
- [`dip()`](https://docs.thi.ng/umbrella/axidraw/functions/dip.html)
|
|
244
|
+
- [`linearPalette()`](https://docs.thi.ng/umbrella/axidraw/functions/linearPalette.html)
|
|
245
|
+
- [`polyline()`](https://docs.thi.ng/umbrella/axidraw/functions/polyline.html)
|
|
246
|
+
- [`radialPalette()`](https://docs.thi.ng/umbrella/axidraw/functions/radialPalette.html)
|
|
247
|
+
- [`registrationMark()`](https://docs.thi.ng/umbrella/axidraw/functions/registrationMark.html)
|
|
248
|
+
|
|
185
249
|
### Example usage
|
|
186
250
|
|
|
187
251
|
#### Basics
|
|
@@ -257,14 +321,82 @@ import { map, range } from "@thi.ng/transducers";
|
|
|
257
321
|
})();
|
|
258
322
|
```
|
|
259
323
|
|
|
324
|
+
### Brush & paint palette
|
|
325
|
+
|
|
326
|
+
This example illustrates how the [`linearPalette()`]() command sequence
|
|
327
|
+
generator can be used to paint random dots with a brush which gets re-dipped in
|
|
328
|
+
different paints every 10 dots...
|
|
329
|
+
|
|
330
|
+
Also see
|
|
331
|
+
[`InterleaveOpts`](https://docs.thi.ng/umbrella/geom-axidraw/interfaces/InterleaveOpts.html)
|
|
332
|
+
for more details...
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
import { points } from "@thi.ng/geom";
|
|
336
|
+
import { asAxiDraw } from "@thi.ng/geom-axidraw";
|
|
337
|
+
import { repeatedly } from "@thi.ng/transducers";
|
|
338
|
+
import { randMinMax2 } from "@thi.ng/vectors";
|
|
339
|
+
|
|
340
|
+
// configure palette
|
|
341
|
+
// "linear" here means the palette slots are arranged in a line
|
|
342
|
+
// (there's also a radialPalette() function for circular/elliptical palette layouts)
|
|
343
|
+
const palette = linearPalette({
|
|
344
|
+
// first palette slot is near the world origin (slight offset)
|
|
345
|
+
pos: [2, 0],
|
|
346
|
+
// 2mm jitter radius (to not always move to exact same position)
|
|
347
|
+
jitter: 2,
|
|
348
|
+
// palette has 5 paint slots
|
|
349
|
+
num: 5,
|
|
350
|
+
// each slot 40mm separation along Y-axis
|
|
351
|
+
// (needs to be measured/determined manually)
|
|
352
|
+
step: [0, 40],
|
|
353
|
+
// dip brush 3x each time
|
|
354
|
+
repeat: 3,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// define point cloud of 100 random points
|
|
358
|
+
// using a random palette slot each time (for each refill)
|
|
359
|
+
// assign axidraw-specific attribs to refill brush every 10 dots
|
|
360
|
+
const cloud = points(
|
|
361
|
+
// pick random points
|
|
362
|
+
[...repeatedly(() => randMinMax2([], [10, 10], [190, 190]), 100)],
|
|
363
|
+
// shape attributes
|
|
364
|
+
{
|
|
365
|
+
__axi: {
|
|
366
|
+
interleave: {
|
|
367
|
+
// every 10 elements/dots...
|
|
368
|
+
num: 10,
|
|
369
|
+
// execute these commands...
|
|
370
|
+
commands: () => [
|
|
371
|
+
// first brush cleaning in water
|
|
372
|
+
// (we decide to use the last palette slot for that)
|
|
373
|
+
...palette(4),
|
|
374
|
+
// now "refill" brush at a random other slot
|
|
375
|
+
...palette(Math.floor(Math.random() * 4))
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
// AxiDraw setup
|
|
383
|
+
const axi = new AxiDraw();
|
|
384
|
+
...
|
|
385
|
+
|
|
386
|
+
// convert geometry into axidraw commands and send to plotter
|
|
387
|
+
axi.draw(asAxiDraw(cloud));
|
|
388
|
+
```
|
|
389
|
+
|
|
260
390
|
Other selected toots/tweets:
|
|
261
391
|
|
|
262
|
-
- https://mastodon.thi.ng/@toxi/109490174709589253
|
|
263
|
-
- https://mastodon.thi.ng/@toxi/109473655772673067
|
|
264
|
-
- https://mastodon.thi.ng/@toxi/109474947869078797
|
|
265
|
-
- https://mastodon.thi.ng/@toxi/109483553358349473
|
|
266
|
-
- https://mastodon.thi.ng/@toxi/109570540391689321
|
|
267
|
-
- https://mastodon.thi.ng/@toxi/109586780630493994
|
|
392
|
+
- [Project announcement](https://mastodon.thi.ng/@toxi/109490174709589253)
|
|
393
|
+
- [Geometry conversion basics](https://mastodon.thi.ng/@toxi/109473655772673067)
|
|
394
|
+
- [Shape group conversion and stippling](https://mastodon.thi.ng/@toxi/109474947869078797)
|
|
395
|
+
- [Per-shape & on-the-fly polyline clipping](https://mastodon.thi.ng/@toxi/109483553358349473)
|
|
396
|
+
- [Bitmap-to-vector conversions & shape sorting](https://mastodon.thi.ng/@toxi/109570540391689321)
|
|
397
|
+
- [Multi-color plotting](https://mastodon.thi.ng/@toxi/109586780630493994)
|
|
398
|
+
- [Using water color & paintbrush](https://mastodon.thi.ng/@toxi/110044424626641749)
|
|
399
|
+
- [Water color brush tests](https://mastodon.thi.ng/@toxi/110051629944117139)
|
|
268
400
|
- more to come...
|
|
269
401
|
|
|
270
402
|
## Authors
|
package/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IDeref } from "@thi.ng/api";
|
|
2
2
|
import type { ILogger } from "@thi.ng/logger";
|
|
3
|
+
import type { Quantity } from "@thi.ng/units";
|
|
3
4
|
import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
4
5
|
/** Start command sequence (configurable via {@link AxiDrawOpts}) */
|
|
5
6
|
export type StartCommand = ["start"];
|
|
@@ -23,10 +24,25 @@ export type PenUpDownCommand = ["u" | "d", number?, number?];
|
|
|
23
24
|
* Move to abs pos (in worldspace coords, default mm), optional speed factor
|
|
24
25
|
* (default: 1)
|
|
25
26
|
*/
|
|
26
|
-
export type MoveXYCommand = ["
|
|
27
|
+
export type MoveXYCommand = ["M", ReadonlyVec, number?];
|
|
28
|
+
/**
|
|
29
|
+
* Move to **relative** pos (based on curr plotter position, im worldspace
|
|
30
|
+
* units, default mm), optional speed factor (default: 1)
|
|
31
|
+
*/
|
|
32
|
+
export type MoveRelCommand = ["m", ReadonlyVec, number?];
|
|
27
33
|
/** Explicit delay (in ms) */
|
|
28
34
|
export type WaitCommand = ["w", number];
|
|
29
|
-
|
|
35
|
+
/** Ignored, but will be logged (if logging enabled) */
|
|
36
|
+
export type CommentCommand = ["comment", string];
|
|
37
|
+
/**
|
|
38
|
+
* Stores current pen configuration on stack.
|
|
39
|
+
*/
|
|
40
|
+
export type SaveCommand = ["save"];
|
|
41
|
+
/**
|
|
42
|
+
* Restores current pen configuration from stack.
|
|
43
|
+
*/
|
|
44
|
+
export type RestoreCommand = ["restore"];
|
|
45
|
+
export type DrawCommand = CommentCommand | HomeCommand | MotorCommand | MoveRelCommand | MoveXYCommand | PenConfigCommand | PenUpDownCommand | ResetCommand | RestoreCommand | SaveCommand | StartCommand | StopCommand | WaitCommand;
|
|
30
46
|
/**
|
|
31
47
|
* Global plotter drawing configuration. Also see {@link DEFAULT_OPTS}.
|
|
32
48
|
*/
|
|
@@ -58,6 +74,28 @@ export interface AxiDrawOpts {
|
|
|
58
74
|
* all or if the control is in the {@link AxiDrawState.CONTINUE} state.
|
|
59
75
|
*/
|
|
60
76
|
control?: IDeref<AxiDrawState>;
|
|
77
|
+
/**
|
|
78
|
+
* All XY coords will be clamped to given bounding rect, either defined by
|
|
79
|
+
* `[[minX,minY], [maxX,maxY]]` (in worldspace units) or as paper size
|
|
80
|
+
* defined as a
|
|
81
|
+
* [`quantity`](https://docs.thi.ng/umbrella/units/functions/quantity-1.html).
|
|
82
|
+
* The default value is DIN A3 landscape.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* Set to `undefined` to disable bounds/clipping. If given a paper size (via
|
|
86
|
+
* thi.ng/units `quantity()`), the units used to define these dimensions are
|
|
87
|
+
* irrelevant (and independent of {@link AxiDrawOpts.unitsPerInch}!) and
|
|
88
|
+
* will be automatically converted. Also, the resulting bounds will always
|
|
89
|
+
* be based on [0, 0].
|
|
90
|
+
*
|
|
91
|
+
* List of paper sizes/presets:
|
|
92
|
+
* https://github.com/thi-ng/umbrella/blob/develop/packages/units/README.md#constants
|
|
93
|
+
*
|
|
94
|
+
* Also see {@link AxiDrawOpts.unitsPerInch}
|
|
95
|
+
*
|
|
96
|
+
* @defaultValue `DIN_A3_LANDSCAPE`
|
|
97
|
+
*/
|
|
98
|
+
bounds?: [ReadonlyVec, ReadonlyVec] | Quantity<number[]>;
|
|
61
99
|
/**
|
|
62
100
|
* Conversion factor from geometry worldspace units to inches.
|
|
63
101
|
* Default units are millimeters.
|
|
@@ -125,6 +163,22 @@ export interface AxiDrawOpts {
|
|
|
125
163
|
* @defaultValue `[UP, HOME, OFF]`
|
|
126
164
|
*/
|
|
127
165
|
stop: DrawCommand[];
|
|
166
|
+
/**
|
|
167
|
+
* Position (in world space units) which is considered the origin and which
|
|
168
|
+
* will be added to all coordinates as offset (e.g. for plotting with a
|
|
169
|
+
* physically offset easel).
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* Note: The configured {@link AxiDrawOpts.bounds} are independent from this
|
|
173
|
+
* setting and are intended to enforce the plotter's physical movement
|
|
174
|
+
* limits. E.g. shifting the home/offset position by +100mm along X (and
|
|
175
|
+
* assuming only positive coordinates will be used for the drawing), simply
|
|
176
|
+
* means the available horizontal drawing space will be reduced by the same
|
|
177
|
+
* amount...
|
|
178
|
+
*
|
|
179
|
+
* @defaultValue [0, 0]
|
|
180
|
+
*/
|
|
181
|
+
home: ReadonlyVec;
|
|
128
182
|
/**
|
|
129
183
|
* Refresh interval for checking the control FSM in paused state.
|
|
130
184
|
*
|
|
@@ -137,15 +191,6 @@ export interface AxiDrawOpts {
|
|
|
137
191
|
*/
|
|
138
192
|
sigint: boolean;
|
|
139
193
|
}
|
|
140
|
-
export declare const START: StartCommand;
|
|
141
|
-
export declare const STOP: StopCommand;
|
|
142
|
-
export declare const HOME: HomeCommand;
|
|
143
|
-
export declare const RESET: ResetCommand;
|
|
144
|
-
export declare const PEN: PenConfigCommand;
|
|
145
|
-
export declare const UP: PenUpDownCommand;
|
|
146
|
-
export declare const DOWN: PenUpDownCommand;
|
|
147
|
-
export declare const ON: MotorCommand;
|
|
148
|
-
export declare const OFF: MotorCommand;
|
|
149
194
|
/**
|
|
150
195
|
* FSM state enum for (interactive) control for processing of drawing commands.
|
|
151
196
|
* See {@link AxiDraw.draw} and {@link AxiDrawControl} for details.
|
|
@@ -245,6 +290,7 @@ export interface SerialConnection {
|
|
|
245
290
|
ctor(path: string, baudRate: number): ISerial;
|
|
246
291
|
}
|
|
247
292
|
export interface ISerial {
|
|
293
|
+
close(): void;
|
|
248
294
|
/**
|
|
249
295
|
* Writes given string to the port.
|
|
250
296
|
*
|
package/api.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
export const START = ["start"];
|
|
2
|
-
export const STOP = ["stop"];
|
|
3
|
-
export const HOME = ["home"];
|
|
4
|
-
export const RESET = ["reset"];
|
|
5
|
-
export const PEN = ["pen"];
|
|
6
|
-
export const UP = ["u"];
|
|
7
|
-
export const DOWN = ["d"];
|
|
8
|
-
export const ON = ["on"];
|
|
9
|
-
export const OFF = ["off"];
|
|
10
1
|
/**
|
|
11
2
|
* FSM state enum for (interactive) control for processing of drawing commands.
|
|
12
3
|
* See {@link AxiDraw.draw} and {@link AxiDrawControl} for details.
|
package/axidraw.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IReset } from "@thi.ng/api";
|
|
2
|
-
import { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
2
|
+
import { ReadonlyVec, Vec, VecPair } from "@thi.ng/vectors/api";
|
|
3
3
|
import { AxiDrawOpts, DrawCommand, ISerial, Metrics } from "./api.js";
|
|
4
4
|
export declare const DEFAULT_OPTS: AxiDrawOpts;
|
|
5
5
|
export declare class AxiDraw implements IReset {
|
|
@@ -8,8 +8,12 @@ export declare class AxiDraw implements IReset {
|
|
|
8
8
|
isConnected: boolean;
|
|
9
9
|
isPenDown: boolean;
|
|
10
10
|
penLimits: [number, number];
|
|
11
|
+
penState: [number, number][];
|
|
11
12
|
pos: Vec;
|
|
12
13
|
targetPos: Vec;
|
|
14
|
+
homePos: ReadonlyVec;
|
|
15
|
+
scale: number;
|
|
16
|
+
bounds?: VecPair;
|
|
13
17
|
constructor(opts?: Partial<AxiDrawOpts>);
|
|
14
18
|
reset(): this;
|
|
15
19
|
/**
|
|
@@ -25,6 +29,7 @@ export declare class AxiDraw implements IReset {
|
|
|
25
29
|
* @param path
|
|
26
30
|
*/
|
|
27
31
|
connect(path?: string | RegExp): Promise<void>;
|
|
32
|
+
disconnect(): void;
|
|
28
33
|
/**
|
|
29
34
|
* Async function. Converts sequence of {@link DrawCommand}s into actual EBB
|
|
30
35
|
* commands and sends them via configured serial port to the AxiDraw. If
|
|
@@ -68,6 +73,8 @@ export declare class AxiDraw implements IReset {
|
|
|
68
73
|
draw1(cmd: DrawCommand): Promise<Metrics>;
|
|
69
74
|
motorsOn(): void;
|
|
70
75
|
motorsOff(): void;
|
|
76
|
+
save(): void;
|
|
77
|
+
restore(): void;
|
|
71
78
|
penConfig(down?: number, up?: number): void;
|
|
72
79
|
penUp(delay?: number, level?: number): number;
|
|
73
80
|
penDown(delay?: number, level?: number): number;
|
|
@@ -85,12 +92,21 @@ export declare class AxiDraw implements IReset {
|
|
|
85
92
|
* @param tempo
|
|
86
93
|
*/
|
|
87
94
|
moveTo(p: ReadonlyVec, tempo?: number): number[];
|
|
95
|
+
/**
|
|
96
|
+
* Similar to {@link AxiDraw.moveTo}, but using **relative** coordinates.
|
|
97
|
+
*
|
|
98
|
+
* @param delta
|
|
99
|
+
* @param tempo
|
|
100
|
+
*/
|
|
101
|
+
moveRelative(delta: ReadonlyVec, tempo?: number): number[];
|
|
88
102
|
/**
|
|
89
103
|
* Syntax sugar for {@link AxiDraw.moveTo}([0, 0]).
|
|
90
104
|
*/
|
|
91
105
|
home(): number[];
|
|
106
|
+
setHome(pos: ReadonlyVec): void;
|
|
92
107
|
protected onSignal(): Promise<void>;
|
|
93
108
|
protected send(msg: string): void;
|
|
109
|
+
protected sendMove(tempo?: number): number[];
|
|
94
110
|
/**
|
|
95
111
|
* Sends pen up/down config
|
|
96
112
|
*
|