Compare commits
307 Commits
feature/sp
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
60a42dfc47 | ||
|
7ebc37a369 | ||
2fc1622c25 | |||
505bbdc648 | |||
69ee57e6ff | |||
e0ae64e7f3 | |||
|
abecb5385b | ||
|
2b03176509 | ||
|
d117fe10ff | ||
|
3bba7c7e73 | ||
|
333d300fc4 | ||
|
d3ccc7ac41 | ||
|
a613e9956d | ||
|
e4c68e5749 | ||
|
72ef125d4f | ||
|
a8a27eaeaa | ||
|
ce0f4509be | ||
|
f71411aacd | ||
|
e877dbf65e | ||
|
4836695840 | ||
|
57ee61e620 | ||
|
32fe39fd8c | ||
|
ddb71b5d05 | ||
fe80b0fd81 | |||
|
a833732f8c | ||
|
e6c575a0da | ||
322b269e5a | |||
|
f0169117b5 | ||
a0279a1fb6 | |||
7b1795c967 | |||
de6f60b42c | |||
9845a0b118 | |||
70c753c660 | |||
|
48a8aea80a | ||
|
aabf02580e | ||
|
0877d068a5 | ||
|
7782d64003 | ||
|
4cc92c6d37 | ||
|
d51851d058 | ||
|
02215ccf40 | ||
|
07edc32a8a | ||
|
f570afba08 | ||
|
52ee5d04c7 | ||
4bfa4d15e5 | |||
6b44373930 | |||
0577491a8c | |||
7b1fdb42e7 | |||
e3259f4ba7 | |||
10a0a9457a | |||
24e8d00db4 | |||
e0ec800dcc | |||
60dee2c62d | |||
671c2d21db | |||
0e5f94e189 | |||
2e43ee7cf0 | |||
6a02a89e5e | |||
|
fbf5b5ccf3 | ||
093cdc0c00 | |||
|
88ace0f66f | ||
dbe7f1999b | |||
7e8eaf6598 | |||
08489819ec | |||
|
a51aac1066 | ||
a3f66d5df0 | |||
04e8798c6a | |||
e6a174e53a | |||
|
01d229823e | ||
51edf0b933 | |||
42dae48639 | |||
df4ea5dd86 | |||
5094c8269f | |||
e88cec2635 | |||
4f1e48a6b0 | |||
1193df20df | |||
e016f14059 | |||
be8495a2f2 | |||
7d0c4f73ba | |||
38bdea2642 | |||
2dec413e94 | |||
d1fe3a49e4 | |||
224415801f | |||
|
7bc9603952 | ||
7852fa5823 | |||
7b0e46e645 | |||
34ffc7816c | |||
7bd7d3ce6d | |||
f64b141227 | |||
|
15c3f4defc | ||
d86c3f69f8 | |||
6e29cb9914 | |||
8d5a3438a3 | |||
|
8401297b3f | ||
|
b2eebfa442 | ||
|
4394030f6b | ||
db492be169 | |||
89a47944a5 | |||
|
511f503912 | ||
6bdd454772 | |||
9b4d496f34 | |||
afe4eadf08 | |||
8cbd0b8879 | |||
dee732c8ca | |||
e6c6a3c18f | |||
1b2c988409 | |||
2e2f565ed7 | |||
|
93d6a9e45a | ||
bce589a751 | |||
6decc7139b | |||
bcc59ce81c | |||
9234e9af34 | |||
974b32e98c | |||
a7992bf20e | |||
0a9f200e97 | |||
b219dcf60b | |||
e526e32146 | |||
a8126b2f3e | |||
|
b24946ca43 | ||
|
7ad17ccfcf | ||
be7490cc9f | |||
6305662d38 | |||
b66eb5befa | |||
b9972b0527 | |||
6343c97175 | |||
4bf26cf158 | |||
48532ab56f | |||
45670f57c7 | |||
04313c746d | |||
97d0c407cf | |||
3145fec599 | |||
232ef6835e | |||
0ec0692aad | |||
32b7ba3d45 | |||
a2cee6566d | |||
|
74418453d3 | ||
854666fd06 | |||
|
232edb2ffb | ||
|
78d769a269 | ||
8b16d1012b | |||
7b0d981327 | |||
28fd0b5578 | |||
ecbf489148 | |||
d98af00775 | |||
91a0c02972 | |||
a34c4223fb | |||
e721e0f5bf | |||
c0009f8f08 | |||
e34eea98ba | |||
c6f8015154 | |||
407accedc8 | |||
ef315676b0 | |||
d329ce6191 | |||
225b60f752 | |||
0c3ff8b00a | |||
dfd22b1d3d | |||
ea20b1bee0 | |||
5fde49c0c2 | |||
63f1c10fcc | |||
56eaa7ca49 | |||
74be8a752b | |||
f7e86d32cf | |||
b43b59e526 | |||
bf721eddf6 | |||
875293a742 | |||
afa7c74f82 | |||
673f5ffcb6 | |||
9f087e3e1a | |||
077a7376c0 | |||
290f469b47 | |||
c5146bd315 | |||
9113d22766 | |||
579f82334c | |||
2dabeddbab | |||
035017617e | |||
bc644c85b2 | |||
705fbd341a | |||
a5a9b2e880 | |||
6e77d697fc | |||
195c0d5123 | |||
6d23179be6 | |||
2e06a17e5d | |||
c1b8697a56 | |||
de4feb0b89 | |||
364089b703 | |||
ffd3cceab8 | |||
36c34a9743 | |||
388bce170c | |||
04b79ade47 | |||
df70d8a8a4 | |||
225f331811 | |||
406e9e99bc | |||
37be7f85b6 | |||
023b141c4d | |||
2a67242f34 | |||
31ac93275c | |||
81cbdac591 | |||
198d637ef9 | |||
6a7c4899b4 | |||
77d99f6b39 | |||
6beeda5df7 | |||
59179652dd | |||
1793eb05e0 | |||
5c03e5c3b6 | |||
7fdc754084 | |||
e624efd067 | |||
f9cea9a6bf | |||
a02249f696 | |||
d382c3d9f2 | |||
93a1369e84 | |||
8ffc60b924 | |||
4af1d3d69b | |||
d453fe52fb | |||
eb6b20adbb | |||
138e1cc041 | |||
5a3211a560 | |||
0d076aa7e1 | |||
396765c8ea | |||
|
0e121a4f92 | ||
|
55bcafa637 | ||
|
abd21a88b2 | ||
|
31b8eb6ec8 | ||
|
0ebaecd1b4 | ||
984ae53213 | |||
1d885ff244 | |||
e96b7bd47d | |||
|
b88d282ae2 | ||
3a816b9f11 | |||
2482422302 | |||
|
89ad6fe39b | ||
|
655b21c0e9 | ||
64e5743893 | |||
70beaad4fa | |||
|
49f43f5dff | ||
|
e72f3f72f5 | ||
|
1d575cf63c | ||
|
7c23bd437f | ||
|
e65c8eb71e | ||
|
abbbd218ee | ||
|
5f13c98529 | ||
|
3ab3f97122 | ||
|
a9fe059b3c | ||
|
8346988604 | ||
|
522a8c2e23 | ||
|
8e144c8311 | ||
|
243d65699f | ||
|
f43863bd51 | ||
|
545e8ee177 | ||
|
d2f71aa993 | ||
0fbd27d41f | |||
7255c83ae9 | |||
8ff0664641 | |||
6315f54a23 | |||
fedc2bd6e4 | |||
892d8bf37e | |||
01cd067460 | |||
4135f6e427 | |||
c383f53025 | |||
3dc1076a88 | |||
4e91e0d5a1 | |||
73dd34449a | |||
491a8ab340 | |||
be132bd9e8 | |||
2797081091 | |||
e179be89fb | |||
e3b65c07b6 | |||
77c470f616 | |||
dc360be318 | |||
a610d0a35a | |||
a85b3d6ad2 | |||
6d3aa19663 | |||
|
63e2552604 | ||
|
172c1b826c | ||
|
ef73b3bde2 | ||
|
1e40bdd537 | ||
|
00e6840c32 | ||
|
822d3da5d9 | ||
|
98f1ca84b0 | ||
|
c7a5efcc78 | ||
|
0b1c5008f3 | ||
|
3bbca30296 | ||
|
05daa648cb | ||
|
a1026547cf | ||
|
e5bba46b80 | ||
|
41ca97e31a | ||
9a9d3ee4d5 | |||
17a64c51dd | |||
732c3626b5 | |||
348037a2ab | |||
6651b79188 | |||
373737ddaf | |||
cc1571dc26 | |||
7b61b6981a | |||
ac4bcbaca0 | |||
46c4b4dacb | |||
e5bca563f7 | |||
|
37d5ccc2e7 | ||
b82ce97259 | |||
b80023bb7f | |||
2c08e8b3ee | |||
a394882dcc | |||
e959230a22 | |||
7a647da798 | |||
1dc583e5f2 | |||
2e6d2b0dbc | |||
5ad9bc5748 | |||
8066824f90 | |||
42f34269f2 | |||
|
4f21d3f63b |
@ -1,14 +1,15 @@
|
|||||||
pipeline:
|
pipeline:
|
||||||
|
|
||||||
install:
|
install:
|
||||||
image: node:10.15.1
|
image: node:20.12.2
|
||||||
commands:
|
commands:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev
|
- apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev
|
||||||
|
- git submodule update --init --recursive
|
||||||
- npm install
|
- npm install
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: node:10.15.1
|
image: node:20.12.2
|
||||||
commands:
|
commands:
|
||||||
- npm run all
|
- npm run all
|
||||||
|
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ node_modules/
|
|||||||
dist/
|
dist/
|
||||||
.vscode/
|
.vscode/
|
||||||
*.tgz
|
*.tgz
|
||||||
|
**/.DS_store
|
||||||
|
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
@ -1,9 +1,15 @@
|
|||||||
{
|
{
|
||||||
"tags": {
|
"tags": {
|
||||||
"allowUnknownTags": true
|
"allowUnknownTags": true,
|
||||||
|
"dictionaries": ["jsdoc"]
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"include": [ "README.md", "dist/node" ],
|
||||||
|
"includePattern": ".js$"
|
||||||
},
|
},
|
||||||
"plugins": ["plugins/markdown"],
|
"plugins": ["plugins/markdown"],
|
||||||
"templates": {
|
"templates": {
|
||||||
|
"referenceTitle": "node-poweredup Reference",
|
||||||
"logoFile": "",
|
"logoFile": "",
|
||||||
"cleverLinks": false,
|
"cleverLinks": false,
|
||||||
"monospaceLinks": false,
|
"monospaceLinks": false,
|
||||||
@ -24,5 +30,11 @@
|
|||||||
"markdown": {
|
"markdown": {
|
||||||
"parser": "gfm",
|
"parser": "gfm",
|
||||||
"hardwrap": true
|
"hardwrap": true
|
||||||
|
},
|
||||||
|
"opts": {
|
||||||
|
"destination": "./docs/",
|
||||||
|
"encoding": "utf8",
|
||||||
|
"private": true,
|
||||||
|
"recurse": true
|
||||||
}
|
}
|
||||||
}
|
}
|
12
.npmignore
12
.npmignore
@ -1,17 +1,5 @@
|
|||||||
boostmovehub.ts
|
|
||||||
consts.ts
|
|
||||||
duplotrainbase.ts
|
|
||||||
hub.ts
|
|
||||||
index.ts
|
|
||||||
lpf2hub.ts
|
|
||||||
port.ts
|
|
||||||
poweredup.ts
|
|
||||||
puphub.ts
|
|
||||||
pupremote.ts
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
tslint.json
|
tslint.json
|
||||||
utils.ts
|
|
||||||
wedo2smarthub.ts
|
|
||||||
.vscode/
|
.vscode/
|
||||||
examples/
|
examples/
|
152
README.md
152
README.md
@ -1,66 +1,30 @@
|
|||||||
[](https://drone.kellenicki.com/nkellenicki/node-poweredup)
|
[](https://drone.kellenicki.com/nkellenicki/node-poweredup)
|
||||||
[](https://www.npmjs.com/package/node-poweredup)
|
[](https://www.npmjs.com/package/node-poweredup)
|
||||||
|
[](https://nathan.kellenicki.com/node-poweredup/)
|
||||||
|
|
||||||
# **node-poweredup** - A Javascript module to interface with LEGO Powered UP components.
|
# **node-poweredup** - A Javascript module to interface with LEGO Powered Up components.
|
||||||
|
|
||||||
|
### Announcements
|
||||||
|
|
||||||
|
* v7.1.0 adds support for SPIKE Essential, including the Technic Small Hub, Technic Small Angular Motor, and Technic 3x3 Color Matrix.
|
||||||
|
|
||||||
### Introduction
|
### Introduction
|
||||||
|
|
||||||
LEGO Powered UP is the successor to Power Functions, the system for adding electronics to LEGO models. Powered UP is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, and LEGO Powered UP released in 2018. It also includes the 2018 Duplo App-Controlled Train sets.
|
LEGO Powered Up is the successor to Power Functions, the system for adding electronics to LEGO models. Powered Up is a collection of ranges, all of which are compatible with each other:
|
||||||
|
|
||||||
This library allows communication and control of Powered UP devices and peripherals via Javascript, both from Node.js and from the browser using Web Bluetooth.
|
* LEGO Education WeDo 2.0
|
||||||
|
* LEGO Boost
|
||||||
|
* LEGO Powered Up
|
||||||
|
* LEGO Technic CONTROL+
|
||||||
|
* LEGO Education SPIKE Prime
|
||||||
|
* LEGO Education SPIKE Essential
|
||||||
|
* LEGO Mindstorms Robot Inventor
|
||||||
|
|
||||||
### Node.js Installation
|
Other products that speak the Powered Up protocol include the Duplo App-Controlled trains and LEGO Super Mario, both of which are compatible with this library.
|
||||||
|
|
||||||
Node.js v8.0 required.
|
This library allows communication and control of Powered Up devices and peripherals via Javascript, both from Node.js and from the browser using Web Bluetooth.
|
||||||
|
|
||||||
```javascript
|
### Sample Usage
|
||||||
npm install node-poweredup --save
|
|
||||||
```
|
|
||||||
|
|
||||||
node-poweredup uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/noble/noble#prerequisites).
|
|
||||||
|
|
||||||
Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B.
|
|
||||||
|
|
||||||
### Compatibility
|
|
||||||
|
|
||||||
While most Powered UP components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
|
|
||||||
|
|
||||||
| Device Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability |
|
|
||||||
| ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ |
|
|
||||||
| WeDo 2.0 Tilt Sensor | <a href="https://brickset.com/sets/45305-1/">45305</a> | Sensor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a> |
|
|
||||||
| WeDo 2.0 Motion Sensor | <a href="https://brickset.com/sets/45304-1/">45304</a> | Sensor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a> |
|
|
||||||
| WeDo 2.0 Medium Motor | <a href="https://brickset.com/sets/45303-1/">45303</a> | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a><br /> <a href="https://brickset.com/sets/76112-1/">76112</a> |
|
|
||||||
| Boost Color and Distance Sensor | <a href="https://brickset.com/sets/88007-1/">88007</a> | Sensor | *Partial* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
|
||||||
| Boost Tacho Motor | <a href="https://brickset.com/sets/88008-1/">88008</a> | Motor/Sensor | *Partial* | Yes | *Partial* | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
|
||||||
| Powered UP Train Motor | <a href="https://brickset.com/sets/88011-1/">88011</a> | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
|
||||||
| Powered UP LED Lights | <a href="https://brickset.com/sets/88005-1/">88005</a> | Light | Yes | Yes | Yes | <a href="https://brickset.com/sets/88005-1/">88005</a> |
|
|
||||||
|
|
||||||
In addition, the Hubs themselves have certain built-in features which this library exposes.
|
|
||||||
|
|
||||||
| Hub Name | Product Code | Built-In Features | Availability |
|
|
||||||
| ------------------ | ------------ | ---------------------- | ------------ |
|
|
||||||
| WeDo 2.0 Smart hub | <a href="https://brickset.com/sets/45301-1/">45301</a> | RGB LED<br />Piezo Buzzer<br />Button | <a href="https://brickset.com/sets/45300-1/">45300</a> |
|
|
||||||
| Boost Move Hub | <a href="https://brickset.com/sets/88006-1/">88006</a> | RGB LED<br />Tilt Sensor<br />2x Tacho Motors<br />Button | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
|
||||||
| Powered UP Hub | <a href="https://brickset.com/sets/88009-1/">88009</a> | RGB LED<br />Button | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a><br /><a href="https://brickset.com/sets/76112-1/">76112</a> |
|
|
||||||
| Powered UP Remote | <a href="https://brickset.com/sets/88010-1/">88010</a> | RGB LED<br />Left and Right Control Buttons<br />Button | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
|
||||||
| Duplo Train Base | 28743 | RGB LED/Headlights<br />Speaker<br />Speedometer<br />Motor<br />Color and Distance Sensor<br />Button | <a href="https://brickset.com/sets/10874-1/">10874</a><br /><a href="https://brickset.com/sets/10875-1/">10875</a> |
|
|
||||||
|
|
||||||
|
|
||||||
### Known Issues and Limitations
|
|
||||||
|
|
||||||
* The Boost Color and Distance sensor only works in color mode with the WeDo 2.0 Smart Hub.
|
|
||||||
|
|
||||||
* When used with the WeDo 2.0 Smart Hub, the Boost Tacho Motor does not support rotating the motor by angle.
|
|
||||||
|
|
||||||
* When used with the Powered UP Hub, the Boost Tacho Motor does not support rotating the motor by angle. It also does not support rotation detection.
|
|
||||||
|
|
||||||
* Plugging two Boost Tacho Motors into the Powered UP Hub will crash the Hub (This requires a firmware update from LEGO to fix).
|
|
||||||
|
|
||||||
### Documentation
|
|
||||||
|
|
||||||
[Full documentation is available here.](https://nathankellenicki.github.io/node-poweredup/)
|
|
||||||
|
|
||||||
### Node.js Sample Usage
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const PoweredUP = require("node-poweredup");
|
const PoweredUP = require("node-poweredup");
|
||||||
@ -69,17 +33,22 @@ const poweredUP = new PoweredUP.PoweredUP();
|
|||||||
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
|
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
|
||||||
console.log(`Discovered ${hub.name}!`);
|
console.log(`Discovered ${hub.name}!`);
|
||||||
await hub.connect(); // Connect to the Hub
|
await hub.connect(); // Connect to the Hub
|
||||||
|
const motorA = await hub.waitForDeviceAtPort("A"); // Make sure a motor is plugged into port A
|
||||||
|
const motorB = await hub.waitForDeviceAtPort("B"); // Make sure a motor is plugged into port B
|
||||||
console.log("Connected");
|
console.log("Connected");
|
||||||
await hub.sleep(3000); // Sleep for 3 seconds before starting
|
|
||||||
|
|
||||||
while (true) { // Repeat indefinitely
|
while (true) { // Repeat indefinitely
|
||||||
console.log("Running motor B at speed 75");
|
console.log("Running motor B at speed 50");
|
||||||
hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
|
motorB.setPower(50); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
|
||||||
console.log("Running motor A at speed 100 for 2 seconds");
|
console.log("Running motor A at speed 100 for 2 seconds");
|
||||||
await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
|
motorA.setPower(100); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
|
||||||
|
await hub.sleep(2000);
|
||||||
|
motorA.brake();
|
||||||
await hub.sleep(1000); // Do nothing for 1 second
|
await hub.sleep(1000); // Do nothing for 1 second
|
||||||
console.log("Running motor A at speed -50 for 1 seconds");
|
console.log("Running motor A at speed -30 for 1 second");
|
||||||
await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
|
motorA.setPower(-30); // Run a motor attached to port A for 2 seconds at 1/2 speed in reverse (-50) then stop
|
||||||
|
await hub.sleep(2000);
|
||||||
|
motorA.brake();
|
||||||
await hub.sleep(1000); // Do nothing for 1 second
|
await hub.sleep(1000); // Do nothing for 1 second
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -90,7 +59,70 @@ console.log("Scanning for Hubs...");
|
|||||||
|
|
||||||
More examples are available in the "examples" directory.
|
More examples are available in the "examples" directory.
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
[Full documentation is available here.](https://nathankellenicki.github.io/node-poweredup/)
|
||||||
|
|
||||||
|
### Node.js Installation
|
||||||
|
|
||||||
|
Node.js v12.0+ required.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
npm install node-poweredup --save
|
||||||
|
```
|
||||||
|
|
||||||
|
node-poweredup uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/abandonware/noble#prerequisites).
|
||||||
|
|
||||||
|
Note: node-poweredup has been tested on macOS 11.0 and Debian/Raspbian on the Raspberry Pi 3 Model B.
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
|
||||||
|
While most Powered Up components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
|
||||||
|
|
||||||
|
| Device Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered Up Hub | Control+ Hub | Availability |
|
||||||
|
| ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ | ----- |
|
||||||
|
| WeDo 2.0 Tilt Sensor | <a href="https://brickset.com/sets/45305-1/">45305</a> | Sensor | Yes | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a> |
|
||||||
|
| WeDo 2.0 Motion Sensor | <a href="https://brickset.com/sets/45304-1/">45304</a> | Sensor | Yes | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a> |
|
||||||
|
| WeDo 2.0 Medium Motor | <a href="https://brickset.com/sets/45303-1/">45303</a> | Motor | Yes | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a><br /> <a href="https://brickset.com/sets/76112-1/">76112</a> |
|
||||||
|
| Boost Color and Distance Sensor | <a href="https://brickset.com/sets/88007-1/">88007</a> | Sensor | *Partial* | Yes | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
|
| Boost Tacho Motor | <a href="https://brickset.com/sets/88008-1/">88008</a> | Motor/Sensor | *Partial* | Yes | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
|
| Powered Up Train Motor | <a href="https://brickset.com/sets/88011-1/">88011</a> | Motor | Yes | Yes | Yes | Yes | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
||||||
|
| Powered Up LED Lights | <a href="https://brickset.com/sets/88005-1/">88005</a> | Light | Yes | Yes | Yes | Yes | <a href="https://brickset.com/sets/88005-1/">88005</a> |
|
||||||
|
| Control+ Large Motor | 22169 | Motor/Sensor | *Partial* | No | Yes | Yes | <a href="https://brickset.com/sets/42099-1/">42099</a><br /><a href="https://brickset.com/sets/42100-1/">42100</a> |
|
||||||
|
| Control+ XLarge Motor | 22172 | Motor/Sensor | *Partial* | No | Yes | Yes | <a href="https://brickset.com/sets/42099-1/">42099</a><br /><a href="https://brickset.com/sets/42100-1/">42100</a> |
|
||||||
|
| SPIKE Prime Medium Motor | 45678 | Motor/Sensor | *Partial* | No | Yes | Yes | <a href="https://brickset.com/sets/45678-1/">45678</a> |
|
||||||
|
| SPIKE Prime Large Motor | 45678 | Motor/Sensor | *Partial* | No | Yes | Yes | <a href="https://brickset.com/sets/45678-1/">45678</a> |
|
||||||
|
| SPIKE Prime Color Sensor | 45678 | Sensor | No | No | Yes | Yes | <a href="https://brickset.com/sets/45678-1/">45678</a> |
|
||||||
|
| SPIKE Prime Distance Sensor | 45678 | Sensor | No | No | Yes | Yes | <a href="https://brickset.com/sets/45678-1/">45678</a> |
|
||||||
|
| SPIKE Prime Force Sensor | 45678 | Sensor | *Partial* | Yes | Yes | Yes | <a href="https://brickset.com/sets/45678-1/">45678</a> |
|
||||||
|
| SPIKE Essential Small Motor | 45607 | Motor/Sensor | *Partial* | No | Yes | Yes | <a href="https://brickset.com/sets/45345-1/">45345</a> |
|
||||||
|
| SPIKE Essential 3x3 Color Matrix | 45608 | Motor/Sensor | *Partial* | No | Yes | Yes | <a href="https://brickset.com/sets/45345-1/">45345</a> |
|
||||||
|
|
||||||
|
|
||||||
|
In addition, the Hubs themselves have certain built-in features which this library exposes.
|
||||||
|
|
||||||
|
| Hub Name | Product Code | Built-In Features | Availability |
|
||||||
|
| ------------------ | ------------ | ---------------------- | ------------ |
|
||||||
|
| WeDo 2.0 Smart hub | <a href="https://brickset.com/sets/45301-1/">45301</a> | RGB LED<br />Piezo Buzzer<br />Button | <a href="https://brickset.com/sets/45300-1/">45300</a> |
|
||||||
|
| Boost Move Hub | <a href="https://brickset.com/sets/88006-1/">88006</a> | RGB LED<br />Tilt Sensor<br />2x Tacho Motors<br />Button | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
|
| Powered Up Hub | <a href="https://brickset.com/sets/88009-1/">88009</a> | RGB LED<br />Button | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a><br /><a href="https://brickset.com/sets/76112-1/">76112</a> |
|
||||||
|
| Powered Up Remote | <a href="https://brickset.com/sets/88010-1/">88010</a> | RGB LED<br />Left and Right Control Buttons<br />Button | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
||||||
|
| Duplo Train Base | 28743 | RGB LED/Headlights<br />Speaker<br />Speedometer<br />Motor<br />Color and Distance Sensor<br />Button | <a href="https://brickset.com/sets/10874-1/">10874</a><br /><a href="https://brickset.com/sets/10875-1/">10875</a> |
|
||||||
|
| Control+ Hub | 22127 | RGB LED<br />Button<br />Tilt Sensor<br />Accelerometer | <a href="https://brickset.com/sets/42099-1/">42099</a><br /><a href="https://brickset.com/sets/42100-1/">42100</a> |
|
||||||
|
| Super Mario | 71360 | Pants Sensor<br />Barcode and Color Sensor | <a href="https://brickset.com/sets/71360-1/">71360</a> |
|
||||||
|
| SPIKE Essential Hub | 45609 | RGB LED<br />Button<br />Tilt Sensor<br />Accelerometer | <a href="https://brickset.com/sets/45345-1/">45345</a> |
|
||||||
|
|
||||||
|
### Known Issues and Limitations
|
||||||
|
|
||||||
|
* The WeDo 2.0 Smart Hub uses an older firmware which is no longer being updated. As a result, only certain motors and sensors work with it. See the table above.
|
||||||
|
|
||||||
|
* When used with the Boost Move Hub, the Control+ Motors and SPIKE Prime Motors/Sensors do not currently accept commands (This is a known bug which requires a firmware update from Lego to fix)
|
||||||
|
|
||||||
|
* The SPIKE Prime Hub does not use Bluetooth Low Energy, so is not supported via this library. It is recommended you use MicroPython to develop for this Hub using the officially provided tools and software. The SPIKE Essential Hub however is supported, as it uses Bluetooth Low Energy.
|
||||||
|
|
||||||
|
* On most Unix systems, you need root permissions to access Bluetooth devices. You may want to [grant the node executable access to the Bluetooth adapter](https://github.com/abandonware/noble#running-without-rootsudo-linux-specific)
|
||||||
|
|
||||||
### Credits
|
### Credits
|
||||||
|
|
||||||
Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian Raff ([@hobbyquaker](https://github.com/hobbyquaker)), Valentin Heun ([@vheun](https://github.com/vheun)), Johan Korten ([@jakorten](https://github.com/jakorten)), and Andrey Pokhilko ([@undera](https://github.com/undera)) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered UP protocols.
|
Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian Raff ([@hobbyquaker](https://github.com/hobbyquaker)), Valentin Heun ([@vheun](https://github.com/vheun)), Johan Korten ([@jakorten](https://github.com/jakorten)), and Andrey Pokhilko ([@undera](https://github.com/undera)) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered Up protocols.
|
||||||
|
|
||||||
|
129
abandonware-noble.d.ts
vendored
Normal file
129
abandonware-noble.d.ts
vendored
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
declare module "@abandonware/noble" {
|
||||||
|
// Type definitions for noble
|
||||||
|
// Project: https://github.com/sandeepmistry/noble
|
||||||
|
// Definitions by: Seon-Wook Park <https://github.com/swook>
|
||||||
|
// Shantanu Bhadoria <https://github.com/shantanubhadoria>
|
||||||
|
// Luke Libraro <https://github.com/lukel99>
|
||||||
|
// Dan Chao <https://github.com/bioball>
|
||||||
|
// Michal Lower <https://github.com/keton>
|
||||||
|
// Rob Moran <https://github.com/thegecko>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import events = require("events");
|
||||||
|
|
||||||
|
export function startScanning(callback?: (error?: Error) => void): void;
|
||||||
|
export function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void;
|
||||||
|
export function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void;
|
||||||
|
export function stopScanning(callback?: () => void): void;
|
||||||
|
|
||||||
|
export function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
||||||
|
export function on(event: "scanStart", listener: () => void): events.EventEmitter;
|
||||||
|
export function on(event: "scanStop", listener: () => void): events.EventEmitter;
|
||||||
|
export function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
||||||
|
export function on(event: string, listener: Function): events.EventEmitter;
|
||||||
|
|
||||||
|
export function removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
|
||||||
|
export function removeListener(event: "scanStart", listener: () => void): events.EventEmitter;
|
||||||
|
export function removeListener(event: "scanStop", listener: () => void): events.EventEmitter;
|
||||||
|
export function removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
|
||||||
|
export function removeListener(event: string, listener: Function): events.EventEmitter;
|
||||||
|
|
||||||
|
export var state:string;
|
||||||
|
|
||||||
|
export class Peripheral extends events.EventEmitter {
|
||||||
|
id: string;
|
||||||
|
uuid: string;
|
||||||
|
address: string;
|
||||||
|
addressType: string;
|
||||||
|
connectable: boolean;
|
||||||
|
advertisement: Advertisement;
|
||||||
|
rssi: number;
|
||||||
|
services: Service[];
|
||||||
|
state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected';
|
||||||
|
|
||||||
|
connect(callback?: (error: string) => void): void;
|
||||||
|
disconnect(callback?: () => void): void;
|
||||||
|
updateRssi(callback?: (error: string, rssi: number) => void): void;
|
||||||
|
discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void;
|
||||||
|
discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
|
||||||
|
discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
|
||||||
|
|
||||||
|
readHandle(handle: Buffer, callback: (error: string, data: Buffer) => void): void;
|
||||||
|
writeHandle(handle: Buffer, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void;
|
||||||
|
toString(): string;
|
||||||
|
|
||||||
|
on(event: "connect", listener: (error: string) => void): this;
|
||||||
|
on(event: "disconnect", listener: (error: string) => void): this;
|
||||||
|
on(event: "rssiUpdate", listener: (rssi: number) => void): this;
|
||||||
|
on(event: "servicesDiscover", listener: (services: Service[]) => void): this;
|
||||||
|
on(event: string, listener: Function): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Advertisement {
|
||||||
|
localName: string;
|
||||||
|
serviceData: {
|
||||||
|
uuid: string,
|
||||||
|
data: Buffer
|
||||||
|
};
|
||||||
|
txPowerLevel: number;
|
||||||
|
manufacturerData: Buffer;
|
||||||
|
serviceUuids: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Service extends events.EventEmitter {
|
||||||
|
uuid: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
includedServiceUuids: string[];
|
||||||
|
characteristics: Characteristic[];
|
||||||
|
|
||||||
|
discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void;
|
||||||
|
discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void;
|
||||||
|
toString(): string;
|
||||||
|
|
||||||
|
on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
|
||||||
|
on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
|
||||||
|
on(event: string, listener: Function): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Characteristic extends events.EventEmitter {
|
||||||
|
uuid: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
properties: string[];
|
||||||
|
descriptors: Descriptor[];
|
||||||
|
|
||||||
|
read(callback?: (error: string, data: Buffer) => void): void;
|
||||||
|
write(data: Buffer, notify: boolean, callback?: (error: string) => void): void;
|
||||||
|
broadcast(broadcast: boolean, callback?: (error: string) => void): void;
|
||||||
|
notify(notify: boolean, callback?: (error: string) => void): void;
|
||||||
|
discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void;
|
||||||
|
toString(): string;
|
||||||
|
subscribe(callback?: (error: string) => void): void;
|
||||||
|
unsubscribe(callback?: (error: string) => void): void;
|
||||||
|
|
||||||
|
on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
|
||||||
|
on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
|
||||||
|
on(event: "broadcast", listener: (state: string) => void): this;
|
||||||
|
on(event: "notify", listener: (state: string) => void): this;
|
||||||
|
on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
|
||||||
|
on(event: string, listener: Function): this;
|
||||||
|
on(event: string, option: boolean, listener: Function): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Descriptor extends events.EventEmitter {
|
||||||
|
uuid: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
|
||||||
|
readValue(callback?: (error: string, data: Buffer) => void): void;
|
||||||
|
writeValue(data: Buffer, callback?: (error: string) => void): void;
|
||||||
|
toString(): string;
|
||||||
|
|
||||||
|
on(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
|
||||||
|
on(event: "valueWrite", listener: (error: string) => void): this;
|
||||||
|
on(event: string, listener: Function): this;
|
||||||
|
}
|
||||||
|
}
|
2008
docs/AbsoluteMotor.html
Normal file
2008
docs/AbsoluteMotor.html
Normal file
File diff suppressed because one or more lines are too long
1391
docs/BaseHub.html
Normal file
1391
docs/BaseHub.html
Normal file
File diff suppressed because one or more lines are too long
1459
docs/BasicMotor.html
Normal file
1459
docs/BasicMotor.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
3025
docs/ColorDistanceSensor.html
Normal file
3025
docs/ColorDistanceSensor.html
Normal file
File diff suppressed because one or more lines are too long
1022
docs/CurrentSensor.html
Normal file
1022
docs/CurrentSensor.html
Normal file
File diff suppressed because one or more lines are too long
841
docs/Device.html
Normal file
841
docs/Device.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1509
docs/DuploTrainBaseColorSensor.html
Normal file
1509
docs/DuploTrainBaseColorSensor.html
Normal file
File diff suppressed because one or more lines are too long
1479
docs/DuploTrainBaseMotor.html
Normal file
1479
docs/DuploTrainBaseMotor.html
Normal file
File diff suppressed because one or more lines are too long
1193
docs/DuploTrainBaseSpeaker.html
Normal file
1193
docs/DuploTrainBaseSpeaker.html
Normal file
File diff suppressed because one or more lines are too long
871
docs/DuploTraniBaseSpeedometer.html
Normal file
871
docs/DuploTraniBaseSpeedometer.html
Normal file
File diff suppressed because one or more lines are too long
7892
docs/Hub.html
7892
docs/Hub.html
File diff suppressed because one or more lines are too long
1239
docs/HubLED.html
Normal file
1239
docs/HubLED.html
Normal file
File diff suppressed because one or more lines are too long
4782
docs/LPF2Hub.html
4782
docs/LPF2Hub.html
File diff suppressed because one or more lines are too long
1239
docs/Light.html
Normal file
1239
docs/Light.html
Normal file
File diff suppressed because one or more lines are too long
2092
docs/Mario.html
Normal file
2092
docs/Mario.html
Normal file
File diff suppressed because one or more lines are too long
1215
docs/MarioAccelerometer.html
Normal file
1215
docs/MarioAccelerometer.html
Normal file
File diff suppressed because one or more lines are too long
1215
docs/MarioBarcodeSensor.html
Normal file
1215
docs/MarioBarcodeSensor.html
Normal file
File diff suppressed because one or more lines are too long
1022
docs/MarioPantsSensor.html
Normal file
1022
docs/MarioPantsSensor.html
Normal file
File diff suppressed because one or more lines are too long
1357
docs/MediumLinearMotor.html
Normal file
1357
docs/MediumLinearMotor.html
Normal file
File diff suppressed because one or more lines are too long
1022
docs/MotionSensor.html
Normal file
1022
docs/MotionSensor.html
Normal file
File diff suppressed because one or more lines are too long
2092
docs/MoveHub.html
Normal file
2092
docs/MoveHub.html
Normal file
File diff suppressed because one or more lines are too long
1357
docs/MoveHubMediumLinearMotor.html
Normal file
1357
docs/MoveHubMediumLinearMotor.html
Normal file
File diff suppressed because one or more lines are too long
1045
docs/MoveHubTiltSensor.html
Normal file
1045
docs/MoveHubTiltSensor.html
Normal file
File diff suppressed because one or more lines are too long
5251
docs/PUPHub.html
5251
docs/PUPHub.html
File diff suppressed because it is too large
Load Diff
3503
docs/PUPRemote.html
3503
docs/PUPRemote.html
File diff suppressed because it is too large
Load Diff
1057
docs/PiezoBuzzer.html
Normal file
1057
docs/PiezoBuzzer.html
Normal file
File diff suppressed because one or more lines are too long
4367
docs/PoweredUP.html
4367
docs/PoweredUP.html
File diff suppressed because one or more lines are too long
2092
docs/RemoteControl.html
Normal file
2092
docs/RemoteControl.html
Normal file
File diff suppressed because one or more lines are too long
1022
docs/RemoteControlButton.html
Normal file
1022
docs/RemoteControlButton.html
Normal file
File diff suppressed because one or more lines are too long
871
docs/SimpleMediumLinearMotor.html
Normal file
871
docs/SimpleMediumLinearMotor.html
Normal file
File diff suppressed because one or more lines are too long
2620
docs/TachoMotor.html
Normal file
2620
docs/TachoMotor.html
Normal file
File diff suppressed because one or more lines are too long
1037
docs/Technic3x3ColorLightMatrix.html
Normal file
1037
docs/Technic3x3ColorLightMatrix.html
Normal file
File diff suppressed because one or more lines are too long
1525
docs/TechnicColorSensor.html
Normal file
1525
docs/TechnicColorSensor.html
Normal file
File diff suppressed because one or more lines are too long
1401
docs/TechnicDistanceSensor.html
Normal file
1401
docs/TechnicDistanceSensor.html
Normal file
File diff suppressed because one or more lines are too long
1316
docs/TechnicForceSensor.html
Normal file
1316
docs/TechnicForceSensor.html
Normal file
File diff suppressed because one or more lines are too long
2028
docs/TechnicLargeAngularMotor.html
Normal file
2028
docs/TechnicLargeAngularMotor.html
Normal file
File diff suppressed because one or more lines are too long
2028
docs/TechnicLargeLinearMotor.html
Normal file
2028
docs/TechnicLargeLinearMotor.html
Normal file
File diff suppressed because one or more lines are too long
2028
docs/TechnicMediumAngularMotor.html
Normal file
2028
docs/TechnicMediumAngularMotor.html
Normal file
File diff suppressed because one or more lines are too long
2092
docs/TechnicMediumHub.html
Normal file
2092
docs/TechnicMediumHub.html
Normal file
File diff suppressed because one or more lines are too long
1068
docs/TechnicMediumHubAccelerometerSensor.html
Normal file
1068
docs/TechnicMediumHubAccelerometerSensor.html
Normal file
File diff suppressed because one or more lines are too long
1068
docs/TechnicMediumHubGyroSensor.html
Normal file
1068
docs/TechnicMediumHubGyroSensor.html
Normal file
File diff suppressed because one or more lines are too long
1696
docs/TechnicMediumHubTiltSensor.html
Normal file
1696
docs/TechnicMediumHubTiltSensor.html
Normal file
File diff suppressed because one or more lines are too long
2028
docs/TechnicSmallAngularMotor.html
Normal file
2028
docs/TechnicSmallAngularMotor.html
Normal file
File diff suppressed because one or more lines are too long
2028
docs/TechnicXLargeLinearMotor.html
Normal file
2028
docs/TechnicXLargeLinearMotor.html
Normal file
File diff suppressed because one or more lines are too long
1045
docs/TiltSensor.html
Normal file
1045
docs/TiltSensor.html
Normal file
File diff suppressed because one or more lines are too long
1479
docs/TrainMotor.html
Normal file
1479
docs/TrainMotor.html
Normal file
File diff suppressed because one or more lines are too long
1022
docs/VoltageSensor.html
Normal file
1022
docs/VoltageSensor.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,445 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
<title>node-poweredup Source: boostmovehub.js</title>
|
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
|
|
||||||
<div class="container">
|
|
||||||
<div class="navbar-header">
|
|
||||||
<a class="navbar-brand" href="index.html">node-poweredup</a>
|
|
||||||
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="navbar-collapse collapse" id="topNavigation">
|
|
||||||
<ul class="nav navbar-nav">
|
|
||||||
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu ">
|
|
||||||
<li><a href="BoostMoveHub.html">BoostMoveHub</a></li><li><a href="DuploTrainBase.html">DuploTrainBase</a></li><li><a href="Hub.html">Hub</a></li><li><a href="LPF2Hub.html">LPF2Hub</a></li><li><a href="PoweredUP.html">PoweredUP</a></li><li><a href="PUPHub.html">PUPHub</a></li><li><a href="PUPRemote.html">PUPRemote</a></li><li><a href="WeDo2SmartHub.html">WeDo2SmartHub</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu ">
|
|
||||||
<li><a href="BoostMoveHub.html#event:attach">BoostMoveHub#event:attach</a></li><li><a href="BoostMoveHub.html#event:button">BoostMoveHub#event:button</a></li><li><a href="BoostMoveHub.html#event:color">BoostMoveHub#event:color</a></li><li><a href="BoostMoveHub.html#event:colorAndDistance">BoostMoveHub#event:colorAndDistance</a></li><li><a href="BoostMoveHub.html#event:detach">BoostMoveHub#event:detach</a></li><li><a href="BoostMoveHub.html#event:distance">BoostMoveHub#event:distance</a></li><li><a href="BoostMoveHub.html#event:rotate">BoostMoveHub#event:rotate</a></li><li><a href="BoostMoveHub.html#event:tilt">BoostMoveHub#event:tilt</a></li><li><a href="DuploTrainBase.html#event:color">DuploTrainBase#event:color</a></li><li><a href="DuploTrainBase.html#event:speed">DuploTrainBase#event:speed</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:detach">Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:attach">LPF2Hub#event:attach</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:color">LPF2Hub#event:color</a></li><li><a href="LPF2Hub.html#event:colorAndDistance">LPF2Hub#event:colorAndDistance</a></li><li><a href="LPF2Hub.html#event:detach">LPF2Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:distance">LPF2Hub#event:distance</a></li><li><a href="LPF2Hub.html#event:rotate">LPF2Hub#event:rotate</a></li><li><a href="LPF2Hub.html#event:speed">LPF2Hub#event:speed</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="PoweredUP.html#event:discover">PoweredUP#event:discover</a></li><li><a href="PUPHub.html#event:attach">PUPHub#event:attach</a></li><li><a href="PUPHub.html#event:button">PUPHub#event:button</a></li><li><a href="PUPHub.html#event:color">PUPHub#event:color</a></li><li><a href="PUPHub.html#event:colorAndDistance">PUPHub#event:colorAndDistance</a></li><li><a href="PUPHub.html#event:detach">PUPHub#event:detach</a></li><li><a href="PUPHub.html#event:distance">PUPHub#event:distance</a></li><li><a href="PUPHub.html#event:tilt">PUPHub#event:tilt</a></li><li><a href="PUPRemote.html#event:button">PUPRemote#event:button</a></li><li><a href="PUPRemote.html#event:colorAndDistance">PUPRemote#event:colorAndDistance</a></li><li><a href="WeDo2SmartHub.html#event:attach">WeDo2SmartHub#event:attach</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</a></li><li><a href="WeDo2SmartHub.html#event:color">WeDo2SmartHub#event:color</a></li><li><a href="WeDo2SmartHub.html#event:detach">WeDo2SmartHub#event:detach</a></li><li><a href="WeDo2SmartHub.html#event:distance">WeDo2SmartHub#event:distance</a></li><li><a href="WeDo2SmartHub.html#event:rotate">WeDo2SmartHub#event:rotate</a></li><li><a href="WeDo2SmartHub.html#event:tilt">WeDo2SmartHub#event:tilt</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu ">
|
|
||||||
<li><a href="global.html">Global</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="col-sm-3 col-md-3">
|
|
||||||
<form class="navbar-form" role="search">
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
|
|
||||||
<div class="input-group-btn">
|
|
||||||
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container" id="toc-content">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-12">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<h1 class="page-title">Source: boostmovehub.js</h1>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<article>
|
|
||||||
<pre
|
|
||||||
class="sunlight-highlight-javascript linenums">"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const lpf2hub_1 = require("./lpf2hub");
|
|
||||||
const port_1 = require("./port");
|
|
||||||
const Consts = __importStar(require("./consts"));
|
|
||||||
const Debug = require("debug");
|
|
||||||
const debug = Debug("boostmovehub");
|
|
||||||
/**
|
|
||||||
* The BoostMoveHub is emitted if the discovered device is a Boost Move Hub.
|
|
||||||
* @class BoostMoveHub
|
|
||||||
* @extends LPF2Hub
|
|
||||||
* @extends Hub
|
|
||||||
*/
|
|
||||||
class BoostMoveHub extends lpf2hub_1.LPF2Hub {
|
|
||||||
// We set JSDoc to ignore these events as a Boost Move Hub will never emit them.
|
|
||||||
/**
|
|
||||||
* @event BoostMoveHub#speed
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
static IsBoostMoveHub(peripheral) {
|
|
||||||
return (peripheral.advertisement &&
|
|
||||||
peripheral.advertisement.serviceUuids &&
|
|
||||||
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.BOOST_MOVE_HUB_ID);
|
|
||||||
}
|
|
||||||
constructor(device, autoSubscribe = true) {
|
|
||||||
super(device, autoSubscribe);
|
|
||||||
this.type = Consts.HubType.BOOST_MOVE_HUB;
|
|
||||||
this._ports = {
|
|
||||||
"A": new port_1.Port("A", 55),
|
|
||||||
"B": new port_1.Port("B", 56),
|
|
||||||
"AB": new port_1.Port("AB", 57),
|
|
||||||
"TILT": new port_1.Port("TILT", 58),
|
|
||||||
"C": new port_1.Port("C", 1),
|
|
||||||
"D": new port_1.Port("D", 2)
|
|
||||||
};
|
|
||||||
debug("Discovered Boost Move Hub");
|
|
||||||
}
|
|
||||||
connect() {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
debug("Connecting to Boost Move Hub");
|
|
||||||
await super.connect();
|
|
||||||
debug("Connect completed");
|
|
||||||
return resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the motor speed on a given port.
|
|
||||||
* @method BoostMoveHub#setMotorSpeed
|
|
||||||
* @param {string} port
|
|
||||||
* @param {number | Array.<number>} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
|
|
||||||
* @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
|
||||||
*/
|
|
||||||
setMotorSpeed(port, speed, time) {
|
|
||||||
const portObj = this._portLookup(port);
|
|
||||||
if (portObj.id !== "AB" && speed instanceof Array) {
|
|
||||||
throw new Error(`Port ${portObj.id} can only accept a single speed`);
|
|
||||||
}
|
|
||||||
let cancelEventTimer = true;
|
|
||||||
if (typeof time === "boolean") {
|
|
||||||
if (time === true) {
|
|
||||||
cancelEventTimer = false;
|
|
||||||
}
|
|
||||||
time = undefined;
|
|
||||||
}
|
|
||||||
if (cancelEventTimer) {
|
|
||||||
portObj.cancelEventTimer();
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (time && typeof time === "number") {
|
|
||||||
if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR) {
|
|
||||||
portObj.busy = true;
|
|
||||||
let data = null;
|
|
||||||
if (portObj.id === "AB") {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
data.writeUInt16LE(time > 65535 ? 65535 : time, 4);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
portObj.finished = () => {
|
|
||||||
return resolve();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
const timeout = global.setTimeout(() => {
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
// @ts-ignore: The type of time is properly checked at the start
|
|
||||||
}, time);
|
|
||||||
portObj.setEventTimer(timeout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR) {
|
|
||||||
portObj.busy = true;
|
|
||||||
let data = null;
|
|
||||||
if (portObj.id === "AB") {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
portObj.finished = () => {
|
|
||||||
return resolve();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Ramp the motor speed on a given port.
|
|
||||||
* @method BoostMoveHub#rampMotorSpeed
|
|
||||||
* @param {string} port
|
|
||||||
* @param {number} fromSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
||||||
* @param {number} toSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
||||||
* @param {number} time How long the ramp should last (in milliseconds).
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command.
|
|
||||||
*/
|
|
||||||
rampMotorSpeed(port, fromSpeed, toSpeed, time) {
|
|
||||||
const portObj = this._portLookup(port);
|
|
||||||
portObj.cancelEventTimer();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._calculateRamp(fromSpeed, toSpeed, time, portObj)
|
|
||||||
.on("changeSpeed", (speed) => {
|
|
||||||
this.setMotorSpeed(port, speed, true);
|
|
||||||
})
|
|
||||||
.on("finished", resolve);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Rotate a motor by a given angle.
|
|
||||||
* @method BoostMoveHub#setMotorAngle
|
|
||||||
* @param {string} port
|
|
||||||
* @param {number} angle How much the motor should be rotated (in degrees).
|
|
||||||
* @param {number | Array.<number>} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
||||||
*/
|
|
||||||
setMotorAngle(port, angle, speed = 100) {
|
|
||||||
const portObj = this._portLookup(port);
|
|
||||||
if (!(portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR)) {
|
|
||||||
throw new Error("Angle rotation is only available when using a Boost Tacho Motor or Boost Move Hub Motor");
|
|
||||||
}
|
|
||||||
if (portObj.id !== "AB" && speed instanceof Array) {
|
|
||||||
throw new Error(`Port ${portObj.id} can only accept a single speed`);
|
|
||||||
}
|
|
||||||
portObj.cancelEventTimer();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
portObj.busy = true;
|
|
||||||
let data = null;
|
|
||||||
if (portObj.id === "AB") {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
data.writeUInt32LE(angle, 4);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
portObj.finished = () => {
|
|
||||||
return resolve();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Fully (hard) stop the motor on a given port.
|
|
||||||
* @method BoostMoveHub#brakeMotor
|
|
||||||
* @param {string} port
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command.
|
|
||||||
*/
|
|
||||||
brakeMotor(port) {
|
|
||||||
return this.setMotorSpeed(port, 127);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the light brightness on a given port.
|
|
||||||
* @method BoostMoveHub#setLightBrightness
|
|
||||||
* @param {string} port
|
|
||||||
* @param {number} brightness Brightness value between 0-100 (0 is off)
|
|
||||||
* @param {number} [time] How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
|
|
||||||
*/
|
|
||||||
setLightBrightness(port, brightness, time) {
|
|
||||||
const portObj = this._portLookup(port);
|
|
||||||
portObj.cancelEventTimer();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, brightness]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
if (time) {
|
|
||||||
const timeout = global.setTimeout(() => {
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
}, time);
|
|
||||||
portObj.setEventTimer(timeout);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BoostMoveHub = BoostMoveHub;
|
|
||||||
//# sourceMappingURL=boostmovehub.js.map</pre>
|
|
||||||
</article>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="modal fade" id="searchResults">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<h4 class="modal-title">Search results</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body"></div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
||||||
</div>
|
|
||||||
</div><!-- /.modal-content -->
|
|
||||||
</div><!-- /.modal-dialog -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
|
|
||||||
|
|
||||||
<span class="copyright">
|
|
||||||
node-poweredup by Nathan Kellenicki licensed under the MIT license.
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="jsdoc-message">
|
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
|
|
||||||
|
|
||||||
on Wed Mar 20th 2019
|
|
||||||
|
|
||||||
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
|
|
||||||
</span>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script src="scripts/docstrap.lib.js"></script>
|
|
||||||
<script src="scripts/toc.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$( function () {
|
|
||||||
$( "[id*='$']" ).each( function () {
|
|
||||||
var $this = $( this );
|
|
||||||
|
|
||||||
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
|
|
||||||
var $this = $( this );
|
|
||||||
|
|
||||||
var example = $this.find( "code" );
|
|
||||||
exampleText = example.html();
|
|
||||||
var lang = /{@lang (.*?)}/.exec( exampleText );
|
|
||||||
if ( lang && lang[1] ) {
|
|
||||||
exampleText = exampleText.replace( lang[0], "" );
|
|
||||||
example.html( exampleText );
|
|
||||||
lang = lang[1];
|
|
||||||
} else {
|
|
||||||
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
|
|
||||||
lang = langClassMatch ? langClassMatch[1] : "javascript";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( lang ) {
|
|
||||||
|
|
||||||
$this
|
|
||||||
.addClass( "sunlight-highlight-" + lang )
|
|
||||||
.addClass( "linenums" )
|
|
||||||
.html( example.html() );
|
|
||||||
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
Sunlight.highlightAll( {
|
|
||||||
lineNumbers : true,
|
|
||||||
showMenu : true,
|
|
||||||
enableDoclinks : true
|
|
||||||
} );
|
|
||||||
|
|
||||||
$.catchAnchorLinks( {
|
|
||||||
navbarOffset: 10
|
|
||||||
} );
|
|
||||||
$( "#toc" ).toc( {
|
|
||||||
anchorName : function ( i, heading, prefix ) {
|
|
||||||
return $( heading ).attr( "id" ) || ( prefix + i );
|
|
||||||
},
|
|
||||||
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
|
|
||||||
showAndHide : false,
|
|
||||||
smoothScrolling: true
|
|
||||||
} );
|
|
||||||
|
|
||||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
|
||||||
$( '.dropdown-toggle' ).dropdown();
|
|
||||||
|
|
||||||
$( "table" ).each( function () {
|
|
||||||
var $this = $( this );
|
|
||||||
$this.addClass('table');
|
|
||||||
} );
|
|
||||||
|
|
||||||
} );
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Navigation and Symbol Display-->
|
|
||||||
|
|
||||||
|
|
||||||
<!--Google Analytics-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
SearcherDisplay.init();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
195
docs/devices_absolutemotor.js.html
Normal file
195
docs/devices_absolutemotor.js.html
Normal file
File diff suppressed because one or more lines are too long
138
docs/devices_basicmotor.js.html
Normal file
138
docs/devices_basicmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
361
docs/devices_colordistancesensor.js.html
Normal file
361
docs/devices_colordistancesensor.js.html
Normal file
File diff suppressed because one or more lines are too long
132
docs/devices_currentsensor.js.html
Normal file
132
docs/devices_currentsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
239
docs/devices_device.js.html
Normal file
239
docs/devices_device.js.html
Normal file
File diff suppressed because one or more lines are too long
154
docs/devices_duplotrainbasecolorsensor.js.html
Normal file
154
docs/devices_duplotrainbasecolorsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_duplotrainbasemotor.js.html
Normal file
89
docs/devices_duplotrainbasemotor.js.html
Normal file
File diff suppressed because one or more lines are too long
117
docs/devices_duplotrainbasespeaker.js.html
Normal file
117
docs/devices_duplotrainbasespeaker.js.html
Normal file
File diff suppressed because one or more lines are too long
111
docs/devices_duplotrainbasespeedometer.js.html
Normal file
111
docs/devices_duplotrainbasespeedometer.js.html
Normal file
File diff suppressed because one or more lines are too long
137
docs/devices_hubled.js.html
Normal file
137
docs/devices_hubled.js.html
Normal file
File diff suppressed because one or more lines are too long
123
docs/devices_light.js.html
Normal file
123
docs/devices_light.js.html
Normal file
File diff suppressed because one or more lines are too long
127
docs/devices_marioaccelerometer.js.html
Normal file
127
docs/devices_marioaccelerometer.js.html
Normal file
File diff suppressed because one or more lines are too long
135
docs/devices_mariobarcodesensor.js.html
Normal file
135
docs/devices_mariobarcodesensor.js.html
Normal file
File diff suppressed because one or more lines are too long
111
docs/devices_mariopantssensor.js.html
Normal file
111
docs/devices_mariopantssensor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_mediumlinearmotor.js.html
Normal file
89
docs/devices_mediumlinearmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
115
docs/devices_motionsensor.js.html
Normal file
115
docs/devices_motionsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_movehubmediumlinearmotor.js.html
Normal file
89
docs/devices_movehubmediumlinearmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
113
docs/devices_movehubtiltsensor.js.html
Normal file
113
docs/devices_movehubtiltsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
105
docs/devices_piezobuzzer.js.html
Normal file
105
docs/devices_piezobuzzer.js.html
Normal file
File diff suppressed because one or more lines are too long
117
docs/devices_remotecontrolbutton.js.html
Normal file
117
docs/devices_remotecontrolbutton.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_simplemediumlinearmotor.js.html
Normal file
89
docs/devices_simplemediumlinearmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
244
docs/devices_tachomotor.js.html
Normal file
244
docs/devices_tachomotor.js.html
Normal file
File diff suppressed because one or more lines are too long
131
docs/devices_technic3x3colorlightmatrix.js.html
Normal file
131
docs/devices_technic3x3colorlightmatrix.js.html
Normal file
File diff suppressed because one or more lines are too long
149
docs/devices_techniccolorsensor.js.html
Normal file
149
docs/devices_techniccolorsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
135
docs/devices_technicdistancesensor.js.html
Normal file
135
docs/devices_technicdistancesensor.js.html
Normal file
File diff suppressed because one or more lines are too long
135
docs/devices_technicforcesensor.js.html
Normal file
135
docs/devices_technicforcesensor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_techniclargeangularmotor.js.html
Normal file
89
docs/devices_techniclargeangularmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_techniclargelinearmotor.js.html
Normal file
89
docs/devices_techniclargelinearmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_technicmediumangularmotor.js.html
Normal file
89
docs/devices_technicmediumangularmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
115
docs/devices_technicmediumhubaccelerometersensor.js.html
Normal file
115
docs/devices_technicmediumhubaccelerometersensor.js.html
Normal file
File diff suppressed because one or more lines are too long
115
docs/devices_technicmediumhubgyrosensor.js.html
Normal file
115
docs/devices_technicmediumhubgyrosensor.js.html
Normal file
File diff suppressed because one or more lines are too long
183
docs/devices_technicmediumhubtiltsensor.js.html
Normal file
183
docs/devices_technicmediumhubtiltsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_technicsmallangularmotor.js.html
Normal file
89
docs/devices_technicsmallangularmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_technicxlargelinearmotor.js.html
Normal file
89
docs/devices_technicxlargelinearmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
113
docs/devices_tiltsensor.js.html
Normal file
113
docs/devices_tiltsensor.js.html
Normal file
File diff suppressed because one or more lines are too long
89
docs/devices_trainmotor.js.html
Normal file
89
docs/devices_trainmotor.js.html
Normal file
File diff suppressed because one or more lines are too long
136
docs/devices_voltagesensor.js.html
Normal file
136
docs/devices_voltagesensor.js.html
Normal file
File diff suppressed because one or more lines are too long
@ -1,394 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
<title>node-poweredup Source: duplotrainbase.js</title>
|
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
|
|
||||||
<div class="container">
|
|
||||||
<div class="navbar-header">
|
|
||||||
<a class="navbar-brand" href="index.html">node-poweredup</a>
|
|
||||||
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="navbar-collapse collapse" id="topNavigation">
|
|
||||||
<ul class="nav navbar-nav">
|
|
||||||
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu ">
|
|
||||||
<li><a href="BoostMoveHub.html">BoostMoveHub</a></li><li><a href="DuploTrainBase.html">DuploTrainBase</a></li><li><a href="Hub.html">Hub</a></li><li><a href="LPF2Hub.html">LPF2Hub</a></li><li><a href="PoweredUP.html">PoweredUP</a></li><li><a href="PUPHub.html">PUPHub</a></li><li><a href="PUPRemote.html">PUPRemote</a></li><li><a href="WeDo2SmartHub.html">WeDo2SmartHub</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu ">
|
|
||||||
<li><a href="BoostMoveHub.html#event:attach">BoostMoveHub#event:attach</a></li><li><a href="BoostMoveHub.html#event:button">BoostMoveHub#event:button</a></li><li><a href="BoostMoveHub.html#event:color">BoostMoveHub#event:color</a></li><li><a href="BoostMoveHub.html#event:colorAndDistance">BoostMoveHub#event:colorAndDistance</a></li><li><a href="BoostMoveHub.html#event:detach">BoostMoveHub#event:detach</a></li><li><a href="BoostMoveHub.html#event:distance">BoostMoveHub#event:distance</a></li><li><a href="BoostMoveHub.html#event:rotate">BoostMoveHub#event:rotate</a></li><li><a href="BoostMoveHub.html#event:tilt">BoostMoveHub#event:tilt</a></li><li><a href="DuploTrainBase.html#event:color">DuploTrainBase#event:color</a></li><li><a href="DuploTrainBase.html#event:speed">DuploTrainBase#event:speed</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:detach">Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:attach">LPF2Hub#event:attach</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:color">LPF2Hub#event:color</a></li><li><a href="LPF2Hub.html#event:colorAndDistance">LPF2Hub#event:colorAndDistance</a></li><li><a href="LPF2Hub.html#event:detach">LPF2Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:distance">LPF2Hub#event:distance</a></li><li><a href="LPF2Hub.html#event:rotate">LPF2Hub#event:rotate</a></li><li><a href="LPF2Hub.html#event:speed">LPF2Hub#event:speed</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="PoweredUP.html#event:discover">PoweredUP#event:discover</a></li><li><a href="PUPHub.html#event:attach">PUPHub#event:attach</a></li><li><a href="PUPHub.html#event:button">PUPHub#event:button</a></li><li><a href="PUPHub.html#event:color">PUPHub#event:color</a></li><li><a href="PUPHub.html#event:colorAndDistance">PUPHub#event:colorAndDistance</a></li><li><a href="PUPHub.html#event:detach">PUPHub#event:detach</a></li><li><a href="PUPHub.html#event:distance">PUPHub#event:distance</a></li><li><a href="PUPHub.html#event:tilt">PUPHub#event:tilt</a></li><li><a href="PUPRemote.html#event:button">PUPRemote#event:button</a></li><li><a href="PUPRemote.html#event:colorAndDistance">PUPRemote#event:colorAndDistance</a></li><li><a href="WeDo2SmartHub.html#event:attach">WeDo2SmartHub#event:attach</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</a></li><li><a href="WeDo2SmartHub.html#event:color">WeDo2SmartHub#event:color</a></li><li><a href="WeDo2SmartHub.html#event:detach">WeDo2SmartHub#event:detach</a></li><li><a href="WeDo2SmartHub.html#event:distance">WeDo2SmartHub#event:distance</a></li><li><a href="WeDo2SmartHub.html#event:rotate">WeDo2SmartHub#event:rotate</a></li><li><a href="WeDo2SmartHub.html#event:tilt">WeDo2SmartHub#event:tilt</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu ">
|
|
||||||
<li><a href="global.html">Global</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="col-sm-3 col-md-3">
|
|
||||||
<form class="navbar-form" role="search">
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
|
|
||||||
<div class="input-group-btn">
|
|
||||||
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container" id="toc-content">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-12">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<h1 class="page-title">Source: duplotrainbase.js</h1>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<article>
|
|
||||||
<pre
|
|
||||||
class="sunlight-highlight-javascript linenums">"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const lpf2hub_1 = require("./lpf2hub");
|
|
||||||
const port_1 = require("./port");
|
|
||||||
const Consts = __importStar(require("./consts"));
|
|
||||||
const Debug = require("debug");
|
|
||||||
const debug = Debug("duplotrainbase");
|
|
||||||
/**
|
|
||||||
* The DuploTrainBase is emitted if the discovered device is a Duplo Train Base.
|
|
||||||
* @class DuploTrainBase
|
|
||||||
* @extends LPF2Hub
|
|
||||||
* @extends Hub
|
|
||||||
*/
|
|
||||||
class DuploTrainBase extends lpf2hub_1.LPF2Hub {
|
|
||||||
// We set JSDoc to ignore these events as a Duplo Train Base will never emit them.
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#distance
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#colorAndDistance
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#tilt
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#rotate
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#button
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#attach
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @event DuploTrainBase#detach
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
static IsDuploTrainBase(peripheral) {
|
|
||||||
return (peripheral.advertisement &&
|
|
||||||
peripheral.advertisement.serviceUuids &&
|
|
||||||
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID);
|
|
||||||
}
|
|
||||||
constructor(device, autoSubscribe = true) {
|
|
||||||
super(device, autoSubscribe);
|
|
||||||
this.type = Consts.HubType.DUPLO_TRAIN_HUB;
|
|
||||||
this._ports = {
|
|
||||||
"MOTOR": new port_1.Port("MOTOR", 0),
|
|
||||||
"COLOR": new port_1.Port("COLOR", 18),
|
|
||||||
"SPEEDOMETER": new port_1.Port("SPEEDOMETER", 19)
|
|
||||||
};
|
|
||||||
debug("Discovered Duplo Train Base");
|
|
||||||
}
|
|
||||||
connect() {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
debug("Connecting to Duplo Train Base");
|
|
||||||
await super.connect();
|
|
||||||
debug("Connect completed");
|
|
||||||
return resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the color of the LED on the train via a color value.
|
|
||||||
* @method DuploTrainBase#setLEDColor
|
|
||||||
* @param {Color} color
|
|
||||||
* @returns {Promise} Resolved upon successful issuance of command.
|
|
||||||
*/
|
|
||||||
setLEDColor(color) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (color === false) {
|
|
||||||
color = 0;
|
|
||||||
}
|
|
||||||
const data = Buffer.from([0x81, 0x11, 0x11, 0x51, 0x00, color]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the motor speed on a given port.
|
|
||||||
* @method DuploTrainBase#setMotorSpeed
|
|
||||||
* @param {string} port
|
|
||||||
* @param {number | Array.<number>} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
|
|
||||||
* @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
|
||||||
*/
|
|
||||||
setMotorSpeed(port, speed, time) {
|
|
||||||
const portObj = this._portLookup(port);
|
|
||||||
let cancelEventTimer = true;
|
|
||||||
if (typeof time === "boolean") {
|
|
||||||
if (time === true) {
|
|
||||||
cancelEventTimer = false;
|
|
||||||
}
|
|
||||||
time = undefined;
|
|
||||||
}
|
|
||||||
if (cancelEventTimer) {
|
|
||||||
portObj.cancelEventTimer();
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (time && typeof time === "number") {
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
const timeout = global.setTimeout(() => {
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
}, time);
|
|
||||||
portObj.setEventTimer(timeout);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Ramp the motor speed on a given port.
|
|
||||||
* @method DuploTrainBase#rampMotorSpeed
|
|
||||||
* @param {string} port
|
|
||||||
* @param {number} fromSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
||||||
* @param {number} toSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
||||||
* @param {number} time How long the ramp should last (in milliseconds).
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command.
|
|
||||||
*/
|
|
||||||
rampMotorSpeed(port, fromSpeed, toSpeed, time) {
|
|
||||||
const portObj = this._portLookup(port);
|
|
||||||
portObj.cancelEventTimer();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._calculateRamp(fromSpeed, toSpeed, time, portObj)
|
|
||||||
.on("changeSpeed", (speed) => {
|
|
||||||
this.setMotorSpeed(port, speed, true);
|
|
||||||
})
|
|
||||||
.on("finished", resolve);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Fully (hard) stop the motor on a given port.
|
|
||||||
* @method DuploTrainBase#brakeMotor
|
|
||||||
* @param {string} port
|
|
||||||
* @returns {Promise} Resolved upon successful completion of command.
|
|
||||||
*/
|
|
||||||
brakeMotor(port) {
|
|
||||||
return this.setMotorSpeed(port, 127);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Play a built-in train sound.
|
|
||||||
* @method DuploTrainBase#playSound
|
|
||||||
* @param {DuploTrainBaseSound} sound
|
|
||||||
* @returns {Promise} Resolved upon successful issuance of command.
|
|
||||||
*/
|
|
||||||
playSound(sound) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const data = Buffer.from([0x81, 0x01, 0x11, 0x51, 0x01, sound]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.DuploTrainBase = DuploTrainBase;
|
|
||||||
//# sourceMappingURL=duplotrainbase.js.map</pre>
|
|
||||||
</article>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="modal fade" id="searchResults">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<h4 class="modal-title">Search results</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body"></div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
||||||
</div>
|
|
||||||
</div><!-- /.modal-content -->
|
|
||||||
</div><!-- /.modal-dialog -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
|
|
||||||
|
|
||||||
<span class="copyright">
|
|
||||||
node-poweredup by Nathan Kellenicki licensed under the MIT license.
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="jsdoc-message">
|
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
|
|
||||||
|
|
||||||
on Wed Mar 20th 2019
|
|
||||||
|
|
||||||
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
|
|
||||||
</span>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script src="scripts/docstrap.lib.js"></script>
|
|
||||||
<script src="scripts/toc.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$( function () {
|
|
||||||
$( "[id*='$']" ).each( function () {
|
|
||||||
var $this = $( this );
|
|
||||||
|
|
||||||
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
|
|
||||||
var $this = $( this );
|
|
||||||
|
|
||||||
var example = $this.find( "code" );
|
|
||||||
exampleText = example.html();
|
|
||||||
var lang = /{@lang (.*?)}/.exec( exampleText );
|
|
||||||
if ( lang && lang[1] ) {
|
|
||||||
exampleText = exampleText.replace( lang[0], "" );
|
|
||||||
example.html( exampleText );
|
|
||||||
lang = lang[1];
|
|
||||||
} else {
|
|
||||||
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
|
|
||||||
lang = langClassMatch ? langClassMatch[1] : "javascript";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( lang ) {
|
|
||||||
|
|
||||||
$this
|
|
||||||
.addClass( "sunlight-highlight-" + lang )
|
|
||||||
.addClass( "linenums" )
|
|
||||||
.html( example.html() );
|
|
||||||
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
Sunlight.highlightAll( {
|
|
||||||
lineNumbers : true,
|
|
||||||
showMenu : true,
|
|
||||||
enableDoclinks : true
|
|
||||||
} );
|
|
||||||
|
|
||||||
$.catchAnchorLinks( {
|
|
||||||
navbarOffset: 10
|
|
||||||
} );
|
|
||||||
$( "#toc" ).toc( {
|
|
||||||
anchorName : function ( i, heading, prefix ) {
|
|
||||||
return $( heading ).attr( "id" ) || ( prefix + i );
|
|
||||||
},
|
|
||||||
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
|
|
||||||
showAndHide : false,
|
|
||||||
smoothScrolling: true
|
|
||||||
} );
|
|
||||||
|
|
||||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
|
||||||
$( '.dropdown-toggle' ).dropdown();
|
|
||||||
|
|
||||||
$( "table" ).each( function () {
|
|
||||||
var $this = $( this );
|
|
||||||
$this.addClass('table');
|
|
||||||
} );
|
|
||||||
|
|
||||||
} );
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Navigation and Symbol Display-->
|
|
||||||
|
|
||||||
|
|
||||||
<!--Google Analytics-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
SearcherDisplay.init();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
BIN
docs/fonts/OpenSans-Semibold-webfont.eot
Executable file
BIN
docs/fonts/OpenSans-Semibold-webfont.eot
Executable file
Binary file not shown.
1830
docs/fonts/OpenSans-Semibold-webfont.svg
Executable file
1830
docs/fonts/OpenSans-Semibold-webfont.svg
Executable file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 116 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user