@thi.ng/axidraw 0.4.0 → 0.5.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-01-10T15:20:18Z
3
+ - **Last updated**: 2023-02-10T14:03:10Z
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,17 @@ 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
+ ## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/axidraw@0.5.0) (2023-02-05)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add speedUp config, rename speed => speedDown ([197d610](https://github.com/thi-ng/umbrella/commit/197d610))
17
+
18
+ #### 🩹 Bug fixes
19
+
20
+ - add [@thi.ng/date](https://github.com/thi-ng/umbrella/tree/main/packages/date) dependency ([bd35a9e](https://github.com/thi-ng/umbrella/commit/bd35a9e))
21
+ required by axidraw.ts
22
+
12
23
  ## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/axidraw@0.4.0) (2023-01-10)
13
24
 
14
25
  #### 🚀 Features
package/README.md CHANGED
@@ -164,15 +164,17 @@ For Node.js REPL:
164
164
  const axidraw = await import("@thi.ng/axidraw");
165
165
  ```
166
166
 
167
- Package sizes (brotli'd, pre-treeshake): ESM: 3.97 KB
167
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.15 KB
168
168
 
169
169
  ## Dependencies
170
170
 
171
171
  - [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
172
172
  - [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
173
173
  - [@thi.ng/compose](https://github.com/thi-ng/umbrella/tree/develop/packages/compose)
174
+ - [@thi.ng/date](https://github.com/thi-ng/umbrella/tree/develop/packages/date)
174
175
  - [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
175
176
  - [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
177
+ - [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
176
178
  - [@thi.ng/vectors](https://github.com/thi-ng/umbrella/tree/develop/packages/vectors)
177
179
  - [serialport](git://github.com/serialport/node-serialport.git)
178
180
 
package/api.d.ts CHANGED
@@ -72,11 +72,17 @@ export interface AxiDrawOpts {
72
72
  */
73
73
  stepsPerInch: number;
74
74
  /**
75
- * Steps per second
75
+ * Steps per second for XY movements whilst pen down
76
76
  *
77
77
  * @defaultValue 4000
78
78
  */
79
- speed: number;
79
+ speedDown: number;
80
+ /**
81
+ * Steps per second for XY movements whilst pen up
82
+ *
83
+ * @defaultValue 4000
84
+ */
85
+ speedUp: number;
80
86
  /**
81
87
  * Up position (%)
82
88
  *
package/axidraw.d.ts CHANGED
@@ -75,6 +75,12 @@ export declare class AxiDraw implements IReset {
75
75
  * Sends a "moveto" command (absolute coords). Returns tuple of `[duration,
76
76
  * distance]` (distance in original/configured units)
77
77
  *
78
+ * @remarks
79
+ * Even though this method accepts absolute coords, all AxiDraw movements
80
+ * are relative. Depending on pen up/down state, movement speed will be
81
+ * either the configured {@link AxiDrawOpts.speedDown} or
82
+ * {@link AxiDrawOpts.speedUp}.
83
+ *
78
84
  * @param p
79
85
  * @param tempo
80
86
  */
package/axidraw.js CHANGED
@@ -15,7 +15,8 @@ export const DEFAULT_OPTS = {
15
15
  refresh: 1000,
16
16
  unitsPerInch: 25.4,
17
17
  stepsPerInch: 2032,
18
- speed: 4000,
18
+ speedDown: 4000,
19
+ speedUp: 4000,
19
20
  up: 60,
20
21
  down: 30,
21
22
  delayUp: 150,
@@ -248,17 +249,24 @@ export class AxiDraw {
248
249
  * Sends a "moveto" command (absolute coords). Returns tuple of `[duration,
249
250
  * distance]` (distance in original/configured units)
250
251
  *
252
+ * @remarks
253
+ * Even though this method accepts absolute coords, all AxiDraw movements
254
+ * are relative. Depending on pen up/down state, movement speed will be
255
+ * either the configured {@link AxiDrawOpts.speedDown} or
256
+ * {@link AxiDrawOpts.speedUp}.
257
+ *
251
258
  * @param p
252
259
  * @param tempo
253
260
  */
254
261
  moveTo(p, tempo = 1) {
255
- const { pos, targetPos, opts } = this;
262
+ const { pos, targetPos, opts, isPenDown } = this;
256
263
  // apply scale factor: worldspace units -> motor steps
257
264
  mulN2(targetPos, p, opts.stepsPerInch / opts.unitsPerInch);
258
265
  const delta = sub2([], targetPos, pos);
259
266
  set2(pos, targetPos);
260
267
  const maxAxis = Math.max(...abs2([], delta));
261
- const duration = (1000 * maxAxis) / (opts.speed * tempo);
268
+ const duration = (1000 * maxAxis) /
269
+ ((isPenDown ? opts.speedDown : opts.speedUp) * tempo);
262
270
  this.send(`XM,${duration | 0},${delta[0] | 0},${delta[1] | 0}\r`);
263
271
  return [duration, (mag(delta) * opts.unitsPerInch) / opts.stepsPerInch];
264
272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/axidraw",
3
- "version": "0.4.0",
3
+ "version": "0.5.2",
4
4
  "description": "Minimal AxiDraw plotter/drawing machine controller for Node.js",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,21 +34,23 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.6.3",
38
- "@thi.ng/checks": "^3.3.7",
39
- "@thi.ng/compose": "^2.1.24",
40
- "@thi.ng/errors": "^2.2.8",
41
- "@thi.ng/logger": "^1.4.7",
42
- "@thi.ng/vectors": "^7.5.31",
37
+ "@thi.ng/api": "^8.7.2",
38
+ "@thi.ng/checks": "^3.3.9",
39
+ "@thi.ng/compose": "^2.1.27",
40
+ "@thi.ng/date": "^2.4.4",
41
+ "@thi.ng/errors": "^2.2.11",
42
+ "@thi.ng/logger": "^1.4.9",
43
+ "@thi.ng/transducers": "^8.3.33",
44
+ "@thi.ng/vectors": "^7.6.2",
43
45
  "serialport": "^10.5.0"
44
46
  },
45
47
  "devDependencies": {
46
- "@microsoft/api-extractor": "^7.33.7",
47
- "@thi.ng/testament": "^0.3.9",
48
- "rimraf": "^3.0.2",
48
+ "@microsoft/api-extractor": "^7.34.2",
49
+ "@thi.ng/testament": "^0.3.11",
50
+ "rimraf": "^4.1.2",
49
51
  "tools": "^0.0.1",
50
- "typedoc": "^0.23.22",
51
- "typescript": "^4.9.4"
52
+ "typedoc": "^0.23.24",
53
+ "typescript": "^4.9.5"
52
54
  },
53
55
  "keywords": [
54
56
  "2d",
@@ -102,5 +104,5 @@
102
104
  "status": "alpha",
103
105
  "year": 2022
104
106
  },
105
- "gitHead": "3f0b3e2a7c82aefc7e46fb4338369836b5e1b8cf\n"
107
+ "gitHead": "cafa4ecea90fb681949dc3885a5bd6ddefa38b51\n"
106
108
  }