nova-control-browser 0.0.7 → 0.0.8

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/README.md CHANGED
@@ -134,16 +134,16 @@ Supported commands:
134
134
 
135
135
  | command | description |
136
136
  | --- | --- |
137
- | `home` | send all servos to home positions |
138
- | `shift-to <deg>` | s1 — head forward / back |
139
- | `roll-to <deg>` | s2 — head CW / CCW |
140
- | `pitch-to <deg>` | s3 — head up / down |
141
- | `rotate-to <deg>` | s4 — body Z-axis rotation |
142
- | `lift-to <deg>` | s5 — secondary head axis |
143
- | `move [key val ]` | set multiple servos atomically (e.g. `move shift-to 100 rotate-to 120`) |
137
+ | `home [<within_ms>]` | send all servos to home positions |
138
+ | `shift-to <deg> [<within_ms>]` | s1 — head forward / back |
139
+ | `roll-to <deg> [<within_ms>]` | s2 — head CW / CCW |
140
+ | `pitch-to <deg> [<within_ms>]` | s3 — head up / down |
141
+ | `rotate-to <deg> [<within_ms>]` | s4 — body Z-axis rotation |
142
+ | `lift-to <deg> [<within_ms>]` | s5 — secondary head axis |
143
+ | `move [shift-to <deg>] [roll-to <deg>] [pitch-to <deg>] [rotate-to <deg>] [lift-to <deg>] [within-ms <ms>]` | set multiple servos atomically (e.g. `move shift-to 100 rotate-to 120 within-ms 500`) |
144
144
  | `wait <ms>` | pause for the given number of milliseconds |
145
145
 
146
- Throws a descriptive error containing the line number if an unknown command or invalid argument is encountered.
146
+ Each command is fully awaited before the next begins. Throws a descriptive error containing the line number if an unknown command or invalid argument is encountered.
147
147
 
148
148
  ### Types
149
149
 
@@ -151,65 +151,83 @@ async function l(e, t) {
151
151
  if (r === "" || r.startsWith("#")) continue;
152
152
  let a = r.split(/\s+/), o = a[0].toLowerCase();
153
153
  switch (!0) {
154
- case o === "home":
155
- await e.home();
154
+ case o === "home": {
155
+ let t = a[1] == null ? void 0 : Number(a[1]);
156
+ if (t != null && isNaN(t)) throw Error(`line ${i}: home: within_ms must be a number, got '${a[1]}'`);
157
+ await e.home(t);
156
158
  break;
159
+ }
157
160
  case o === "shift-to": {
158
161
  let t = Number(a[1]);
159
162
  if (isNaN(t)) throw Error(`line ${i}: shift-to requires a numeric angle, got '${a[1]}'`);
160
- await e.shiftHeadTo(t);
163
+ let n = a[2] == null ? void 0 : Number(a[2]);
164
+ if (n != null && isNaN(n)) throw Error(`line ${i}: shift-to: within_ms must be a number, got '${a[2]}'`);
165
+ await e.shiftHeadTo(t, n);
161
166
  break;
162
167
  }
163
168
  case o === "roll-to": {
164
169
  let t = Number(a[1]);
165
170
  if (isNaN(t)) throw Error(`line ${i}: roll-to requires a numeric angle, got '${a[1]}'`);
166
- await e.rollHeadTo(t);
171
+ let n = a[2] == null ? void 0 : Number(a[2]);
172
+ if (n != null && isNaN(n)) throw Error(`line ${i}: roll-to: within_ms must be a number, got '${a[2]}'`);
173
+ await e.rollHeadTo(t, n);
167
174
  break;
168
175
  }
169
176
  case o === "pitch-to": {
170
177
  let t = Number(a[1]);
171
178
  if (isNaN(t)) throw Error(`line ${i}: pitch-to requires a numeric angle, got '${a[1]}'`);
172
- await e.pitchHeadTo(t);
179
+ let n = a[2] == null ? void 0 : Number(a[2]);
180
+ if (n != null && isNaN(n)) throw Error(`line ${i}: pitch-to: within_ms must be a number, got '${a[2]}'`);
181
+ await e.pitchHeadTo(t, n);
173
182
  break;
174
183
  }
175
184
  case o === "rotate-to": {
176
185
  let t = Number(a[1]);
177
186
  if (isNaN(t)) throw Error(`line ${i}: rotate-to requires a numeric angle, got '${a[1]}'`);
178
- await e.rotateBodyTo(t);
187
+ let n = a[2] == null ? void 0 : Number(a[2]);
188
+ if (n != null && isNaN(n)) throw Error(`line ${i}: rotate-to: within_ms must be a number, got '${a[2]}'`);
189
+ await e.rotateBodyTo(t, n);
179
190
  break;
180
191
  }
181
192
  case o === "lift-to": {
182
193
  let t = Number(a[1]);
183
194
  if (isNaN(t)) throw Error(`line ${i}: lift-to requires a numeric angle, got '${a[1]}'`);
184
- await e.liftHeadTo(t);
195
+ let n = a[2] == null ? void 0 : Number(a[2]);
196
+ if (n != null && isNaN(n)) throw Error(`line ${i}: lift-to: within_ms must be a number, got '${a[2]}'`);
197
+ await e.liftHeadTo(t, n);
185
198
  break;
186
199
  }
187
200
  case o === "move": {
188
- let t = {};
201
+ let t = {}, n;
189
202
  for (let e = 1; e < a.length; e += 2) {
190
- let n = a[e].toLowerCase(), r = Number(a[e + 1]);
191
- if (isNaN(r)) throw Error(`line ${i}: '${n}' requires a numeric angle, got '${a[e + 1]}'`);
192
- switch (n) {
203
+ let r = a[e].toLowerCase(), o = Number(a[e + 1]);
204
+ if (r === "within-ms") {
205
+ if (isNaN(o)) throw Error(`line ${i}: within-ms requires a numeric value, got '${a[e + 1]}'`);
206
+ n = o;
207
+ break;
208
+ }
209
+ if (isNaN(o)) throw Error(`line ${i}: '${r}' requires a numeric angle, got '${a[e + 1]}'`);
210
+ switch (r) {
193
211
  case "shift-to":
194
- t.s1 = r;
212
+ t.s1 = o;
195
213
  break;
196
214
  case "roll-to":
197
- t.s2 = r;
215
+ t.s2 = o;
198
216
  break;
199
217
  case "pitch-to":
200
- t.s3 = r;
218
+ t.s3 = o;
201
219
  break;
202
220
  case "rotate-to":
203
- t.s4 = r;
221
+ t.s4 = o;
204
222
  break;
205
223
  case "lift-to":
206
- t.s5 = r;
224
+ t.s5 = o;
207
225
  break;
208
- default: throw Error(`line ${i}: unknown move argument '${n}'`);
226
+ default: throw Error(`line ${i}: unknown move argument '${r}'`);
209
227
  }
210
228
  }
211
229
  if (Object.keys(t).length === 0) throw Error(`line ${i}: move requires at least one servo argument`);
212
- e.State = t, await e.sendServoState();
230
+ await e.moveTo(t, n);
213
231
  break;
214
232
  }
215
233
  case o === "wait": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nova-control-browser",
3
3
  "description": "Control a NOVA DIY Artificial Intelligence Robot by Creoqode from a browser",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "nova",