diff --git a/README.md b/README.md index dbb1771..f642368 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,19 @@ # **node-poweredup** - A Javascript module to interface with LEGO Powered Up components. +### Announcements + +*Important*: v6.0.0 is a complete re-architecting of this library. Improvements include proper device and mode support through an external Device object, correct handling of firmware features, and promise-based functionality for interfacing with device attachments. Although many new features were added, existing code will almost surely break upon upgrade. + ### 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, LEGO Powered Up released in 2018, and LEGO Technic CONTROL+ released in 2019. 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 - starting with LEGO Education WeDo 2.0 released in 2016, LEGO Boost released in 2017, LEGO Powered Up released in 2018, LEGO Technic CONTROL+ released in 2019, and LEGO Education SPIKE Prime released in 2020. It also includes the 2018 Duplo App-Controlled Train sets. 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. ### Node.js Installation -Node.js v8.0 required. +Node.js v8.0+ required. ```javascript npm install node-poweredup --save @@ -19,7 +23,7 @@ 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. +Note: node-poweredup has been tested on macOS 10.15 and Debian/Raspbian on the Raspberry Pi 3 Model B. ### Compatibility @@ -36,6 +40,12 @@ While most Powered Up components and Hubs are compatible with each other, there | Powered Up LED Lights | 88005 | Light | Yes | Yes | Yes | Yes | 88005 | | Control+ Large Motor | 22169 | Motor/Sensor | *Partial* | No | Yes | Yes | 42099
42100 | | Control+ XLarge Motor | 22172 | Motor/Sensor | *Partial* | No | Yes | Yes | 42099
42100 | +| SPIKE Prime Medium Motor | 45678 | Motor/Sensor | *Partial* | Yes | Yes | Yes | 45678 | +| SPIKE Prime Large Motor | 45678 | Motor/Sensor | *Partial* | Yes | Yes | Yes | 45678 | +| SPIKE Prime Color Sensor | 45678 | Sensor | No | Yes | Yes | Yes | 45678 | +| SPIKE Prime Distance Sensor | 45678 | Sensor | No | Yes | Yes | Yes | 45678 | +| SPIKE Prime Force Sensor | 45678 | Sensor | No | Yes | Yes | Yes | 45678 | + In addition, the Hubs themselves have certain built-in features which this library exposes. @@ -50,11 +60,11 @@ In addition, the Hubs themselves have certain built-in features which this libra ### Known Issues and Limitations -* The Boost Color and Distance sensor only works in color mode with the WeDo 2.0 Smart Hub. +* 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 WeDo 2.0 Smart Hub, the Boost Tacho Motor and Control+ Motors do not support rotating the motor by angle. +* When used with the Boost Move Hub, the Control+ Motors do not currently accept commands (This is a known but which requires a firmware update from Lego to fix) -* When used with the Boost Move Hub, the Control+ Motors do not currently accept commands. +* The SPIKE Prime Hub does not use Bluetooth Low Energy, so is not supported via this library. It is recommended you use MicroPython and Bluetooth Classic to develop for this Hub. ### Documentation @@ -69,17 +79,22 @@ const poweredUP = new PoweredUP.PoweredUP(); poweredUP.on("discover", async (hub) => { // Wait to discover a Hub console.log(`Discovered ${hub.name}!`); 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"); - await hub.sleep(3000); // Sleep for 3 seconds before starting while (true) { // Repeat indefinitely - console.log("Running motor B at speed 75"); - hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely + console.log("Running motor B at speed 50"); + 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"); - 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 - console.log("Running motor A at speed -50 for 1 seconds"); - 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 + console.log("Running motor A at speed -30 for 1 second"); + 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 } }); diff --git a/docs/AbsoluteMotor.html b/docs/AbsoluteMotor.html new file mode 100644 index 0000000..8a0bab1 --- /dev/null +++ b/docs/AbsoluteMotor.html @@ -0,0 +1,1413 @@ + + + + + + + node-poweredup Class: AbsoluteMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: AbsoluteMotor

+
+ +
+ +

+ AbsoluteMotor +

+ + +
+ + +
+
+ + +
+
+

new AbsoluteMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

gotoAngle(angle [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given angle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
angle + + +number + + + + + + + + + + + + +

Absolute position the motor should go to (degrees from 0).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/BaseHub.html b/docs/BaseHub.html new file mode 100644 index 0000000..5ee6147 --- /dev/null +++ b/docs/BaseHub.html @@ -0,0 +1,1419 @@ + + + + + + + node-poweredup Class: BaseHub + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: BaseHub

+
+ +
+ +

+ BaseHub +

+ + +
+ + +
+
+ + +
+
+

new BaseHub()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + +
    +
  • EventEmitter
  • +
+ + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> batteryLevel

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
batteryLevel + + +number + + + + +

Battery level of the hub (Percentage between 0-100)

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> firmwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Firmware version of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hardwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> name

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Name of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> rssi

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rssi + + +number + + + + +

Signal strength of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> uuid

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
uuid + + +string + + + + +

UUID of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/BasicMotor.html b/docs/BasicMotor.html new file mode 100644 index 0000000..7409e88 --- /dev/null +++ b/docs/BasicMotor.html @@ -0,0 +1,1716 @@ + + + + + + + node-poweredup Class: BasicMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: BasicMotor

+
+ +
+ +

+ BasicMotor +

+ + +
+ + +
+
+ + +
+
+

new BasicMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

brake()

+ + +
+
+ + +
+

Brake the motor.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rampPower(fromPower, toPower, time)

+ + +
+
+ + +
+

Ramp the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fromPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time + + +number + + + + +

How long the ramp should last (in milliseconds).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setPower(power)

+ + +
+
+ + +
+

Set the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
power + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

stop()

+ + +
+
+ + +
+

Stop the motor.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index 0e3c54a..5209d0d 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -33,21 +33,14 @@ - - @@ -152,8 +145,8 @@
@@ -209,1375 +202,12 @@ -

Members

- -
- -
-
-

<readonly> batteryLevel

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
batteryLevel - - -number - - - - -

Battery level of the hub (Percentage between 0-100)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> firmwareVersion

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
firmwareVersion - - -string - - - - -

Firmware version of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> hardwareVersion

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
firmwareVersion - - -string - - - - -

Hardware version of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> name

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - -

Name of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> primaryMACAddress

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
primaryMACAddress - - -string - - - - -

Primary MAC address of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> rssi

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
rssi - - -number - - - - -

Signal strength of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> uuid

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
uuid - - -string - - - - -

UUID of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- -
-

Methods

-
-
-

brakeMotor(port)

- - -
-
- - -
-

Fully (hard) stop the motor on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - -

connect()

@@ -1648,8 +278,8 @@
@@ -1700,6 +330,202 @@ + + + + +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -1744,11 +570,6 @@ - -
Overrides:
-
@@ -1774,8 +595,8 @@
@@ -1832,7 +653,7 @@
-

getHubType()

+

getDeviceAtPort(portName)

@@ -1840,129 +661,7 @@
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - - - - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

+

Retrieves the device attached to a given port.

@@ -1997,7 +696,7 @@ - port + portName @@ -2014,7 +713,7 @@ - +

The name of the port to retrieve the device from.

@@ -2036,247 +735,12 @@
- -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -DeviceType - - - -
-
- - - - - - - - - -
-
-

rampMotorSpeed(port, fromSpeed, toSpeed, time)

- - -
-
- - -
-

Ramp the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
fromSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time - - -number - - - - -

How long the ramp should last (in milliseconds).

- - - - -
- - - - - - - - @@ -2302,8 +766,8 @@
@@ -2332,7 +796,7 @@
-

Resolved upon successful completion of command.

+

The device attached to the port.

@@ -2343,347 +807,43 @@
-Promise - - - -
-
- - - - - -
- - - -
-
-

resetAbsolutePosition(port)

- - -
-
- - -
-

Reset the current motor position as absolute position zero

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the motor is finished).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setAbsolutePosition(port, pos [, speed])

- - -
-
- - -
-

Tell motor to goto an absolute position

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - + - -
NameTypeArgumentDefaultDescription
port - - -string - - - - - - - - - - - - -
pos - - -number - - - - - - - - - - - - -

The position of the motor to go to

speed - - -number +Device | -Array.<number> +undefined - - - - <optional>
- - - - -
- - 100 - -

A value between 1 - 100 should be set (Direction does not apply when going to absolute position)

+
+ + +
+
+

getDevices()

+ + +
+
+ + +
+

Retrieves all attached devices.

+
+ + + + + + + @@ -2695,6 +855,15 @@ +
Inherited From:
+
+ +
+ @@ -2721,8 +890,8 @@
@@ -2751,7 +920,7 @@
-

Resolved upon successful completion of command (ie. once the motor is finished).

+

Array of all attached devices.

@@ -2762,7 +931,7 @@
-Promise +Array.<Device> @@ -2779,7 +948,7 @@
-

setLEDColor(color)

+

getDevicesByType(deviceType)

@@ -2787,7 +956,7 @@
-

Set the color of the LED on the Hub via a color value.

+

Retrieves an array of devices of the specified type.

@@ -2822,13 +991,13 @@ - color + deviceType -Color +number @@ -2839,7 +1008,7 @@ - +

The device type to lookup.

@@ -2861,7 +1030,7 @@
@@ -2892,8 +1061,8 @@
@@ -2922,7 +1091,7 @@
-

Resolved upon successful issuance of command.

+

Array of all devices of the specified type.

@@ -2933,962 +1102,7 @@
-Promise - - - -
- - - - - - - - - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLightBrightness(port, brightness [, time])

- - -
-
- - -
-

Set the light brightness on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
brightness - - -number - - - - - - - - - - -

Brightness value between 0-100 (0 is off)

time - - -number - - - - - - - <optional>
- - - - - -

How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the light is turned off.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorAngle(port, angle [, speed])

- - -
-
- - -
-

Rotate a motor by a given angle.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDefaultDescription
port - - -string - - - - - - - - - - - - -
angle - - -number - - - - - - - - - - - - -

How much the motor should be rotated (in degrees).

speed - - -number -| - -Array.<number> - - - - - - - <optional>
- - - - - -
- - 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.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the motor is finished).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorSpeed(port, speed [, time])

- - -
-
- - -
-

Set the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
speed - - -number -| - -Array.<number> - - - - - - - - - - -

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.

time - - -number - - - - - - - <optional>
- - - - - -

How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the motor is finished.

-
- - - -
-
- Type -
-
- -Promise +Array.<Device> @@ -4018,8 +1232,8 @@
@@ -4139,8 +1353,8 @@
@@ -4206,7 +1420,7 @@

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

+

Note: This is a helper method to make it easier to add delays into a chain of commands.

@@ -4286,11 +1500,6 @@
- -
Overrides:
-
@@ -4316,8 +1525,8 @@
@@ -4368,402 +1577,6 @@ - - - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -4779,7 +1592,7 @@

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

+

Note: This is a helper method to make it easier to wait for concurrent commands to complete.

@@ -4859,11 +1672,6 @@ - -
Overrides:
-
@@ -4889,8 +1697,8 @@
@@ -4943,19 +1751,11 @@ - - - - - - -

Events

- -
+
-

accel

+

waitForDeviceAtPort(portName)

@@ -4963,7 +1763,8 @@
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

+

Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -4998,7 +1799,7 @@ - port + portName @@ -5015,79 +1816,7 @@ - - - - - - - - x - - - - - -number - - - - - - - - - - - - - - - - - - y - - - - - -number - - - - - - - - - - - - - - - - - - z - - - - - -number - - - - - - - - - - - +

The name of the port to retrieve the device from.

@@ -5109,7 +1838,7 @@
@@ -5140,8 +1869,8 @@
@@ -5166,6 +1895,30 @@ +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + @@ -5174,7 +1927,7 @@
-

attach

+

waitForDeviceByType(deviceType)

@@ -5182,7 +1935,8 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -5217,13 +1971,13 @@ - port + deviceType -string +number @@ -5234,20 +1988,175 @@ - +

The device type to lookup.

+ + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + + + +
+ + + + + +

Events

+ +
+ +
+
+

attach

+ + +
+
+ + +
+

Emits when a device is attached to the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + - + - + - + + @@ -2036,247 +735,12 @@
- -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -DeviceType - - - -
-
- - - - - - - - - -
-
-

rampMotorSpeed(port, fromSpeed, toSpeed, time)

- - -
-
- - -
-

Ramp the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - -
NameTypeDescription
typedevice -DeviceType +Device @@ -5286,11 +2195,6 @@ - -
Overrides:
-
@@ -5316,8 +2220,8 @@
@@ -5423,7 +2327,7 @@
-ButtonState +ButtonState @@ -5487,374 +2391,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -5895,7 +2433,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -5930,13 +2468,13 @@
portdevice -string +Device @@ -5975,11 +2513,6 @@ - -
Overrides:
-
@@ -6005,8 +2538,8 @@
@@ -6039,7 +2572,7 @@
-

distance

+

disconnect

@@ -6047,7 +2580,7 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

@@ -6057,80 +2590,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- -
@@ -6145,7 +2604,7 @@
@@ -6176,740 +2635,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -6988,7 +2715,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/ColorDistanceSensor.html b/docs/ColorDistanceSensor.html new file mode 100644 index 0000000..7db693e --- /dev/null +++ b/docs/ColorDistanceSensor.html @@ -0,0 +1,1576 @@ + + + + + + + node-poweredup Class: ColorDistanceSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: ColorDistanceSensor

+
+ +
+ +

+ ColorDistanceSensor +

+ + +
+ + +
+
+ + +
+
+

new ColorDistanceSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

color

+ + +
+
+ + +
+

Emits when a color sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
color + + +Color + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

colorAndDistance

+ + +
+
+ + +
+

A combined color and distance event, emits when the sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
color + + +Color + + + + +
distance + + +number + + + + +

Distance, in millimeters.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

distance

+ + +
+
+ + +
+

Emits when a distance sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
distance + + +number + + + + +

Distance, in millimeters.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/ControlPlusHub.html b/docs/ControlPlusHub.html index e9847ee..8bb50a1 100644 --- a/docs/ControlPlusHub.html +++ b/docs/ControlPlusHub.html @@ -33,21 +33,14 @@ - - @@ -152,8 +145,8 @@
@@ -209,1375 +202,12 @@ -

Members

- -
- -
-
-

<readonly> batteryLevel

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
batteryLevel - - -number - - - - -

Battery level of the hub (Percentage between 0-100)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> firmwareVersion

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
firmwareVersion - - -string - - - - -

Firmware version of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> hardwareVersion

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
firmwareVersion - - -string - - - - -

Hardware version of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> name

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -string - - - - -

Name of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> primaryMACAddress

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
primaryMACAddress - - -string - - - - -

Primary MAC address of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> rssi

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
rssi - - -number - - - - -

Signal strength of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> uuid

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
uuid - - -string - - - - -

UUID of the hub

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - -
- -
-

Methods

-
-
-

brakeMotor(port)

- - -
-
- - -
-

Fully (hard) stop the motor on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - -

connect()

@@ -1648,8 +278,8 @@
@@ -1700,6 +330,202 @@ +
+ + + +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -1744,11 +570,6 @@ - -
Overrides:
-
@@ -1774,8 +595,8 @@
@@ -1832,7 +653,7 @@
-

getHubType()

+

getDeviceAtPort(portName)

@@ -1840,129 +661,7 @@
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - - - - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

+

Retrieves the device attached to a given port.

@@ -1997,7 +696,7 @@
portportName @@ -2014,7 +713,7 @@ -

The name of the port to retrieve the device from.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
fromSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time - - -number - - - - -

How long the ramp should last (in milliseconds).

- - - - -
- - - - - - - - @@ -2302,8 +766,8 @@
@@ -2332,7 +796,7 @@
-

Resolved upon successful completion of command.

+

The device attached to the port.

@@ -2343,347 +807,43 @@
-Promise - - - -
-
- - - - - -
- - - -
-
-

resetAbsolutePosition(port)

- - -
-
- - -
-

Reset the current motor position as absolute position zero

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the motor is finished).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setAbsolutePosition(port, pos [, speed])

- - -
-
- - -
-

Tell motor to goto an absolute position

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - + - -
NameTypeArgumentDefaultDescription
port - - -string - - - - - - - - - - - - -
pos - - -number - - - - - - - - - - - - -

The position of the motor to go to

speed - - -number +Device | -Array.<number> +undefined - - - - <optional>
- - - - -
- - 100 - -

A value between 1 - 100 should be set (Direction does not apply when going to absolute position)

+
+ + +
+
+

getDevices()

+ + +
+
+ + +
+

Retrieves all attached devices.

+
+ + + + + + + @@ -2695,6 +855,15 @@ +
Inherited From:
+
+ +
+ @@ -2721,8 +890,8 @@
@@ -2751,7 +920,7 @@
-

Resolved upon successful completion of command (ie. once the motor is finished).

+

Array of all attached devices.

@@ -2762,7 +931,7 @@
-Promise +Array.<Device> @@ -2779,7 +948,7 @@
-

setLEDColor(color)

+

getDevicesByType(deviceType)

@@ -2787,7 +956,7 @@
-

Set the color of the LED on the Hub via a color value.

+

Retrieves an array of devices of the specified type.

@@ -2822,13 +991,13 @@ - color + deviceType -Color +number @@ -2839,7 +1008,7 @@ - +

The device type to lookup.

@@ -2861,7 +1030,7 @@
@@ -2892,8 +1061,8 @@
@@ -2922,7 +1091,7 @@
-

Resolved upon successful issuance of command.

+

Array of all devices of the specified type.

@@ -2933,962 +1102,7 @@
-Promise - - - -
-
- - - - - - - - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLightBrightness(port, brightness [, time])

- - -
-
- - -
-

Set the light brightness on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
brightness - - -number - - - - - - - - - - -

Brightness value between 0-100 (0 is off)

time - - -number - - - - - - - <optional>
- - - - - -

How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the light is turned off.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorAngle(port, angle [, speed])

- - -
-
- - -
-

Rotate a motor by a given angle.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDefaultDescription
port - - -string - - - - - - - - - - - - -
angle - - -number - - - - - - - - - - - - -

How much the motor should be rotated (in degrees).

speed - - -number -| - -Array.<number> - - - - - - - <optional>
- - - - - -
- - 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.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the motor is finished).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorSpeed(port, speed [, time])

- - -
-
- - -
-

Set the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
speed - - -number -| - -Array.<number> - - - - - - - - - - -

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.

time - - -number - - - - - - - <optional>
- - - - - -

How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the motor is finished.

-
- - - -
-
- Type -
-
- -Promise +Array.<Device> @@ -4018,8 +1232,8 @@
@@ -4139,8 +1353,8 @@
@@ -4206,7 +1420,7 @@

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

+

Note: This is a helper method to make it easier to add delays into a chain of commands.

@@ -4286,11 +1500,6 @@
- -
Overrides:
-
@@ -4316,8 +1525,8 @@
@@ -4368,402 +1577,6 @@ - - - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -4779,7 +1592,7 @@

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

+

Note: This is a helper method to make it easier to wait for concurrent commands to complete.

@@ -4859,11 +1672,6 @@ - -
Overrides:
-
@@ -4889,8 +1697,8 @@
@@ -4943,19 +1751,11 @@ - - - - - - -

Events

- -
+
-

accel

+

waitForDeviceAtPort(portName)

@@ -4963,7 +1763,8 @@
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

+

Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -4998,7 +1799,7 @@ - port + portName @@ -5015,79 +1816,7 @@ - - - - - - - - x - - - - - -number - - - - - - - - - - - - - - - - - - y - - - - - -number - - - - - - - - - - - - - - - - - - z - - - - - -number - - - - - - - - - - - +

The name of the port to retrieve the device from.

@@ -5109,7 +1838,7 @@
@@ -5140,8 +1869,8 @@
@@ -5166,6 +1895,30 @@ +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + @@ -5174,7 +1927,7 @@
-

attach

+

waitForDeviceByType(deviceType)

@@ -5182,7 +1935,8 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -5217,13 +1971,13 @@ - port + deviceType -string +number @@ -5234,20 +1988,175 @@ - +

The device type to lookup.

+ + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + + + +
+ + + + + +

Events

+ +
+ +
+
+

attach

+ + +
+
+ + +
+

Emits when a device is attached to the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + - + - + - + - + + - -
NameTypeDescription
typedevice -DeviceType +Device @@ -5286,11 +2195,6 @@ - -
Overrides:
-
@@ -5316,8 +2220,8 @@
@@ -5423,7 +2327,7 @@
-ButtonState +ButtonState @@ -5487,374 +2391,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -5895,7 +2433,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -5930,13 +2468,13 @@
portdevice -string +Device @@ -5975,11 +2513,6 @@ - -
Overrides:
-
@@ -6005,8 +2538,8 @@
@@ -6039,7 +2572,7 @@
-

distance

+

disconnect

@@ -6047,7 +2580,7 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

@@ -6057,80 +2590,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- -
@@ -6145,7 +2604,7 @@
@@ -6176,740 +2635,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -6988,7 +2715,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/CurrentSensor.html b/docs/CurrentSensor.html new file mode 100644 index 0000000..c4137ad --- /dev/null +++ b/docs/CurrentSensor.html @@ -0,0 +1,1264 @@ + + + + + + + node-poweredup Class: CurrentSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: CurrentSensor

+
+ +
+ +

+ CurrentSensor +

+ + +
+ + +
+
+ + +
+
+

new CurrentSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

current

+ + +
+
+ + +
+

Emits when a current change is detected.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
current + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Device.html b/docs/Device.html new file mode 100644 index 0000000..9c0aea0 --- /dev/null +++ b/docs/Device.html @@ -0,0 +1,1062 @@ + + + + + + + node-poweredup Class: Device + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: Device

+
+ +
+ +

+ Device +

+ + +
+ + +
+
+ + +
+
+

new Device()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + +
    +
  • EventEmitter
  • +
+ + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 0a9860c..29b8e30 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -33,21 +33,14 @@ - - @@ -152,8 +145,8 @@
@@ -194,7 +187,7 @@ @@ -290,17 +283,12 @@
- -
Overrides:
-
@@ -326,141 +314,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -556,17 +411,12 @@
- -
Overrides:
-
@@ -592,8 +442,8 @@
@@ -653,7 +503,7 @@
firmwareVersionhardwareVersion @@ -689,17 +539,12 @@
- -
Overrides:
-
@@ -725,8 +570,8 @@
@@ -822,17 +667,12 @@
- -
Overrides:
-
@@ -858,8 +698,136 @@
+
+ + + + + + + + + + + + + + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -955,17 +923,12 @@
- -
Overrides:
-
@@ -991,8 +954,8 @@
@@ -1088,17 +1051,12 @@
- -
Overrides:
-
@@ -1124,8 +1082,136 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -1221,17 +1307,12 @@
- -
Overrides:
-
@@ -1257,141 +1338,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -1418,7 +1366,7 @@
-

brakeMotor(port)

+

createVirtualPort(firstPortName, secondPortName)

@@ -1426,7 +1374,8 @@
-

Fully (hard) stop the motor on a given port.

+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

@@ -1461,7 +1410,7 @@
portfirstPortName @@ -1478,526 +1427,14 @@ -

First port name

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

connect()

- - -
-
- - -
-

Connect to the Hub.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful connect.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

disconnect()

- - -
-
- - -
-

Disconnect the Hub.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful disconnect.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

getHubType()

- - -
-
- - -
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - -
- - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - + + @@ -2036,175 +1473,12 @@
- -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -DeviceType - - - -
-
- - - - - - - - - -
-
-

playSound(sound)

- - -
-
- - -
-

Play a built-in train sound.

-
- - - - - - - - -
Parameters:
- - -
NameTypeDescription
portsecondPortName @@ -2014,7 +1451,7 @@ -

Second port name

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sound - - -DuploTrainBaseSound - - - - -
- - - - -
- - - - - - - - @@ -2230,8 +1504,8 @@
@@ -2282,871 +1556,6 @@ -
- - - -
-
-

rampMotorSpeed(port, fromSpeed, toSpeed, time)

- - -
-
- - -
-

Ramp the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
fromSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time - - -number - - - - -

How long the ramp should last (in milliseconds).

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLEDColor(color)

- - -
-
- - -
-

Set the color of the LED on the Hub via a color value.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorSpeed(port, speed [, time])

- - -
-
- - -
-

Set the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
speed - - -number -| - -Array.<number> - - - - - - - - - - -

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.

time - - -number - - - - - - - <optional>
- - - - - -

How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the motor is finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -3266,8 +1675,8 @@
@@ -3387,8 +1796,8 @@
@@ -3439,756 +1848,6 @@ - - - - -
-
-

sleep(delay)

- - -
-
- - -
-

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
delay - - -number - - - - -

How long to sleep (in milliseconds).

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved after the delay is finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

wait(commands)

- - -
-
- - -
-

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
commands - - -Array.<Promise.<any>> - - - - -

Array of executing commands.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved after the commands are finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -4201,401 +1860,6 @@
-
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - -

button

@@ -4671,7 +1935,7 @@ -ButtonState +ButtonState @@ -4735,1429 +1999,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

distance

- - -
-
- - -
-

Emits when a distance sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -6236,7 +2079,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/DuploTrainBaseColorSensor.html b/docs/DuploTrainBaseColorSensor.html new file mode 100644 index 0000000..ac04757 --- /dev/null +++ b/docs/DuploTrainBaseColorSensor.html @@ -0,0 +1,1600 @@ + + + + + + + node-poweredup Class: DuploTrainBaseColorSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: DuploTrainBaseColorSensor

+
+ +
+ +

+ DuploTrainBaseColorSensor +

+ + +
+ + +
+
+ + +
+
+

new DuploTrainBaseColorSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

color

+ + +
+
+ + +
+

Emits when a color sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
color + + +Color + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

reflect

+ + +
+
+ + +
+

Emits when the light reflectivity changes.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
reflect + + +number + + + + +

Percentage, from 0 to 100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rgb

+ + +
+
+ + +
+

Emits when the light reflectivity changes.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
red + + +number + + + + +
green + + +number + + + + +
blue + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/DuploTrainBaseMotor.html b/docs/DuploTrainBaseMotor.html new file mode 100644 index 0000000..766d5b4 --- /dev/null +++ b/docs/DuploTrainBaseMotor.html @@ -0,0 +1,1752 @@ + + + + + + + node-poweredup Class: DuploTrainBaseMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: DuploTrainBaseMotor

+
+ +
+ +

+ DuploTrainBaseMotor +

+ + +
+ + +
+
+ + +
+
+

new DuploTrainBaseMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

brake()

+ + +
+
+ + +
+

Brake the motor.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rampPower(fromPower, toPower, time)

+ + +
+
+ + +
+

Ramp the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fromPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time + + +number + + + + +

How long the ramp should last (in milliseconds).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setPower(power)

+ + +
+
+ + +
+

Set the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
power + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

stop()

+ + +
+
+ + +
+

Stop the motor.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/DuploTrainBaseSpeaker.html b/docs/DuploTrainBaseSpeaker.html new file mode 100644 index 0000000..b899c44 --- /dev/null +++ b/docs/DuploTrainBaseSpeaker.html @@ -0,0 +1,1444 @@ + + + + + + + node-poweredup Class: DuploTrainBaseSpeaker + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: DuploTrainBaseSpeaker

+
+ +
+ +

+ DuploTrainBaseSpeaker +

+ + +
+ + +
+
+ + +
+
+

new DuploTrainBaseSpeaker()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

playSound(sound)

+ + +
+
+ + +
+

Play a built-in train sound.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sound + + +DuploTrainBaseSound + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

playTone(tone)

+ + +
+
+ + +
+

Play a built-in system tone.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tone + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/DuploTraniBaseSpeedometer.html b/docs/DuploTraniBaseSpeedometer.html new file mode 100644 index 0000000..edb6c29 --- /dev/null +++ b/docs/DuploTraniBaseSpeedometer.html @@ -0,0 +1,1116 @@ + + + + + + + node-poweredup Class: DuploTraniBaseSpeedometer + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: DuploTraniBaseSpeedometer

+
+ +
+ +

+ DuploTraniBaseSpeedometer +

+ + +
+ + +
+
+ + +
+
+

new DuploTraniBaseSpeedometer()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Hub.html b/docs/Hub.html index 06dfa3c..568eaa6 100644 --- a/docs/Hub.html +++ b/docs/Hub.html @@ -33,21 +33,14 @@ - - @@ -105,6 +98,10 @@
+
+

The Hub is emitted if the discovered device is a Hub.

+
+ @@ -148,8 +145,8 @@
@@ -188,7 +185,9 @@ @@ -280,126 +279,16 @@ - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
+
Inherited From:
+
- - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - - @@ -425,8 +314,8 @@
@@ -518,6 +407,15 @@ +
Inherited From:
+
+ +
+ @@ -544,8 +442,8 @@
@@ -605,7 +503,7 @@ - firmwareVersion + hardwareVersion @@ -637,6 +535,15 @@ +
Inherited From:
+
+ +
+ @@ -663,8 +570,8 @@
@@ -756,6 +663,15 @@ +
Inherited From:
+
+ +
+ @@ -782,8 +698,136 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -875,6 +919,15 @@ +
Inherited From:
+
+ +
+ @@ -901,8 +954,8 @@
@@ -994,6 +1047,15 @@ +
Inherited From:
+
+ +
+ @@ -1020,8 +1082,136 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -1113,126 +1303,16 @@ - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
+
Inherited From:
+
- - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - - @@ -1258,8 +1338,8 @@
@@ -1340,8 +1420,8 @@
@@ -1392,6 +1472,202 @@ +
+ + + +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -1452,8 +1728,8 @@
@@ -1510,7 +1786,7 @@
-

getHubType()

+

getDeviceAtPort(portName)

@@ -1518,115 +1794,7 @@
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - - - - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

+

Retrieves the device attached to a given port.

@@ -1661,7 +1829,7 @@ - port + portName @@ -1678,7 +1846,7 @@ - +

The name of the port to retrieve the device from.

@@ -1722,8 +1890,8 @@
@@ -1751,6 +1919,10 @@
Returns:
+
+

The device attached to the port.

+
+
@@ -1759,7 +1931,576 @@
-DeviceType +Device +| + +undefined + + + +
+
+ + + + + + + + + +
+
+

getDevices()

+ + +
+
+ + +
+

Retrieves all attached devices.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Array of all attached devices.

+
+ + + +
+
+ Type +
+
+ +Array.<Device> + + + +
+
+ + + + + +
+ + + +
+
+

getDevicesByType(deviceType)

+ + +
+
+ + +
+

Retrieves an array of devices of the specified type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
deviceType + + +number + + + + +

The device type to lookup.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Array of all devices of the specified type.

+
+ + + +
+
+ Type +
+
+ +Array.<Device> + + + +
+
+ + + + + +
+ + + +
+
+

setName(name)

+ + +
+
+ + +
+

Set the name of the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

New name of the hub (14 characters or less, ASCII only).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

shutdown()

+ + +
+
+ + +
+

Shutdown the Hub.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful disconnect.

+
+ + + +
+
+ Type +
+
+ +Promise @@ -1785,7 +2526,7 @@

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

+

Note: This is a helper method to make it easier to add delays into a chain of commands.

@@ -1881,8 +2622,8 @@
@@ -1933,374 +2674,6 @@ -
- - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -2316,7 +2689,7 @@

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

+

Note: This is a helper method to make it easier to wait for concurrent commands to complete.

@@ -2412,8 +2785,8 @@
@@ -2466,19 +2839,11 @@ - - - - - - -

Events

- -
+
-

attach

+

waitForDeviceAtPort(portName)

@@ -2486,7 +2851,8 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -2521,7 +2887,7 @@ - port + portName @@ -2538,20 +2904,329 @@ - +

The name of the port to retrieve the device from.

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + + + + + +
+
+

waitForDeviceByType(deviceType)

+ + +
+
+ + +
+

Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + +
NameTypeDescription
typedeviceType -DeviceType +number + + + + +

The device type to lookup.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

attach

+ + +
+
+ + +
+

Emits when a device is attached to the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + - -
NameTypeDescription
device + + +Device @@ -2606,8 +3281,179 @@
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -2648,7 +3494,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -2683,13 +3529,13 @@
portdevice -string +Device @@ -2744,8 +3590,96 @@
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

disconnect

+ + +
+
+ + +
+

Emits when the hub is disconnected.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -2824,7 +3758,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/HubLED.html b/docs/HubLED.html new file mode 100644 index 0000000..76ae88f --- /dev/null +++ b/docs/HubLED.html @@ -0,0 +1,1492 @@ + + + + + + + node-poweredup Class: HubLED + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: HubLED

+
+ +
+ +

+ HubLED +

+ + +
+ + +
+
+ + +
+
+

new HubLED()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

setColor(color)

+ + +
+
+ + +
+

Set the color of the LED on the Hub via a color value.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
color + + +Color + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setRGB(red, green, blue)

+ + +
+
+ + +
+

Set the color of the LED on the Hub via RGB values.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
red + + +number + + + + +
green + + +number + + + + +
blue + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index dfcf835..fdff9e3 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -33,21 +33,14 @@ - - @@ -148,8 +141,8 @@
@@ -188,7 +181,7 @@ @@ -284,7 +277,7 @@
@@ -315,136 +308,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -540,7 +405,7 @@
@@ -571,8 +436,8 @@
@@ -632,7 +497,7 @@
firmwareVersionhardwareVersion @@ -668,7 +533,7 @@
@@ -699,8 +564,8 @@
@@ -796,7 +661,7 @@
@@ -827,8 +692,136 @@
+
+ + + + + + + + + + + + + + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -924,7 +917,7 @@
@@ -955,8 +948,8 @@
@@ -1052,7 +1045,7 @@
@@ -1083,8 +1076,136 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -1180,7 +1301,7 @@
@@ -1211,136 +1332,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -1367,7 +1360,7 @@
-

connect()

+

createVirtualPort(firstPortName, secondPortName)

@@ -1375,371 +1368,8 @@
-

Connect to the Hub.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful connect.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

disconnect()

- - -
-
- - -
-

Disconnect the Hub.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful disconnect.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

getHubType()

- - -
-
- - -
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - -
- - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

@@ -1774,7 +1404,7 @@
portfirstPortName @@ -1791,163 +1421,20 @@ -

First port name

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -DeviceType - - - -
-
- - - - - -
- - - -
-
-

setLEDColor(color)

- - -
-
- - -
-

Set the color of the LED on the Hub via a color value.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - + + @@ -2002,218 +1489,8 @@
-
- - - - - - - - - - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - - - - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - -
NameTypeDescription
colorsecondPortName -Color +string @@ -1958,7 +1445,7 @@ -

Second port name

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -2374,8 +1651,8 @@
@@ -2486,8 +1763,8 @@
@@ -2538,736 +1815,6 @@ -
- - - -
-
-

sleep(delay)

- - -
-
- - -
-

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
delay - - -number - - - - -

How long to sleep (in milliseconds).

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved after the delay is finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

wait(commands)

- - -
-
- - -
-

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
commands - - -Array.<Promise.<any>> - - - - -

Array of executing commands.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved after the commands are finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -3280,387 +1827,6 @@
-
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - -

button

@@ -3736,7 +1902,7 @@ -ButtonState +ButtonState @@ -3791,1361 +1957,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

distance

- - -
-
- - -
-

Emits when a distance sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -5224,7 +2037,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/Light.html b/docs/Light.html new file mode 100644 index 0000000..7882395 --- /dev/null +++ b/docs/Light.html @@ -0,0 +1,1492 @@ + + + + + + + node-poweredup Class: Light + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: Light

+
+ +
+ +

+ Light +

+ + +
+ + +
+
+ + +
+
+

new Light()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

rampBrightness(fromBrightness, toBrightness, time)

+ + +
+
+ + +
+

Ramp the light brightness.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fromBrightness + + +number + + + + +

Brightness value between 0-100 (0 is off)

toBrightness + + +number + + + + +

Brightness value between 0-100 (0 is off)

time + + +number + + + + +

How long the ramp should last (in milliseconds).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrightness(brightness)

+ + +
+
+ + +
+

Set the light brightness.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
brightness + + +number + + + + +

Brightness value between 0-100 (0 is off)

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/MediumLinearMotor.html b/docs/MediumLinearMotor.html new file mode 100644 index 0000000..6abfde9 --- /dev/null +++ b/docs/MediumLinearMotor.html @@ -0,0 +1,1051 @@ + + + + + + + node-poweredup Class: MediumLinearMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: MediumLinearMotor

+
+ +
+ +

+ MediumLinearMotor +

+ + +
+ + +
+
+ + +
+
+

new MediumLinearMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/MotionSensor.html b/docs/MotionSensor.html new file mode 100644 index 0000000..fee58b9 --- /dev/null +++ b/docs/MotionSensor.html @@ -0,0 +1,1264 @@ + + + + + + + node-poweredup Class: MotionSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: MotionSensor

+
+ +
+ +

+ MotionSensor +

+ + +
+ + +
+
+ + +
+
+

new MotionSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

distance

+ + +
+
+ + +
+

Emits when a distance sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
distance + + +number + + + + +

Distance, in millimeters.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/MoveHub.html b/docs/MoveHub.html new file mode 100644 index 0000000..b6be234 --- /dev/null +++ b/docs/MoveHub.html @@ -0,0 +1,2218 @@ + + + + + + + node-poweredup Class: MoveHub + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: MoveHub

+
+ +
+ +

+ MoveHub +

+ + +
+ + +
+
+ + +
+
+

new MoveHub()

+ + +
+
+ + +
+

The MoveHub is emitted if the discovered device is a Move Hub.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> batteryLevel

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
batteryLevel + + +number + + + + +

Battery level of the hub (Percentage between 0-100)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> firmwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Firmware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hardwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> name

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Name of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> rssi

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rssi + + +number + + + + +

Signal strength of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> uuid

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
uuid + + +string + + + + +

UUID of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setName(name)

+ + +
+
+ + +
+

Set the name of the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

New name of the hub (14 characters or less, ASCII only).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

shutdown()

+ + +
+
+ + +
+

Shutdown the Hub.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful disconnect.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/MoveHubMediumLinearMotor.html b/docs/MoveHubMediumLinearMotor.html new file mode 100644 index 0000000..8cfbf68 --- /dev/null +++ b/docs/MoveHubMediumLinearMotor.html @@ -0,0 +1,1051 @@ + + + + + + + node-poweredup Class: MoveHubMediumLinearMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: MoveHubMediumLinearMotor

+
+ +
+ +

+ MoveHubMediumLinearMotor +

+ + +
+ + +
+
+ + +
+
+

new MoveHubMediumLinearMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/MoveHubTiltSensor.html b/docs/MoveHubTiltSensor.html new file mode 100644 index 0000000..ea3e9d2 --- /dev/null +++ b/docs/MoveHubTiltSensor.html @@ -0,0 +1,1288 @@ + + + + + + + node-poweredup Class: MoveHubTiltSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: MoveHubTiltSensor

+
+ +
+ +

+ MoveHubTiltSensor +

+ + +
+ + +
+
+ + +
+
+

new MoveHubTiltSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

tilt

+ + +
+
+ + +
+

Emits when a tilt sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/PUPHub.html b/docs/PUPHub.html index bda0f11..21f0117 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -33,21 +33,14 @@ - - @@ -152,8 +145,8 @@
@@ -290,7 +283,7 @@
@@ -326,141 +319,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -556,7 +416,7 @@
@@ -592,8 +452,8 @@
@@ -653,7 +513,7 @@ - firmwareVersion + hardwareVersion @@ -689,7 +549,7 @@
@@ -725,8 +585,8 @@
@@ -822,7 +682,7 @@
@@ -858,8 +718,141 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -955,7 +948,7 @@
@@ -991,8 +984,8 @@
@@ -1088,7 +1081,7 @@
@@ -1124,8 +1117,141 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -1221,7 +1347,7 @@
@@ -1257,141 +1383,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -1416,168 +1409,6 @@
-
-
-

brakeMotor(port)

- - -
-
- - -
-

Fully (hard) stop the motor on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - -

connect()

@@ -1648,8 +1479,8 @@
@@ -1700,6 +1531,207 @@ +
+ + + +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -1744,11 +1776,6 @@ - -
Overrides:
-
@@ -1774,8 +1801,8 @@
@@ -1832,7 +1859,7 @@
-

getHubType()

+

getDeviceAtPort(portName)

@@ -1840,129 +1867,7 @@
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - - - - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

+

Retrieves the device attached to a given port.

@@ -1997,7 +1902,7 @@ - port + portName @@ -2014,7 +1919,7 @@ - +

The name of the port to retrieve the device from.

@@ -2036,247 +1941,12 @@
- -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -DeviceType - - - -
-
- - - - - - - - - -
-
-

rampMotorSpeed(port, fromSpeed, toSpeed, time)

- - -
-
- - -
-

Ramp the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
fromSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time - - -number - - - - -

How long the ramp should last (in milliseconds).

- - - - -
- - - - - - - - @@ -2302,8 +1972,8 @@
@@ -2332,7 +2002,7 @@
-

Resolved upon successful completion of command.

+

The device attached to the port.

@@ -2343,347 +2013,43 @@
-Promise - - - -
-
- - - - - -
- - - -
-
-

resetAbsolutePosition(port)

- - -
-
- - -
-

Reset the current motor position as absolute position zero

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the motor is finished).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setAbsolutePosition(port, pos [, speed])

- - -
-
- - -
-

Tell motor to goto an absolute position

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - + - -
NameTypeArgumentDefaultDescription
port - - -string - - - - - - - - - - - - -
pos - - -number - - - - - - - - - - - - -

The position of the motor to go to

speed - - -number +Device | -Array.<number> +undefined - - - - <optional>
- - - - -
- - 100 - -

A value between 1 - 100 should be set (Direction does not apply when going to absolute position)

+
+ + +
+
+

getDevices()

+ + +
+
+ + +
+

Retrieves all attached devices.

+
+ + + + + + + @@ -2695,6 +2061,15 @@ +
Inherited From:
+
+ +
+ @@ -2721,8 +2096,8 @@
@@ -2751,7 +2126,7 @@
-

Resolved upon successful completion of command (ie. once the motor is finished).

+

Array of all attached devices.

@@ -2762,7 +2137,7 @@
-Promise +Array.<Device> @@ -2779,7 +2154,7 @@
-

setLEDColor(color)

+

getDevicesByType(deviceType)

@@ -2787,7 +2162,7 @@
-

Set the color of the LED on the Hub via a color value.

+

Retrieves an array of devices of the specified type.

@@ -2822,13 +2197,13 @@ - color + deviceType -Color +number @@ -2839,7 +2214,7 @@ - +

The device type to lookup.

@@ -2861,7 +2236,7 @@
@@ -2892,8 +2267,8 @@
@@ -2922,7 +2297,7 @@
-

Resolved upon successful issuance of command.

+

Array of all devices of the specified type.

@@ -2933,962 +2308,7 @@
-Promise - - - -
- - - - - - - - - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLightBrightness(port, brightness [, time])

- - -
-
- - -
-

Set the light brightness on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
brightness - - -number - - - - - - - - - - -

Brightness value between 0-100 (0 is off)

time - - -number - - - - - - - <optional>
- - - - - -

How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the light is turned off.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorAngle(port, angle [, speed])

- - -
-
- - -
-

Rotate a motor by a given angle.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDefaultDescription
port - - -string - - - - - - - - - - - - -
angle - - -number - - - - - - - - - - - - -

How much the motor should be rotated (in degrees).

speed - - -number -| - -Array.<number> - - - - - - - <optional>
- - - - - -
- - 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.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the motor is finished).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorSpeed(port, speed [, time])

- - -
-
- - -
-

Set the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
speed - - -number -| - -Array.<number> - - - - - - - - - - -

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.

time - - -number - - - - - - - <optional>
- - - - - -

How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the motor is finished.

-
- - - -
-
- Type -
-
- -Promise +Array.<Device> @@ -3993,6 +2413,11 @@
+ +
Overrides:
+
@@ -4018,8 +2443,8 @@
@@ -4114,6 +2539,11 @@
+ +
Overrides:
+
@@ -4139,8 +2569,8 @@
@@ -4206,7 +2636,7 @@

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

+

Note: This is a helper method to make it easier to add delays into a chain of commands.

@@ -4286,11 +2716,6 @@ - -
Overrides:
-
@@ -4316,8 +2741,8 @@
@@ -4368,402 +2793,6 @@ - - - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -4779,7 +2808,7 @@

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

+

Note: This is a helper method to make it easier to wait for concurrent commands to complete.

@@ -4859,11 +2888,6 @@ - -
Overrides:
-
@@ -4889,8 +2913,8 @@
@@ -4943,19 +2967,11 @@ - - - - - - -

Events

- -
+
-

accel

+

waitForDeviceAtPort(portName)

@@ -4963,7 +2979,8 @@
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

+

Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -4998,7 +3015,7 @@ - port + portName @@ -5015,79 +3032,7 @@ - - - - - - - - x - - - - - -number - - - - - - - - - - - - - - - - - - y - - - - - -number - - - - - - - - - - - - - - - - - - z - - - - - -number - - - - - - - - - - - +

The name of the port to retrieve the device from.

@@ -5109,7 +3054,7 @@
@@ -5140,8 +3085,8 @@
@@ -5166,6 +3111,30 @@ +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + @@ -5174,7 +3143,7 @@
-

attach

+

waitForDeviceByType(deviceType)

@@ -5182,7 +3151,8 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -5217,13 +3187,13 @@ - port + deviceType -string +number @@ -5234,20 +3204,175 @@ - +

The device type to lookup.

+ + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + + + +
+ + + + + +

Events

+ +
+ +
+
+

attach

+ + +
+
+ + +
+

Emits when a device is attached to the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + - + - + - + - + + @@ -1874,17 +1941,12 @@
- -
Overrides:
-
@@ -1910,8 +1972,8 @@
@@ -1939,6 +2001,10 @@
Returns:
+
+

The device attached to the port.

+
+
@@ -1947,7 +2013,10 @@
-DeviceType +Device +| + +undefined @@ -1964,7 +2033,7 @@
-

setLEDColor(color)

+

getDevices()

@@ -1972,7 +2041,128 @@
-

Set the color of the LED on the Hub via a color value.

+

Retrieves all attached devices.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Array of all attached devices.

+
+ + + +
+
+ Type +
+
+ +Array.<Device> + + + +
+
+ + + + + + + + + +
+
+

getDevicesByType(deviceType)

+ + +
+
+ + +
+

Retrieves an array of devices of the specified type.

@@ -2007,13 +2197,13 @@
- + + @@ -2046,7 +2236,7 @@
@@ -2077,8 +2267,8 @@
@@ -2107,7 +2297,7 @@
-

Resolved upon successful issuance of command.

+

Array of all devices of the specified type.

@@ -2118,226 +2308,7 @@
-Promise - - - -
- - - - - - - - - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - -
NameTypeDescription
typedevice -DeviceType +Device @@ -5286,11 +3411,6 @@ - -
Overrides:
-
@@ -5316,8 +3436,8 @@
@@ -5423,7 +3543,7 @@
-ButtonState +ButtonState @@ -5463,176 +3583,10 @@ - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - +
Overrides:
+
@@ -5658,203 +3612,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -5895,7 +3654,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -5930,13 +3689,13 @@
portdevice -string +Device @@ -5975,11 +3734,6 @@ - -
Overrides:
-
@@ -6005,8 +3759,8 @@
@@ -6039,7 +3793,7 @@
-

distance

+

disconnect

@@ -6047,7 +3801,7 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

@@ -6057,80 +3811,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- -
@@ -6145,7 +3825,7 @@
@@ -6176,740 +3856,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -6988,7 +3936,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index 071196f..290051c 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -33,21 +33,14 @@ - - @@ -152,8 +145,8 @@
@@ -290,7 +283,7 @@
@@ -326,141 +319,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -556,7 +416,7 @@
@@ -592,8 +452,8 @@
@@ -653,7 +513,7 @@
firmwareVersionhardwareVersion @@ -689,7 +549,7 @@
@@ -725,8 +585,8 @@
@@ -822,7 +682,7 @@
@@ -858,8 +718,141 @@
+
+ + + + + + + + + + + + + + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -955,7 +948,7 @@
@@ -991,8 +984,8 @@
@@ -1088,7 +1081,7 @@
@@ -1124,8 +1117,141 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -1221,7 +1347,7 @@
@@ -1257,141 +1383,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -1486,8 +1479,8 @@
@@ -1538,6 +1531,207 @@ +
+ + + +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -1582,11 +1776,6 @@ - -
Overrides:
-
@@ -1612,8 +1801,8 @@
@@ -1670,7 +1859,7 @@
-

getHubType()

+

getDeviceAtPort(portName)

@@ -1678,129 +1867,7 @@
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - - - - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

+

Retrieves the device attached to a given port.

@@ -1835,7 +1902,7 @@
portportName @@ -1852,7 +1919,7 @@ -

The name of the port to retrieve the device from.

colordeviceType -Color +number @@ -2024,7 +2214,7 @@ -

The device type to lookup.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise +Array.<Device> @@ -2442,6 +2413,11 @@
+ +
Overrides:
+
@@ -2467,8 +2443,8 @@
@@ -2563,6 +2539,11 @@
+ +
Overrides:
+
@@ -2588,8 +2569,8 @@
@@ -2655,7 +2636,7 @@

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

+

Note: This is a helper method to make it easier to add delays into a chain of commands.

@@ -2735,11 +2716,6 @@ - -
Overrides:
-
@@ -2765,8 +2741,8 @@
@@ -2817,402 +2793,6 @@ - - - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -3228,7 +2808,7 @@

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

+

Note: This is a helper method to make it easier to wait for concurrent commands to complete.

@@ -3308,11 +2888,6 @@ - -
Overrides:
-
@@ -3338,8 +2913,8 @@
@@ -3392,19 +2967,11 @@ -
- - - - - -

Events

- -
+
-

accel

+

waitForDeviceAtPort(portName)

@@ -3412,7 +2979,8 @@
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

+

Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -3447,7 +3015,7 @@ - port + portName @@ -3464,79 +3032,7 @@ - - - - - - - - x - - - - - -number - - - - - - - - - - - - - - - - - - y - - - - - -number - - - - - - - - - - - - - - - - - - z - - - - - -number - - - - - - - - - - - +

The name of the port to retrieve the device from.

@@ -3558,7 +3054,7 @@
@@ -3589,8 +3085,8 @@
@@ -3615,6 +3111,30 @@ +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + @@ -3623,7 +3143,7 @@
-

attach

+

waitForDeviceByType(deviceType)

@@ -3631,7 +3151,8 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

+

Note: If a device is never attached, the returned promise may never resolve.

@@ -3666,13 +3187,13 @@ - port + deviceType -string +number @@ -3683,20 +3204,175 @@ - +

The device type to lookup.

+ + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved once a device is attached, or resolved immediately if a device is already attached.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + + + +
+ + + + + +

Events

+ +
+ +
+
+

attach

+ + +
+
+ + +
+

Emits when a device is attached to the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - + + +
NameTypeDescription
typedevice -DeviceType +Device @@ -3735,11 +3411,6 @@ - -
Overrides:
-
@@ -3765,8 +3436,8 @@
@@ -3872,7 +3543,7 @@
-ButtonState +ButtonState @@ -3912,176 +3583,10 @@ - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - +
Overrides:
+
@@ -4107,203 +3612,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -4344,7 +3654,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -4379,13 +3689,13 @@
portdevice -string +Device @@ -4424,11 +3734,6 @@ - -
Overrides:
-
@@ -4454,8 +3759,8 @@
@@ -4488,7 +3793,7 @@
-

distance

+

disconnect

@@ -4496,7 +3801,7 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

@@ -4506,80 +3811,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- -
@@ -4594,7 +3825,7 @@
@@ -4625,740 +3856,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -5437,7 +3936,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/PiezoBuzzer.html b/docs/PiezoBuzzer.html new file mode 100644 index 0000000..bf700ae --- /dev/null +++ b/docs/PiezoBuzzer.html @@ -0,0 +1,1306 @@ + + + + + + + node-poweredup Class: PiezoBuzzer + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: PiezoBuzzer

+
+ +
+ +

+ PiezoBuzzer +

+ + +
+ + +
+
+ + +
+
+

new PiezoBuzzer()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

playTone(frequency, time)

+ + +
+
+ + +
+

Play a tone on the Hub's in-built buzzer

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
frequency + + +number + + + + +
time + + +number + + + + +

How long the tone should play for (in milliseconds).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the tone has finished playing).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/PoweredUP.html b/docs/PoweredUP.html index 47290cc..d9f67de 100644 --- a/docs/PoweredUP.html +++ b/docs/PoweredUP.html @@ -33,14 +33,14 @@ @@ -211,7 +211,7 @@
-

getConnectedHubByPrimaryMACAddress(address)

+

getHubByPrimaryMACAddress(address)

@@ -316,7 +316,7 @@
@@ -352,7 +352,7 @@
-Hub +BaseHub @@ -369,7 +369,7 @@
-

getConnectedHubByUUID(uuid)

+

getHubByUUID(uuid)

@@ -474,7 +474,7 @@ @@ -510,7 +510,7 @@
-Hub +BaseHub | null @@ -530,7 +530,7 @@
-

getConnectedHubs()

+

getHubs()

@@ -585,7 +585,7 @@ @@ -621,7 +621,7 @@
-Array.<Hub> +Array.<BaseHub> @@ -638,7 +638,7 @@
-

getConnectedHubsByName(name)

+

getHubsByName(name)

@@ -743,7 +743,7 @@ @@ -779,7 +779,165 @@
-Array.<Hub> +Array.<BaseHub> + + + +
+ + + + + + + + + + +
+
+

getHubsByType(name)

+ + +
+
+ + +
+

Retrieve a list of Powered UP Hub by type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Array.<BaseHub> @@ -851,7 +1009,7 @@
@@ -939,7 +1097,7 @@
@@ -1029,22 +1187,22 @@
-WeDo2SmartHub +WeDo2SmartHub | -BoostMoveHub +MoveHub | -ControlPlusHub +TechnicMediumHub | -PUPHub +Hub | -PUPRemote +RemoteControl | -DuploTrainBase +DuploTrainBase @@ -1100,7 +1258,7 @@ @@ -1179,7 +1337,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Fri Feb 7th 2020 using the DocStrap template. diff --git a/docs/RemoteControl.html b/docs/RemoteControl.html new file mode 100644 index 0000000..baa185e --- /dev/null +++ b/docs/RemoteControl.html @@ -0,0 +1,2218 @@ + + + + + + + node-poweredup Class: RemoteControl + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: RemoteControl

+
+ +
+ +

+ RemoteControl +

+ + +
+ + +
+
+ + +
+
+

new RemoteControl()

+ + +
+
+ + +
+

The RemoteControl is emitted if the discovered device is a Remote Control.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> batteryLevel

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
batteryLevel + + +number + + + + +

Battery level of the hub (Percentage between 0-100)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> firmwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Firmware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hardwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> name

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Name of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> rssi

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rssi + + +number + + + + +

Signal strength of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> uuid

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
uuid + + +string + + + + +

UUID of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setName(name)

+ + +
+
+ + +
+

Set the name of the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

New name of the hub (14 characters or less, ASCII only).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

shutdown()

+ + +
+
+ + +
+

Shutdown the Hub.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful disconnect.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/RemoteControlButton.html b/docs/RemoteControlButton.html new file mode 100644 index 0000000..93c6137 --- /dev/null +++ b/docs/RemoteControlButton.html @@ -0,0 +1,1264 @@ + + + + + + + node-poweredup Class: RemoteControlButton + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: RemoteControlButton

+
+ +
+ +

+ RemoteControlButton +

+ + +
+ + +
+
+ + +
+
+

new RemoteControlButton()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

button

+ + +
+
+ + +
+

Emits when a button on the remote is pressed or released.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
event + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/SimpleMediumLinearMotor.html b/docs/SimpleMediumLinearMotor.html new file mode 100644 index 0000000..60f7205 --- /dev/null +++ b/docs/SimpleMediumLinearMotor.html @@ -0,0 +1,1116 @@ + + + + + + + node-poweredup Class: SimpleMediumLinearMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: SimpleMediumLinearMotor

+
+ +
+ +

+ SimpleMediumLinearMotor +

+ + +
+ + +
+
+ + +
+
+

new SimpleMediumLinearMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TachoMotor.html b/docs/TachoMotor.html new file mode 100644 index 0000000..967adff --- /dev/null +++ b/docs/TachoMotor.html @@ -0,0 +1,2419 @@ + + + + + + + node-poweredup Class: TachoMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TachoMotor

+
+ +
+ +

+ TachoMotor +

+ + +
+ + +
+
+ + +
+
+

new TachoMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

brake()

+ + +
+
+ + +
+

Brake the motor.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rampPower(fromPower, toPower, time)

+ + +
+
+ + +
+

Ramp the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fromPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time + + +number + + + + +

How long the ramp should last (in milliseconds).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setPower(power)

+ + +
+
+ + +
+

Set the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
power + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

stop()

+ + +
+
+ + +
+

Stop the motor.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicColorSensor.html b/docs/TechnicColorSensor.html new file mode 100644 index 0000000..83f854b --- /dev/null +++ b/docs/TechnicColorSensor.html @@ -0,0 +1,1552 @@ + + + + + + + node-poweredup Class: TechnicColorSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicColorSensor

+
+ +
+ +

+ TechnicColorSensor +

+ + +
+ + +
+
+ + +
+
+

new TechnicColorSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

ambient

+ + +
+
+ + +
+

Emits when the ambient light changes.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ambient + + +number + + + + +

Percentage, from 0 to 100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

color

+ + +
+
+ + +
+

Emits when a color sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
color + + +Color + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

reflect

+ + +
+
+ + +
+

Emits when the light reflectivity changes.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
reflect + + +number + + + + +

Percentage, from 0 to 100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicDistanceSensor.html b/docs/TechnicDistanceSensor.html new file mode 100644 index 0000000..83569c3 --- /dev/null +++ b/docs/TechnicDistanceSensor.html @@ -0,0 +1,1646 @@ + + + + + + + node-poweredup Class: TechnicDistanceSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicDistanceSensor

+
+ +
+ +

+ TechnicDistanceSensor +

+ + +
+ + +
+
+ + +
+
+

new TechnicDistanceSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

setBrightness(topLeft, bottomLeft, topRight, bottomRight)

+ + +
+
+ + +
+

Set the brightness (or turn on/off) the lights around the eyes.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
topLeft + + +number + + + + +

Top left quadrant (above left eye). 0-100 brightness.

bottomLeft + + +number + + + + +

Bottom left quadrant (below left eye). 0-100 brightness.

topRight + + +number + + + + +

Top right quadrant (above right eye). 0-100 brightness.

bottomRight + + +number + + + + +

Bottom right quadrant (below right eye). 0-100 brightness.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

distance

+ + +
+
+ + +
+

Emits when the detected distance changes (Slow sampling covers 40mm to 2500mm).

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
distance + + +number + + + + +

Distance, from 40 to 2500mm

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

fastDistance

+ + +
+
+ + +
+

Emits when the detected distance changes (Fast sampling covers 50mm to 320mm).

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fastDistance + + +number + + + + +

Distance, from 50 to 320mm

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicForceSensor.html b/docs/TechnicForceSensor.html new file mode 100644 index 0000000..d82d696 --- /dev/null +++ b/docs/TechnicForceSensor.html @@ -0,0 +1,1552 @@ + + + + + + + node-poweredup Class: TechnicForceSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicForceSensor

+
+ +
+ +

+ TechnicForceSensor +

+ + +
+ + +
+
+ + +
+
+

new TechnicForceSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

force

+ + +
+
+ + +
+

Emits when force is applied.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
force + + +number + + + + +

Force, in newtons (0-10).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

tapped

+ + +
+
+ + +
+

Emits when the sensor is tapped.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tapped + + +number + + + + +

How hard the sensor was tapped, from 0-3.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

touch

+ + +
+
+ + +
+

Emits when the sensor is touched.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
touch + + +boolean + + + + +

Touched on/off (boolean).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicLargeAngularMotor.html b/docs/TechnicLargeAngularMotor.html new file mode 100644 index 0000000..5c6ff15 --- /dev/null +++ b/docs/TechnicLargeAngularMotor.html @@ -0,0 +1,1431 @@ + + + + + + + node-poweredup Class: TechnicLargeAngularMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicLargeAngularMotor

+
+ +
+ +

+ TechnicLargeAngularMotor +

+ + +
+ + +
+
+ + +
+
+

new TechnicLargeAngularMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

gotoAngle(angle [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given angle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
angle + + +number + + + + + + + + + + + + +

Absolute position the motor should go to (degrees from 0).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicLargeLinearMotor.html b/docs/TechnicLargeLinearMotor.html new file mode 100644 index 0000000..ea5f77c --- /dev/null +++ b/docs/TechnicLargeLinearMotor.html @@ -0,0 +1,1431 @@ + + + + + + + node-poweredup Class: TechnicLargeLinearMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicLargeLinearMotor

+
+ +
+ +

+ TechnicLargeLinearMotor +

+ + +
+ + +
+
+ + +
+
+

new TechnicLargeLinearMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

gotoAngle(angle [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given angle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
angle + + +number + + + + + + + + + + + + +

Absolute position the motor should go to (degrees from 0).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicMediumAngularMotor.html b/docs/TechnicMediumAngularMotor.html new file mode 100644 index 0000000..9201004 --- /dev/null +++ b/docs/TechnicMediumAngularMotor.html @@ -0,0 +1,1431 @@ + + + + + + + node-poweredup Class: TechnicMediumAngularMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicMediumAngularMotor

+
+ +
+ +

+ TechnicMediumAngularMotor +

+ + +
+ + +
+
+ + +
+
+

new TechnicMediumAngularMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

gotoAngle(angle [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given angle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
angle + + +number + + + + + + + + + + + + +

Absolute position the motor should go to (degrees from 0).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicMediumHub.html b/docs/TechnicMediumHub.html new file mode 100644 index 0000000..ae18d0e --- /dev/null +++ b/docs/TechnicMediumHub.html @@ -0,0 +1,2218 @@ + + + + + + + node-poweredup Class: TechnicMediumHub + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicMediumHub

+
+ +
+ +

+ TechnicMediumHub +

+ + +
+ + +
+
+ + +
+
+

new TechnicMediumHub()

+ + +
+
+ + +
+

The TechnicMediumHub is emitted if the discovered device is a Technic Medium Hub.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> batteryLevel

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
batteryLevel + + +number + + + + +

Battery level of the hub (Percentage between 0-100)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> firmwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Firmware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hardwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> name

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Name of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> rssi

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rssi + + +number + + + + +

Signal strength of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> uuid

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
uuid + + +string + + + + +

UUID of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

createVirtualPort(firstPortName, secondPortName)

+ + +
+
+ + +
+

Combines two ports with into a single virtual port.

+

Note: The devices attached to the ports must be of the same device type.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firstPortName + + +string + + + + +

First port name

secondPortName + + +string + + + + +

Second port name

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setName(name)

+ + +
+
+ + +
+

Set the name of the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

New name of the hub (14 characters or less, ASCII only).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

shutdown()

+ + +
+
+ + +
+

Shutdown the Hub.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful disconnect.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicMediumHubAccelerometerSensor.html b/docs/TechnicMediumHubAccelerometerSensor.html new file mode 100644 index 0000000..eda09c3 --- /dev/null +++ b/docs/TechnicMediumHubAccelerometerSensor.html @@ -0,0 +1,1312 @@ + + + + + + + node-poweredup Class: TechnicMediumHubAccelerometerSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicMediumHubAccelerometerSensor

+
+ +
+ +

+ TechnicMediumHubAccelerometerSensor +

+ + +
+ + +
+
+ + +
+
+

new TechnicMediumHubAccelerometerSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

accel

+ + +
+
+ + +
+

Emits when accelerometer detects movement. Measured in mG.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
z + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicMediumHubGyroSensor.html b/docs/TechnicMediumHubGyroSensor.html new file mode 100644 index 0000000..b2c7736 --- /dev/null +++ b/docs/TechnicMediumHubGyroSensor.html @@ -0,0 +1,1312 @@ + + + + + + + node-poweredup Class: TechnicMediumHubGyroSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicMediumHubGyroSensor

+
+ +
+ +

+ TechnicMediumHubGyroSensor +

+ + +
+ + +
+
+ + +
+
+

new TechnicMediumHubGyroSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

gyro

+ + +
+
+ + +
+

Emits when gyroscope detects movement. Measured in DPS - degrees per second.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
z + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicMediumHubTiltSensor.html b/docs/TechnicMediumHubTiltSensor.html new file mode 100644 index 0000000..7dba8d9 --- /dev/null +++ b/docs/TechnicMediumHubTiltSensor.html @@ -0,0 +1,1312 @@ + + + + + + + node-poweredup Class: TechnicMediumHubTiltSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicMediumHubTiltSensor

+
+ +
+ +

+ TechnicMediumHubTiltSensor +

+ + +
+ + +
+
+ + +
+
+

new TechnicMediumHubTiltSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

tilt

+ + +
+
+ + +
+

Emits when a tilt sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
z + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TechnicXLargeLinearMotor.html b/docs/TechnicXLargeLinearMotor.html new file mode 100644 index 0000000..ef77666 --- /dev/null +++ b/docs/TechnicXLargeLinearMotor.html @@ -0,0 +1,1431 @@ + + + + + + + node-poweredup Class: TechnicXLargeLinearMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TechnicXLargeLinearMotor

+
+ +
+ +

+ TechnicXLargeLinearMotor +

+ + +
+ + +
+
+ + +
+
+

new TechnicXLargeLinearMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Methods

+ +
+ +
+
+

gotoAngle(angle [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given angle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
angle + + +number + + + + + + + + + + + + +

Absolute position the motor should go to (degrees from 0).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rotateByDegrees(degrees [, speed])

+ + +
+
+ + +
+

Rotate a motor by a given amount of degrees.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
degrees + + +number + + + + + + + + + + + + +

How much the motor should be rotated (in degrees).

speed + + +number + + + + + + + <optional>
+ + + + + +
+ + 100 + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setBrakingStyle(style)

+ + +
+
+ + +
+

Set the braking style of the motor.

+

Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
style + + +number + + + + +

Either BRAKE or HOLD

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

setSpeed(speed)

+ + +
+
+ + +
+

Set the motor speed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
speed + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TiltSensor.html b/docs/TiltSensor.html new file mode 100644 index 0000000..545a26c --- /dev/null +++ b/docs/TiltSensor.html @@ -0,0 +1,1288 @@ + + + + + + + node-poweredup Class: TiltSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TiltSensor

+
+ +
+ +

+ TiltSensor +

+ + +
+ + +
+
+ + +
+
+

new TiltSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

tilt

+ + +
+
+ + +
+

Emits when a tilt sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/TrainMotor.html b/docs/TrainMotor.html new file mode 100644 index 0000000..87d16af --- /dev/null +++ b/docs/TrainMotor.html @@ -0,0 +1,1752 @@ + + + + + + + node-poweredup Class: TrainMotor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: TrainMotor

+
+ +
+ +

+ TrainMotor +

+ + +
+ + +
+
+ + +
+
+

new TrainMotor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+
+

brake()

+ + +
+
+ + +
+

Brake the motor.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

rampPower(fromPower, toPower, time)

+ + +
+
+ + +
+

Ramp the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fromPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toPower + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time + + +number + + + + +

How long the ramp should last (in milliseconds).

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

setPower(power)

+ + +
+
+ + +
+

Set the motor power.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
power + + +number + + + + +

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ + + +
+
+

stop()

+ + +
+
+ + +
+

Stop the motor.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful issuance of the command.

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/VoltageSensor.html b/docs/VoltageSensor.html new file mode 100644 index 0000000..f0e5419 --- /dev/null +++ b/docs/VoltageSensor.html @@ -0,0 +1,1264 @@ + + + + + + + node-poweredup Class: VoltageSensor + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: VoltageSensor

+
+ +
+ +

+ VoltageSensor +

+ + +
+ + +
+
+ + +
+
+

new VoltageSensor()

+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + +

Members

+ +
+ +
+
+

<readonly> connected

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connected + + +boolean + + + + +

Check if the device is still attached.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> hub

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
hub + + +Hub + + + + +

The Hub the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> isVirtualPort

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
isVirtualPort + + +boolean + + + + +

Is this device attached to a virtual port (ie. a combined device)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> mode

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mode + + +number + + + + +

The mode the device is currently in

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> portName

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
portName + + +string + + + + +

The port the device is attached to.

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +number + + + + +

The type of the device

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + + + + + +

Events

+ +
+ +
+
+

voltage

+ + +
+
+ + +
+

Emits when a voltage change is detected.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
voltage + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html index 71a97c6..1e810f0 100644 --- a/docs/WeDo2SmartHub.html +++ b/docs/WeDo2SmartHub.html @@ -33,21 +33,14 @@ - - @@ -152,8 +145,8 @@
@@ -192,7 +185,7 @@ @@ -288,7 +281,7 @@
@@ -319,136 +312,8 @@
-
- - - - - - - - - - - - - - - -
-
-

<readonly> current

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
current - - -number - - - - -

Current usage of the hub (Milliamps)

-
- - - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -544,7 +409,7 @@
@@ -575,8 +440,8 @@
@@ -636,7 +501,7 @@
firmwareVersionhardwareVersion @@ -672,7 +537,7 @@
@@ -703,8 +568,8 @@
@@ -800,7 +665,7 @@
@@ -831,8 +696,136 @@
+
+ + + + + + + + + + + + + + + +
+
+

<readonly> ports

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ports + + +Array.<string> + + + + +

Array of port names

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -928,7 +921,7 @@
@@ -959,8 +952,8 @@
@@ -1056,7 +1049,7 @@
@@ -1087,8 +1080,136 @@
+
+ + + + + + + +
+ + + +
+ + + +
+
+

<readonly> type

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + +

Hub type

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -1184,7 +1305,7 @@
@@ -1215,136 +1336,8 @@
-
- - - - - - - -
- - - -
- - - -
-
-

<readonly> voltage

- - -
-
- - - - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
voltage - - -number - - - - -

Voltage of the hub (Volts)

-
- - - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -1369,1967 +1362,6 @@
-
-
-

brakeMotor(port)

- - -
-
- - -
-

Fully (hard) stop the motor on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

connect()

- - -
-
- - -
-

Connect to the Hub.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful connect.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

disconnect()

- - -
-
- - -
-

Disconnect the Hub.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful disconnect.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

getHubType()

- - -
-
- - -
-

Get the hub type.

-
- - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -HubType - - - -
-
- - - - - -
- - - -
-
-

getPortDeviceType(port)

- - -
-
- - -
-

Get the device type for a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -DeviceType - - - -
-
- - - - - -
- - - -
-
-

playTone(frequency, time)

- - -
-
- - -
-

Play a tone on the Hub's in-built buzzer

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
frequency - - -number - - - - -
time - - -number - - - - -

How long the tone should play for (in milliseconds).

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command (ie. once the tone has finished playing).

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

rampMotorSpeed(port, fromSpeed, toSpeed, time)

- - -
-
- - -
-

Ramp the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
fromSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

toSpeed - - -number - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time - - -number - - - - -

How long the ramp should last (in milliseconds).

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLEDColor(color)

- - -
-
- - -
-

Set the color of the LED on the Hub via a color value.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
color - - -Color - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLEDRGB(red, green, blue)

- - -
-
- - -
-

Set the color of the LED on the Hub via RGB values.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
red - - -number - - - - -
green - - -number - - - - -
blue - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setLightBrightness(port, brightness [, time])

- - -
-
- - -
-

Set the light brightness on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
brightness - - -number - - - - - - - - - - -

Brightness value between 0-100 (0 is off)

time - - -number - - - - - - - <optional>
- - - - - -

How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the light is turned off.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

setMotorSpeed(port, speed [, time])

- - -
-
- - -
-

Set the motor speed on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
speed - - -number - - - - - - - - - - -

For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.

time - - -number - - - - - - - <optional>
- - - - - -

How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful completion of command. If time is specified, this is once the motor is finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - -

setName(name)

@@ -3436,8 +1468,8 @@
@@ -3548,8 +1580,8 @@
@@ -3600,736 +1632,6 @@ -
- - - -
-
-

sleep(delay)

- - -
-
- - -
-

Sleep a given amount of time.

-

This is a helper method to make it easier to add delays into a chain of commands.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
delay - - -number - - - - -

How long to sleep (in milliseconds).

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved after the delay is finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

subscribe(port [, mode])

- - -
-
- - -
-

Subscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
port - - -string - - - - - - - - - - -
mode - - -number - - - - - - - <optional>
- - - - - -

The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

unsubscribe(port)

- - -
-
- - -
-

Unsubscribe to sensor notifications on a given port.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved upon successful issuance of command.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - - -
- - - -
-
-

wait(commands)

- - -
-
- - -
-

Wait until a given list of concurrently running commands are complete.

-

This is a helper method to make it easier to wait for concurrent commands to complete.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
commands - - -Array.<Promise.<any>> - - - - -

Array of executing commands.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

Resolved after the commands are finished.

-
- - - -
-
- Type -
-
- -Promise - - - -
-
- - - - -
@@ -4342,177 +1644,6 @@
-
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - -

button

@@ -4588,7 +1719,7 @@
-ButtonState +ButtonState @@ -4643,827 +1774,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

distance

- - -
-
- - -
-

Emits when a distance sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -5542,7 +1854,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/boostmovehub.js.html b/docs/boostmovehub.js.html index 74a382c..85bb247 100644 --- a/docs/boostmovehub.js.html +++ b/docs/boostmovehub.js.html @@ -40,7 +40,7 @@ @@ -423,7 +423,7 @@ exports.BoostMoveHub = BoostMoveHub; Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Tue Dec 3rd 2019 using the DocStrap template. diff --git a/docs/classes.list.html b/docs/classes.list.html index 8465b00..1c88563 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -33,21 +33,14 @@ - - @@ -149,22 +142,73 @@

Classes

+
AbsoluteMotor
+
+ +
BaseHub
+
+ +
BasicMotor
+
+
BoostMoveHub
+
ColorDistanceSensor
+
+
ControlPlusHub
+
CurrentSensor
+
+ +
Device
+
+
DuploTrainBase
+
DuploTrainBaseColorSensor
+
+ +
DuploTrainBaseMotor
+
+ +
DuploTrainBaseSpeaker
+
+ +
DuploTraniBaseSpeedometer
+
+
Hub
+
HubLED
+
+ +
Light
+
+
LPF2Hub
-
PoweredUP
+
MediumLinearMotor
+
+ +
MotionSensor
+
+ +
MoveHub
+
+ +
MoveHubMediumLinearMotor
+
+ +
MoveHubTiltSensor
+
+ +
PiezoBuzzer
PUPHub
@@ -173,6 +217,60 @@
PUPRemote
+
RemoteControl
+
+ +
RemoteControlButton
+
+ +
SimpleMediumLinearMotor
+
+ +
TachoMotor
+
+ +
TechnicColorSensor
+
+ +
TechnicDistanceSensor
+
+ +
TechnicForceSensor
+
+ +
TechnicLargeAngularMotor
+
+ +
TechnicLargeLinearMotor
+
+ +
TechnicMediumAngularMotor
+
+ +
TechnicMediumHub
+
+ +
TechnicMediumHubAccelerometerSensor
+
+ +
TechnicMediumHubGyroSensor
+
+ +
TechnicMediumHubTiltSensor
+
+ +
TechnicXLargeLinearMotor
+
+ +
TiltSensor
+
+ +
TrainMotor
+
+ +
VoltageSensor
+
+
WeDo2SmartHub
@@ -195,7 +293,7 @@
-

accel

+

absolute

@@ -203,13 +301,19 @@
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

+

Emits when a the motors absolute position is changed.

+
Type: +object + + +
+ @@ -238,31 +342,7 @@
port - - -string - - - - -
xabsolute @@ -283,34 +363,130 @@
- - - y + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+
+

rotate

+ + +
+
- - - -number + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object +
+ - - + + +
Parameters:
+ - + + + + + + - + - - + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -834,7 +1207,7 @@ - - - - - - - - - - - - - - - - @@ -1005,7 +1351,7 @@ - - - - - - - - - - - - - - - - @@ -1381,15 +1548,6 @@ -
Inherited From:
-
- -
- @@ -1416,959 +1574,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - -
NameType
Description
zrotation @@ -349,7 +525,7 @@
@@ -380,8 +556,8 @@
@@ -422,7 +598,7 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Emits when a device is attached to the Hub.

@@ -457,37 +633,13 @@
portdevice -string - - - - -
type - - -DeviceType +Device @@ -526,11 +678,6 @@ - -
Overrides:
-
@@ -556,8 +703,8 @@
@@ -663,7 +810,7 @@
-ButtonState +ButtonState @@ -727,8 +874,252 @@
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

detach

+ + +
+
+ + +
+

Emits when a device is detached from the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
device + + +Device + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

disconnect

+ + +
+
+ + +
+

Emits when the hub is disconnected.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -776,6 +1167,12 @@ +
Type: +object + + +
+ @@ -802,30 +1199,6 @@
port - - -string - - - - -
color -Color +Color @@ -863,15 +1236,6 @@ -
Inherited From:
-
- -
- @@ -898,8 +1262,8 @@
@@ -947,6 +1311,12 @@ +
Type: +object + + +
+ @@ -973,30 +1343,6 @@
port - - -string - - - - -
color -Color +Color @@ -1058,15 +1404,6 @@ -
Inherited From:
-
- -
- @@ -1093,160 +1430,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -1294,6 +1479,12 @@ +
Type: +object + + +
+ @@ -1320,30 +1511,6 @@
port - - -string - - - - -
distance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -2409,7 +1616,7 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Emits when a device is attached to the Hub.

@@ -2444,37 +1651,13 @@ - port + device -string - - - - - - - - - - - - - - - - - - type - - - - - -DeviceType +Device @@ -2513,11 +1696,6 @@
- -
Overrides:
-
@@ -2543,8 +1721,8 @@
@@ -2650,7 +1828,7 @@ -ButtonState +ButtonState @@ -2714,374 +1892,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -3122,7 +1934,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -3157,13 +1969,13 @@ - port + device -string +Device @@ -3202,11 +2014,6 @@
- -
Overrides:
-
@@ -3232,8 +2039,8 @@
@@ -3266,7 +2073,7 @@
-

distance

+

disconnect

@@ -3274,7 +2081,7 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

@@ -3284,80 +2091,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- -
@@ -3372,7 +2105,7 @@
@@ -3403,8 +2136,8 @@
@@ -3437,7 +2170,7 @@
-

rotate

+

current

@@ -3445,13 +2178,19 @@
-

Emits when a rotation sensor is activated.

+

Emits when a current change is detected.

+
Type: +object + + +
+ @@ -3480,31 +2219,7 @@ - port - - - - - -string - - - - - - - - - - - - - - - - - - rotation + current @@ -3539,15 +2254,6 @@ -
Inherited From:
-
- -
- @@ -3574,964 +2280,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -4637,7 +2387,7 @@ -ButtonState +ButtonState @@ -4701,8 +2451,8 @@
@@ -4750,6 +2500,12 @@ +
Type: +object + + +
+ @@ -4776,30 +2532,6 @@ - - - port - - - - - -string - - - - - - - - - - - - - - - color @@ -4808,7 +2540,7 @@ -Color +Color @@ -4837,15 +2569,6 @@ -
Inherited From:
-
- -
- @@ -4872,8 +2595,8 @@
@@ -4906,7 +2629,7 @@
-

colorAndDistance

+

reflect

@@ -4914,13 +2637,19 @@
-

A combined color and distance event, emits when the sensor is activated.

+

Emits when the light reflectivity changes.

+
Type: +object + + +
+ @@ -4949,55 +2678,7 @@ - port - - - - - -string - - - - - - - - - - - - - - - - - - color - - - - - -Color - - - - - - - - - - - - - - - - - - distance + reflect @@ -5014,7 +2695,7 @@ -

Distance, in millimeters.

+

Percentage, from 0 to 100.

@@ -5032,15 +2713,6 @@ -
Inherited From:
-
- -
- @@ -5067,8 +2739,8 @@
@@ -5101,7 +2773,7 @@
-

detach

+

rgb

@@ -5109,13 +2781,19 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when the light reflectivity changes.

+
Type: +object + + +
+ @@ -5144,183 +2822,7 @@ - port - - - - - -string - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

distance

- - -
-
- - -
-

Emits when a distance sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - -
NameTypeDescription
port - - -string - - - - -
distancered @@ -5337,143 +2839,20 @@ -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - @@ -5697,15 +3049,6 @@ -
Inherited From:
-
- -
- @@ -5732,398 +3075,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - -
NameTypeDescription
portgreen -string +number @@ -5491,7 +2870,7 @@
rotationblue @@ -5526,15 +2905,6 @@ -
Inherited From:
-
- -
- @@ -5561,8 +2931,8 @@
@@ -5610,6 +2980,12 @@ +
Type: +object + + +
+ @@ -5636,30 +3012,6 @@
port - - -string - - - - -
speed
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -6164,7 +3117,7 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Emits when a device is attached to the Hub.

@@ -6199,37 +3152,13 @@ - port + device -string - - - - - - - - - - - - - - - - - - type - - - - - -DeviceType +Device @@ -6284,527 +3213,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -6910,2070 +3320,7 @@ -ButtonState - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

distance

- - -
-
- - -
-

Emits when a distance sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

discover

- - -
-
- - -
-

Emits when a Powered UP Hub device is found.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
hub - - -WeDo2SmartHub -| - -BoostMoveHub -| - -ControlPlusHub -| - -PUPHub -| - -PUPRemote -| - -DuploTrainBase - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

button

- - -
-
- - -
-

Emits when a button is pressed.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + +
NameTypeDescription
button - - -string - - - - -
state - - -ButtonState +ButtonState @@ -9037,374 +3384,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -9445,7 +3426,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -9480,13 +3461,13 @@
portdevice -string +Device @@ -9515,21 +3496,7 @@ -
Inherited From:
-
- -
- - -
Overrides:
-
@@ -9555,8 +3522,8 @@
@@ -9589,7 +3556,7 @@
-

distance

+

disconnect

@@ -9597,7 +3564,7 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

@@ -9607,80 +3574,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- -
@@ -9691,15 +3584,6 @@ -
Inherited From:
-
- -
- @@ -9726,1135 +3610,8 @@
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
-

rotate

- - -
-
- - -
-

Emits when a rotation sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
rotation - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

tilt

- - -
-
- - -
-

Emits when a tilt sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -

(Only available when using a Control+ Hub)

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

accel

- - -
-
- - -
-

Emits when accelerometer detects movement. Measured in DPS - degrees per second.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
x - - -number - - - - -
y - - -number - - - - -
z - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

attach

- - -
-
- - -
-

Emits when a motor or sensor is attached to the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
type - - -DeviceType - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -10960,7 +3717,466 @@
-ButtonState +ButtonState + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

distance

+ + +
+
+ + +
+

Emits when a distance sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
distance + + +number + + + + +

Distance, in millimeters.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - @@ -11853,7 +4362,7 @@
@@ -11884,350 +4393,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

speed

- - -
-
- - -
-

Emits on a speed change.

-
- - - - - - - - -
Parameters:
- - -
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState @@ -11024,697 +4240,8 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

colorAndDistance

- - -
-
- - -
-

A combined color and distance event, emits when the sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

detach

- - -
-
- - -
-

Emits when an attached motor or sensor is detached from the Hub.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

distance

- - -
-
- - -
-

Emits when a distance sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
distance - - -number - - - - -

Distance, in millimeters.

- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -11762,6 +4289,12 @@ +
Type: +object + + +
+ @@ -11788,30 +4321,6 @@
port - - -string - - - - -
rotation
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
speed - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - -
-
-

temp

- - -
-
- - -
-

Emits when a change is detected on a temperature sensor. Measured in degrees centigrade.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -

For Control+ Hubs, port will be "CPU" as the sensor reports CPU temperature.

temp - - -number - - - - -
- - - - -
- - - - - - - -
Inherited From:
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
-
@@ -12275,6 +4442,12 @@ +
Type: +object + + +
+ @@ -12301,30 +4474,6 @@ - - - port - - - - - -string - - - - - - - - - - -

If the event is fired from the Move Hub or Control+ Hub's in-built tilt sensor, the special port "TILT" is used.

- - - - x @@ -12372,30 +4521,6 @@ - - - - z - - - - - -number - - - - - - - - - - -

(Only available when using a Control+ Hub)

- - - @@ -12410,15 +4535,6 @@ -
Inherited From:
-
- -
- @@ -12445,8 +4561,8 @@
@@ -12487,7 +4603,7 @@
-

Emits when a motor or sensor is attached to the Hub.

+

Emits when a device is attached to the Hub.

@@ -12522,37 +4638,13 @@ - port + device -string - - - - - - - - - - - - - - - - - - type - - - - - -DeviceType +Device @@ -12616,8 +4708,8 @@
@@ -12723,7 +4815,7 @@ -ButtonState +ButtonState @@ -12752,169 +4844,21 @@ - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
+
Inherited From:
+
- - - - - -
- - - - - - - - - - - - - - -
- - - -
-
-

color

- - -
-
- - -
-

Emits when a color sensor is activated.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
port - - -string - - - - -
color - - -Color - - - - -
- - - - -
- - - - - - - - +
Overrides:
+
@@ -12940,8 +4884,8 @@
@@ -12982,7 +4926,7 @@
-

Emits when an attached motor or sensor is detached from the Hub.

+

Emits when a device is detached from the Hub.

@@ -13017,13 +4961,13 @@ - port + device -string +Device @@ -13087,8 +5031,8 @@
@@ -13121,7 +5065,7 @@
-

distance

+

disconnect

@@ -13129,7 +5073,104 @@
-

Emits when a distance sensor is activated.

+

Emits when the hub is disconnected.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

attach

+ + +
+
+ + +
+

Emits when a device is attached to the Hub.

@@ -13164,7 +5205,154 @@ - port + device + + + + + +Device + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + +
NameTypeDescription
button @@ -13188,7 +5376,580 @@
distancestate + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

detach

+ + +
+
+ + +
+

Emits when a device is detached from the Hub.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
device + + +Device + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

disconnect

+ + +
+
+ + +
+

Emits when the hub is disconnected.

+
+ + + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button on the remote is pressed or released.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -13249,8 +6010,8 @@
@@ -13298,6 +6059,12 @@ +
Type: +object + + +
+ @@ -13324,30 +6091,6 @@ - - - - - - - - - - - - - - - - @@ -13411,8 +6154,2633 @@
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

ambient

+ + +
+
+ + +
+

Emits when the ambient light changes.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + +
NameTypeDescription
event @@ -13205,7 +5966,7 @@ -

Distance, in millimeters.

port - - -string - - - - -
rotation
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
ambient + + +number + + + + +

Percentage, from 0 to 100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

color

+ + +
+
+ + +
+

Emits when a color sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
color + + +Color + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

reflect

+ + +
+
+ + +
+

Emits when the light reflectivity changes.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
reflect + + +number + + + + +

Percentage, from 0 to 100.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

distance

+ + +
+
+ + +
+

Emits when the detected distance changes (Slow sampling covers 40mm to 2500mm).

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
distance + + +number + + + + +

Distance, from 40 to 2500mm

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

fastDistance

+ + +
+
+ + +
+

Emits when the detected distance changes (Fast sampling covers 50mm to 320mm).

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fastDistance + + +number + + + + +

Distance, from 50 to 320mm

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

force

+ + +
+
+ + +
+

Emits when force is applied.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
force + + +number + + + + +

Force, in newtons (0-10).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

tapped

+ + +
+
+ + +
+

Emits when the sensor is tapped.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tapped + + +number + + + + +

How hard the sensor was tapped, from 0-3.

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

touch

+ + +
+
+ + +
+

Emits when the sensor is touched.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
touch + + +boolean + + + + +

Touched on/off (boolean).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

accel

+ + +
+
+ + +
+

Emits when accelerometer detects movement. Measured in mG.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
z + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

gyro

+ + +
+
+ + +
+

Emits when gyroscope detects movement. Measured in DPS - degrees per second.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +number + + + + +
y + + +number + + + + +
z + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -13460,6 +8828,12 @@ +
Type: +object + + +
+ @@ -13488,13 +8862,13 @@ - port + x -string +number @@ -13510,6 +8884,480 @@ + + + y + + + + + +number + + + + + + + + + + + + + + + + + + z + + + + + +number + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

absolute

+ + +
+
+ + +
+

Emits when a the motors absolute position is changed.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
absolute + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

rotate

+ + +
+
+ + +
+

Emits when a rotation sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
rotation + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

tilt

+ + +
+
+ + +
+

Emits when a tilt sensor is activated.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + @@ -13597,8 +9445,314 @@
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

voltage

+ + +
+
+ + +
+

Emits when a voltage change is detected.

+
+ + + + + +
Type: +object + + +
+ + + + +
Parameters:
+ + +
NameTypeDescription
x
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
voltage + + +number + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -13677,7 +9831,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/consts.js.html b/docs/consts.js.html index 5b95611..05bd8d0 100644 --- a/docs/consts.js.html +++ b/docs/consts.js.html @@ -33,14 +33,14 @@ @@ -90,7 +90,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); * @typedef HubType * @property {number} UNKNOWN 0 * @property {number} WEDO2_SMART_HUB 1 - * @property {number} BOOST_MOVE_HUB 2 + * @property {number} MOVE_HUB 2 * @property {number} POWERED_UP_HUB 3 * @property {number} POWERED_UP_REMOTE 4 * @property {number} DUPLO_TRAIN_HUB 5 @@ -100,18 +100,18 @@ var HubType; (function (HubType) { HubType[HubType["UNKNOWN"] = 0] = "UNKNOWN"; HubType[HubType["WEDO2_SMART_HUB"] = 1] = "WEDO2_SMART_HUB"; - HubType[HubType["BOOST_MOVE_HUB"] = 2] = "BOOST_MOVE_HUB"; - HubType[HubType["POWERED_UP_HUB"] = 3] = "POWERED_UP_HUB"; - HubType[HubType["POWERED_UP_REMOTE"] = 4] = "POWERED_UP_REMOTE"; - HubType[HubType["DUPLO_TRAIN_HUB"] = 5] = "DUPLO_TRAIN_HUB"; - HubType[HubType["CONTROL_PLUS_HUB"] = 6] = "CONTROL_PLUS_HUB"; + HubType[HubType["MOVE_HUB"] = 2] = "MOVE_HUB"; + HubType[HubType["HUB"] = 3] = "HUB"; + HubType[HubType["REMOTE_CONTROL"] = 4] = "REMOTE_CONTROL"; + HubType[HubType["DUPLO_TRAIN_BASE"] = 5] = "DUPLO_TRAIN_BASE"; + HubType[HubType["TECHNIC_MEDIUM_HUB"] = 6] = "TECHNIC_MEDIUM_HUB"; })(HubType = exports.HubType || (exports.HubType = {})); // tslint:disable-next-line exports.HubTypeNames = HubType; /** * @typedef DeviceType * @property {number} UNKNOWN 0 - * @property {number} BASIC_MOTOR 1 + * @property {number} SIMPLE_MEDIUM_LINEAR_MOTOR 1 * @property {number} TRAIN_MOTOR 2 * @property {number} LED_LIGHTS 8 * @property {number} VOLTAGE 20 @@ -120,9 +120,9 @@ exports.HubTypeNames = HubType; * @property {number} RGB_LIGHT 23 * @property {number} WEDO2_TILT 34 * @property {number} WEDO2_DISTANCE 35 - * @property {number} BOOST_DISTANCE 37 - * @property {number} BOOST_TACHO_MOTOR 38 - * @property {number} BOOST_MOVE_HUB_MOTOR 39 + * @property {number} COLOR_DISTANCE_SENSOR 37 + * @property {number} MEDIUM_LINEAR_MOTOR 38 + * @property {number} MOVE_HUB_MEDIUM_LINEAR_MOTOR 39 * @property {number} BOOST_TILT 40 * @property {number} DUPLO_TRAIN_BASE_MOTOR 41 * @property {number} DUPLO_TRAIN_BASE_SPEAKER 42 @@ -138,29 +138,37 @@ exports.HubTypeNames = HubType; var DeviceType; (function (DeviceType) { DeviceType[DeviceType["UNKNOWN"] = 0] = "UNKNOWN"; - DeviceType[DeviceType["BASIC_MOTOR"] = 1] = "BASIC_MOTOR"; + DeviceType[DeviceType["SIMPLE_MEDIUM_LINEAR_MOTOR"] = 1] = "SIMPLE_MEDIUM_LINEAR_MOTOR"; DeviceType[DeviceType["TRAIN_MOTOR"] = 2] = "TRAIN_MOTOR"; - DeviceType[DeviceType["LED_LIGHTS"] = 8] = "LED_LIGHTS"; - DeviceType[DeviceType["VOLTAGE"] = 20] = "VOLTAGE"; - DeviceType[DeviceType["CURRENT"] = 21] = "CURRENT"; - DeviceType[DeviceType["PIEZO_TONE"] = 22] = "PIEZO_TONE"; - DeviceType[DeviceType["RGB_LIGHT"] = 23] = "RGB_LIGHT"; - DeviceType[DeviceType["WEDO2_TILT"] = 34] = "WEDO2_TILT"; - DeviceType[DeviceType["WEDO2_DISTANCE"] = 35] = "WEDO2_DISTANCE"; - DeviceType[DeviceType["BOOST_DISTANCE"] = 37] = "BOOST_DISTANCE"; - DeviceType[DeviceType["BOOST_TACHO_MOTOR"] = 38] = "BOOST_TACHO_MOTOR"; - DeviceType[DeviceType["BOOST_MOVE_HUB_MOTOR"] = 39] = "BOOST_MOVE_HUB_MOTOR"; - DeviceType[DeviceType["BOOST_TILT"] = 40] = "BOOST_TILT"; + DeviceType[DeviceType["LIGHT"] = 8] = "LIGHT"; + DeviceType[DeviceType["VOLTAGE_SENSOR"] = 20] = "VOLTAGE_SENSOR"; + DeviceType[DeviceType["CURRENT_SENSOR"] = 21] = "CURRENT_SENSOR"; + DeviceType[DeviceType["PIEZO_BUZZER"] = 22] = "PIEZO_BUZZER"; + DeviceType[DeviceType["HUB_LED"] = 23] = "HUB_LED"; + DeviceType[DeviceType["TILT_SENSOR"] = 34] = "TILT_SENSOR"; + DeviceType[DeviceType["MOTION_SENSOR"] = 35] = "MOTION_SENSOR"; + DeviceType[DeviceType["COLOR_DISTANCE_SENSOR"] = 37] = "COLOR_DISTANCE_SENSOR"; + DeviceType[DeviceType["MEDIUM_LINEAR_MOTOR"] = 38] = "MEDIUM_LINEAR_MOTOR"; + DeviceType[DeviceType["MOVE_HUB_MEDIUM_LINEAR_MOTOR"] = 39] = "MOVE_HUB_MEDIUM_LINEAR_MOTOR"; + DeviceType[DeviceType["MOVE_HUB_TILT_SENSOR"] = 40] = "MOVE_HUB_TILT_SENSOR"; DeviceType[DeviceType["DUPLO_TRAIN_BASE_MOTOR"] = 41] = "DUPLO_TRAIN_BASE_MOTOR"; DeviceType[DeviceType["DUPLO_TRAIN_BASE_SPEAKER"] = 42] = "DUPLO_TRAIN_BASE_SPEAKER"; - DeviceType[DeviceType["DUPLO_TRAIN_BASE_COLOR"] = 43] = "DUPLO_TRAIN_BASE_COLOR"; + DeviceType[DeviceType["DUPLO_TRAIN_BASE_COLOR_SENSOR"] = 43] = "DUPLO_TRAIN_BASE_COLOR_SENSOR"; DeviceType[DeviceType["DUPLO_TRAIN_BASE_SPEEDOMETER"] = 44] = "DUPLO_TRAIN_BASE_SPEEDOMETER"; - DeviceType[DeviceType["CONTROL_PLUS_LARGE_MOTOR"] = 46] = "CONTROL_PLUS_LARGE_MOTOR"; - DeviceType[DeviceType["CONTROL_PLUS_XLARGE_MOTOR"] = 47] = "CONTROL_PLUS_XLARGE_MOTOR"; - DeviceType[DeviceType["POWERED_UP_REMOTE_BUTTON"] = 55] = "POWERED_UP_REMOTE_BUTTON"; - DeviceType[DeviceType["RSSI"] = 56] = "RSSI"; - DeviceType[DeviceType["CONTROL_PLUS_ACCELEROMETER"] = 58] = "CONTROL_PLUS_ACCELEROMETER"; - DeviceType[DeviceType["CONTROL_PLUS_TILT"] = 59] = "CONTROL_PLUS_TILT"; + DeviceType[DeviceType["TECHNIC_LARGE_LINEAR_MOTOR"] = 46] = "TECHNIC_LARGE_LINEAR_MOTOR"; + DeviceType[DeviceType["TECHNIC_XLARGE_LINEAR_MOTOR"] = 47] = "TECHNIC_XLARGE_LINEAR_MOTOR"; + DeviceType[DeviceType["TECHNIC_MEDIUM_ANGULAR_MOTOR"] = 48] = "TECHNIC_MEDIUM_ANGULAR_MOTOR"; + DeviceType[DeviceType["TECHNIC_LARGE_ANGULAR_MOTOR"] = 49] = "TECHNIC_LARGE_ANGULAR_MOTOR"; + DeviceType[DeviceType["TECHNIC_MEDIUM_HUB_GEST_SENSOR"] = 54] = "TECHNIC_MEDIUM_HUB_GEST_SENSOR"; + DeviceType[DeviceType["REMOTE_CONTROL_BUTTON"] = 55] = "REMOTE_CONTROL_BUTTON"; + DeviceType[DeviceType["REMOTE_CONTROL_RSSI"] = 56] = "REMOTE_CONTROL_RSSI"; + DeviceType[DeviceType["TECHNIC_MEDIUM_HUB_ACCELEROMETER"] = 57] = "TECHNIC_MEDIUM_HUB_ACCELEROMETER"; + DeviceType[DeviceType["TECHNIC_MEDIUM_HUB_GYRO_SENSOR"] = 58] = "TECHNIC_MEDIUM_HUB_GYRO_SENSOR"; + DeviceType[DeviceType["TECHNIC_MEDIUM_HUB_TILT_SENSOR"] = 59] = "TECHNIC_MEDIUM_HUB_TILT_SENSOR"; + DeviceType[DeviceType["TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR"] = 60] = "TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR"; + DeviceType[DeviceType["TECHNIC_COLOR_SENSOR"] = 61] = "TECHNIC_COLOR_SENSOR"; + DeviceType[DeviceType["TECHNIC_DISTANCE_SENSOR"] = 62] = "TECHNIC_DISTANCE_SENSOR"; + DeviceType[DeviceType["TECHNIC_FORCE_SENSOR"] = 63] = "TECHNIC_FORCE_SENSOR"; // Spike Prime })(DeviceType = exports.DeviceType || (exports.DeviceType = {})); // tslint:disable-next-line exports.DeviceTypeNames = DeviceType; @@ -206,12 +214,22 @@ exports.ColorNames = Color; */ var ButtonState; (function (ButtonState) { - ButtonState[ButtonState["PRESSED"] = 0] = "PRESSED"; - ButtonState[ButtonState["RELEASED"] = 1] = "RELEASED"; - ButtonState[ButtonState["UP"] = 2] = "UP"; - ButtonState[ButtonState["DOWN"] = 3] = "DOWN"; - ButtonState[ButtonState["STOP"] = 4] = "STOP"; + ButtonState[ButtonState["PRESSED"] = 2] = "PRESSED"; + ButtonState[ButtonState["RELEASED"] = 0] = "RELEASED"; + ButtonState[ButtonState["UP"] = 1] = "UP"; + ButtonState[ButtonState["DOWN"] = 255] = "DOWN"; + ButtonState[ButtonState["STOP"] = 127] = "STOP"; })(ButtonState = exports.ButtonState || (exports.ButtonState = {})); +/** + * @typedef BrakingStyle + * @property {number} HOLD 127 + * @property {number} BRAKE 128 + */ +var BrakingStyle; +(function (BrakingStyle) { + BrakingStyle[BrakingStyle["HOLD"] = 127] = "HOLD"; + BrakingStyle[BrakingStyle["BRAKE"] = 128] = "BRAKE"; +})(BrakingStyle = exports.BrakingStyle || (exports.BrakingStyle = {})); /** * @typedef DuploTrainBaseSound * @property {number} BRAKE 3 @@ -230,11 +248,11 @@ var DuploTrainBaseSound; })(DuploTrainBaseSound = exports.DuploTrainBaseSound || (exports.DuploTrainBaseSound = {})); var BLEManufacturerData; (function (BLEManufacturerData) { - BLEManufacturerData[BLEManufacturerData["DUPLO_TRAIN_HUB_ID"] = 32] = "DUPLO_TRAIN_HUB_ID"; - BLEManufacturerData[BLEManufacturerData["BOOST_MOVE_HUB_ID"] = 64] = "BOOST_MOVE_HUB_ID"; - BLEManufacturerData[BLEManufacturerData["POWERED_UP_HUB_ID"] = 65] = "POWERED_UP_HUB_ID"; - BLEManufacturerData[BLEManufacturerData["POWERED_UP_REMOTE_ID"] = 66] = "POWERED_UP_REMOTE_ID"; - BLEManufacturerData[BLEManufacturerData["CONTROL_PLUS_LARGE_HUB"] = 128] = "CONTROL_PLUS_LARGE_HUB"; + BLEManufacturerData[BLEManufacturerData["DUPLO_TRAIN_BASE_ID"] = 32] = "DUPLO_TRAIN_BASE_ID"; + BLEManufacturerData[BLEManufacturerData["MOVE_HUB_ID"] = 64] = "MOVE_HUB_ID"; + BLEManufacturerData[BLEManufacturerData["HUB_ID"] = 65] = "HUB_ID"; + BLEManufacturerData[BLEManufacturerData["REMOTE_CONTROL_ID"] = 66] = "REMOTE_CONTROL_ID"; + BLEManufacturerData[BLEManufacturerData["TECHNIC_MEDIUM_HUB"] = 128] = "TECHNIC_MEDIUM_HUB"; })(BLEManufacturerData = exports.BLEManufacturerData || (exports.BLEManufacturerData = {})); var BLEService; (function (BLEService) { @@ -307,7 +325,7 @@ var BLECharacteristic; Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Fri Feb 7th 2020 using the DocStrap template. diff --git a/docs/controlplushub.js.html b/docs/controlplushub.js.html index ab3961e..3d31560 100644 --- a/docs/controlplushub.js.html +++ b/docs/controlplushub.js.html @@ -40,7 +40,7 @@ @@ -108,15 +108,18 @@ class ControlPlusHub extends lpf2hub_1.LPF2Hub { constructor(device, autoSubscribe = true) { super(device, autoSubscribe); this._currentPort = 0x3b; + this._currentMaxMA = 4175; this._voltagePort = 0x3c; this._voltageMaxRaw = 4095; + this._voltageMaxV = 9.615; this.type = Consts.HubType.CONTROL_PLUS_HUB; this._ports = { "A": new port_1.Port("A", 0), "B": new port_1.Port("B", 1), "C": new port_1.Port("C", 2), "D": new port_1.Port("D", 3), - "ACCEL": new port_1.Port("ACCEL", 98), + "ACCEL": new port_1.Port("ACCEL", 97), + "GYRO": new port_1.Port("GYRO", 98), "TILT": new port_1.Port("TILT", 99) }; this.on("attach", (port, type) => { @@ -414,7 +417,7 @@ exports.ControlPlusHub = ControlPlusHub; Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Tue Dec 3rd 2019 using the DocStrap template. diff --git a/docs/devices_absolutemotor.js.html b/docs/devices_absolutemotor.js.html new file mode 100644 index 0000000..86e00e8 --- /dev/null +++ b/docs/devices_absolutemotor.js.html @@ -0,0 +1,301 @@ + + + + + + + node-poweredup Source: devices/absolutemotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/absolutemotor.js

+ +
+
+
"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 tachomotor_1 = require("./tachomotor");
+const Consts = __importStar(require("../consts"));
+const utils_1 = require("../utils");
+/**
+ * @class AbsoluteMotor
+ * @extends TachoMotor
+ */
+class AbsoluteMotor extends tachomotor_1.TachoMotor {
+    constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.UNKNOWN) {
+        super(hub, portId, Object.assign({}, modeMap, exports.ModeMap), type);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.ABSOLUTE:
+                const angle = utils_1.normalizeAngle(message.readInt16LE(this.isWeDo2SmartHub ? 2 : 4));
+                /**
+                 * Emits when a the motors absolute position is changed.
+                 * @event AbsoluteMotor#absolute
+                 * @type {object}
+                 * @param {number} absolute
+                 */
+                this.notify("absolute", { angle });
+                break;
+            default:
+                super.receive(message);
+                break;
+        }
+    }
+    /**
+     * Rotate a motor by a given angle.
+     * @method AbsoluteMotor#gotoAngle
+     * @param {number} angle Absolute position the motor should go to (degrees from 0).
+     * @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
+     * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+     */
+    gotoAngle(angle, speed = 100) {
+        if (!this.isVirtualPort && angle instanceof Array) {
+            throw new Error("Only virtual ports can accept multiple positions");
+        }
+        if (this.isWeDo2SmartHub) {
+            throw new Error("Absolute positioning is not available on the WeDo 2.0 Smart Hub");
+        }
+        this.cancelEventTimer();
+        return new Promise((resolve) => {
+            this._busy = true;
+            if (speed === undefined || speed === null) {
+                speed = 100;
+            }
+            let message;
+            if (angle instanceof Array) {
+                message = Buffer.from([0x81, this.portId, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
+                message.writeInt32LE(utils_1.normalizeAngle(angle[0]), 4);
+                message.writeInt32LE(utils_1.normalizeAngle(angle[1]), 8);
+            }
+            else {
+                message = Buffer.from([0x81, this.portId, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
+                message.writeInt32LE(utils_1.normalizeAngle(angle), 4);
+            }
+            this.send(message);
+            this._finished = () => {
+                return resolve();
+            };
+        });
+    }
+}
+exports.AbsoluteMotor = AbsoluteMotor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["ROTATION"] = 2] = "ROTATION";
+    Mode[Mode["ABSOLUTE"] = 3] = "ABSOLUTE";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "rotate": Mode.ROTATION,
+    "absolute": Mode.ABSOLUTE
+};
+//# sourceMappingURL=absolutemotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_basicmotor.js.html b/docs/devices_basicmotor.js.html new file mode 100644 index 0000000..33943d4 --- /dev/null +++ b/docs/devices_basicmotor.js.html @@ -0,0 +1,289 @@ + + + + + + + node-poweredup Source: devices/basicmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/basicmotor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+const utils_1 = require("../utils");
+/**
+ * @class BasicMotor
+ * @extends Device
+ */
+class BasicMotor extends device_1.Device {
+    constructor(hub, portId, modeMap, type = Consts.DeviceType.UNKNOWN) {
+        super(hub, portId, modeMap, type);
+    }
+    /**
+     * Set the motor power.
+     * @method BasicMotor#setPower
+     * @param {number} power For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    setPower(power, interrupt = true) {
+        if (interrupt) {
+            this.cancelEventTimer();
+        }
+        return new Promise((resolve) => {
+            this.writeDirect(0x00, Buffer.from([utils_1.mapSpeed(power)]));
+            return resolve();
+        });
+    }
+    /**
+     * Ramp the motor power.
+     * @method BasicMotor#rampPower
+     * @param {number} fromPower For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+     * @param {number} toPower 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.
+     */
+    rampPower(fromPower, toPower, time) {
+        this.cancelEventTimer();
+        return new Promise((resolve) => {
+            utils_1.calculateRamp(this, fromPower, toPower, time)
+                .on("changePower", (power) => {
+                this.setPower(power, false);
+            })
+                .on("finished", resolve);
+        });
+    }
+    /**
+     * Stop the motor.
+     * @method BasicMotor#stop
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    stop() {
+        this.cancelEventTimer();
+        return this.setPower(0);
+    }
+    /**
+     * Brake the motor.
+     * @method BasicMotor#brake
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    brake() {
+        this.cancelEventTimer();
+        return this.setPower(Consts.BrakingStyle.BRAKE);
+    }
+}
+exports.BasicMotor = BasicMotor;
+//# sourceMappingURL=basicmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_colordistancesensor.js.html b/docs/devices_colordistancesensor.js.html new file mode 100644 index 0000000..f4afb81 --- /dev/null +++ b/docs/devices_colordistancesensor.js.html @@ -0,0 +1,302 @@ + + + + + + + node-poweredup Source: devices/colordistancesensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/colordistancesensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class ColorDistanceSensor
+ * @extends Device
+ */
+class ColorDistanceSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.COLOR_DISTANCE_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.COLOR:
+                if (message[this.isWeDo2SmartHub ? 2 : 4] <= 10) {
+                    const color = message[this.isWeDo2SmartHub ? 2 : 4];
+                    /**
+                     * Emits when a color sensor is activated.
+                     * @event ColorDistanceSensor#color
+                     * @type {object}
+                     * @param {Color} color
+                     */
+                    this.notify("color", { color });
+                }
+                break;
+            case Mode.DISTANCE:
+                if (this.isWeDo2SmartHub) {
+                    break;
+                }
+                if (message[4] <= 10) {
+                    const distance = Math.floor(message[4] * 25.4) - 20;
+                    /**
+                     * Emits when a distance sensor is activated.
+                     * @event ColorDistanceSensor#distance
+                     * @type {object}
+                     * @param {number} distance Distance, in millimeters.
+                     */
+                    this.notify("distance", { distance });
+                }
+                break;
+            case Mode.COLOR_AND_DISTANCE:
+                if (this.isWeDo2SmartHub) {
+                    break;
+                }
+                let distance = message[5];
+                const partial = message[7];
+                if (partial > 0) {
+                    distance += 1.0 / partial;
+                }
+                distance = Math.floor(distance * 25.4) - 20;
+                /**
+                 * A combined color and distance event, emits when the sensor is activated.
+                 * @event ColorDistanceSensor#colorAndDistance
+                 * @type {object}
+                 * @param {Color} color
+                 * @param {number} distance Distance, in millimeters.
+                 */
+                if (message[4] <= 10) {
+                    const color = message[4];
+                    this.notify("colorAndDistance", { color, distance });
+                }
+                break;
+        }
+    }
+}
+exports.ColorDistanceSensor = ColorDistanceSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["COLOR"] = 0] = "COLOR";
+    Mode[Mode["DISTANCE"] = 1] = "DISTANCE";
+    Mode[Mode["COLOR_AND_DISTANCE"] = 8] = "COLOR_AND_DISTANCE";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "color": Mode.COLOR,
+    "distance": Mode.DISTANCE,
+    "colorAndDistance": Mode.COLOR_AND_DISTANCE
+};
+//# sourceMappingURL=colordistancesensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_currentsensor.js.html b/docs/devices_currentsensor.js.html new file mode 100644 index 0000000..d03a2ad --- /dev/null +++ b/docs/devices_currentsensor.js.html @@ -0,0 +1,280 @@ + + + + + + + node-poweredup Source: devices/currentsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/currentsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class CurrentSensor
+ * @extends Device
+ */
+class CurrentSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.CURRENT_SENSOR);
+    }
+    receive(message) {
+        const mode = this.mode;
+        switch (mode) {
+            case Mode.CURRENT:
+                if (this.isWeDo2SmartHub) {
+                    const current = message.readInt16LE(2) / 1000;
+                    this.notify("current", { current });
+                }
+                else {
+                    let maxCurrentValue = MaxCurrentValue[this.hub.type];
+                    if (maxCurrentValue === undefined) {
+                        maxCurrentValue = MaxCurrentValue[Consts.HubType.UNKNOWN];
+                    }
+                    let maxCurrentRaw = MaxCurrentRaw[this.hub.type];
+                    if (maxCurrentRaw === undefined) {
+                        maxCurrentRaw = MaxCurrentRaw[Consts.HubType.UNKNOWN];
+                    }
+                    const current = message.readUInt16LE(4) * maxCurrentValue / maxCurrentRaw;
+                    /**
+                     * Emits when a current change is detected.
+                     * @event CurrentSensor#current
+                     * @type {object}
+                     * @param {number} current
+                     */
+                    this.notify("current", { current });
+                }
+                break;
+        }
+    }
+}
+exports.CurrentSensor = CurrentSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["CURRENT"] = 0] = "CURRENT";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "current": Mode.CURRENT
+};
+const MaxCurrentValue = {
+    [Consts.HubType.UNKNOWN]: 2444,
+    [Consts.HubType.TECHNIC_MEDIUM_HUB]: 4175,
+};
+const MaxCurrentRaw = {
+    [Consts.HubType.UNKNOWN]: 4095,
+};
+//# sourceMappingURL=currentsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_device.js.html b/docs/devices_device.js.html new file mode 100644 index 0000000..29459d1 --- /dev/null +++ b/docs/devices_device.js.html @@ -0,0 +1,379 @@ + + + + + + + node-poweredup Source: devices/device.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/device.js

+ +
+
+
"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 events_1 = require("events");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class Device
+ * @extends EventEmitter
+ */
+class Device extends events_1.EventEmitter {
+    constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.UNKNOWN) {
+        super();
+        this.autoSubscribe = true;
+        this.values = {};
+        this._busy = false;
+        this._connected = true;
+        this._modeMap = {};
+        this._isVirtualPort = false;
+        this._eventTimer = null;
+        this._hub = hub;
+        this._portId = portId;
+        this._type = type;
+        this._modeMap = modeMap;
+        this._isWeDo2SmartHub = (this.hub.type === Consts.HubType.WEDO2_SMART_HUB);
+        this._isVirtualPort = this.hub.isPortVirtual(portId);
+        const eventAttachListener = (event) => {
+            if (event === "detach") {
+                return;
+            }
+            if (this.autoSubscribe) {
+                if (this._modeMap[event] !== undefined) {
+                    this.subscribe(this._modeMap[event]);
+                }
+            }
+        };
+        const deviceDetachListener = (device) => {
+            if (device.portId === this.portId) {
+                this._connected = false;
+                this.hub.removeListener("detach", deviceDetachListener);
+                this.emit("detach");
+            }
+        };
+        for (const event in this._modeMap) {
+            if (this.hub.listenerCount(event) > 0) {
+                eventAttachListener(event);
+            }
+        }
+        this.hub.on("newListener", eventAttachListener);
+        this.on("newListener", eventAttachListener);
+        this.hub.on("detach", deviceDetachListener);
+    }
+    /**
+     * @readonly
+     * @property {boolean} connected Check if the device is still attached.
+     */
+    get connected() {
+        return this._connected;
+    }
+    /**
+     * @readonly
+     * @property {Hub} hub The Hub the device is attached to.
+     */
+    get hub() {
+        return this._hub;
+    }
+    get portId() {
+        return this._portId;
+    }
+    /**
+     * @readonly
+     * @property {string} portName The port the device is attached to.
+     */
+    get portName() {
+        return this.hub.getPortNameForPortId(this.portId);
+    }
+    /**
+     * @readonly
+     * @property {number} type The type of the device
+     */
+    get type() {
+        return this._type;
+    }
+    get typeName() {
+        return Consts.DeviceTypeNames[this.type];
+    }
+    /**
+     * @readonly
+     * @property {number} mode The mode the device is currently in
+     */
+    get mode() {
+        return this._mode;
+    }
+    get isWeDo2SmartHub() {
+        return this._isWeDo2SmartHub;
+    }
+    /**
+     * @readonly
+     * @property {boolean} isVirtualPort Is this device attached to a virtual port (ie. a combined device)
+     */
+    get isVirtualPort() {
+        return this._isVirtualPort;
+    }
+    writeDirect(mode, data, callback) {
+        if (this.isWeDo2SmartHub) {
+            this.send(Buffer.concat([Buffer.from([this.portId, 0x01, 0x02]), data]), Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
+        }
+        else {
+            this.send(Buffer.concat([Buffer.from([0x81, this.portId, 0x11, 0x51, mode]), data]), Consts.BLECharacteristic.LPF2_ALL, callback);
+        }
+    }
+    send(data, characteristic = Consts.BLECharacteristic.LPF2_ALL, callback) {
+        this._ensureConnected();
+        this.hub.send(data, characteristic, callback);
+    }
+    subscribe(mode) {
+        this._ensureConnected();
+        if (mode !== this._mode) {
+            this._mode = mode;
+            this.hub.subscribe(this.portId, this.type, mode);
+        }
+    }
+    unsubscribe(mode) {
+        this._ensureConnected();
+    }
+    receive(message) {
+        this.notify("receive", { message });
+    }
+    notify(event, values) {
+        this.values[event] = values;
+        this.emit(event, values);
+        if (this.hub.listenerCount(event) > 0) {
+            this.hub.emit(event, this, values);
+        }
+    }
+    finish() {
+        this._busy = false;
+        if (this._finished) {
+            this._finished();
+            this._finished = undefined;
+        }
+    }
+    setEventTimer(timer) {
+        this._eventTimer = timer;
+    }
+    cancelEventTimer() {
+        if (this._eventTimer) {
+            clearTimeout(this._eventTimer);
+            this._eventTimer = null;
+        }
+    }
+    _ensureConnected() {
+        if (!this.connected) {
+            throw new Error("Device is not connected");
+        }
+    }
+}
+exports.Device = Device;
+//# sourceMappingURL=device.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_duplotrainbasecolorsensor.js.html b/docs/devices_duplotrainbasecolorsensor.js.html new file mode 100644 index 0000000..78076a8 --- /dev/null +++ b/docs/devices_duplotrainbasecolorsensor.js.html @@ -0,0 +1,289 @@ + + + + + + + node-poweredup Source: devices/duplotrainbasecolorsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/duplotrainbasecolorsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class DuploTrainBaseColorSensor
+ * @extends Device
+ */
+class DuploTrainBaseColorSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.COLOR:
+                if (message[4] <= 10) {
+                    const color = message[4];
+                    /**
+                     * Emits when a color sensor is activated.
+                     * @event DuploTrainBaseColorSensor#color
+                     * @type {object}
+                     * @param {Color} color
+                     */
+                    this.notify("color", { color });
+                }
+                break;
+            case Mode.REFLECTIVITY:
+                const reflect = message[4];
+                /**
+                 * Emits when the light reflectivity changes.
+                 * @event DuploTrainBaseColorSensor#reflect
+                 * @type {object}
+                 * @param {number} reflect Percentage, from 0 to 100.
+                 */
+                this.notify("reflect", { reflect });
+                break;
+            case Mode.RGB:
+                const red = Math.floor(message.readUInt16LE(4) / 4);
+                const green = Math.floor(message.readUInt16LE(6) / 4);
+                const blue = Math.floor(message.readUInt16LE(8) / 4);
+                /**
+                 * Emits when the light reflectivity changes.
+                 * @event DuploTrainBaseColorSensor#rgb
+                 * @type {object}
+                 * @param {number} red
+                 * @param {number} green
+                 * @param {number} blue
+                 */
+                this.notify("rgb", { red, green, blue });
+                break;
+        }
+    }
+}
+exports.DuploTrainBaseColorSensor = DuploTrainBaseColorSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["COLOR"] = 0] = "COLOR";
+    Mode[Mode["REFLECTIVITY"] = 2] = "REFLECTIVITY";
+    Mode[Mode["RGB"] = 3] = "RGB";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "color": Mode.COLOR,
+    "reflect": Mode.REFLECTIVITY,
+    "rgb": Mode.RGB
+};
+//# sourceMappingURL=duplotrainbasecolorsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_duplotrainbasemotor.js.html b/docs/devices_duplotrainbasemotor.js.html new file mode 100644 index 0000000..67d83c4 --- /dev/null +++ b/docs/devices_duplotrainbasemotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/duplotrainbasemotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/duplotrainbasemotor.js

+ +
+
+
"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 basicmotor_1 = require("./basicmotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class DuploTrainBaseMotor
+ * @extends BasicMotor
+ */
+class DuploTrainBaseMotor extends basicmotor_1.BasicMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.DUPLO_TRAIN_BASE_MOTOR);
+    }
+}
+exports.DuploTrainBaseMotor = DuploTrainBaseMotor;
+//# sourceMappingURL=duplotrainbasemotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_duplotrainbasespeaker.js.html b/docs/devices_duplotrainbasespeaker.js.html new file mode 100644 index 0000000..842cfdc --- /dev/null +++ b/docs/devices_duplotrainbasespeaker.js.html @@ -0,0 +1,265 @@ + + + + + + + node-poweredup Source: devices/duplotrainbasespeaker.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/duplotrainbasespeaker.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class DuploTrainBaseSpeaker
+ * @extends Device
+ */
+class DuploTrainBaseSpeaker extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.DUPLO_TRAIN_BASE_SPEAKER);
+    }
+    /**
+     * Play a built-in train sound.
+     * @method DuploTrainBaseSpeaker#playSound
+     * @param {DuploTrainBaseSound} sound
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    playSound(sound) {
+        return new Promise((resolve, reject) => {
+            this.subscribe(Mode.SOUND);
+            this.writeDirect(0x01, Buffer.from([sound]));
+            return resolve();
+        });
+    }
+    /**
+     * Play a built-in system tone.
+     * @method DuploTrainBaseSpeaker#playTone
+     * @param {number} tone
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    playTone(tone) {
+        this.subscribe(Mode.TONE);
+        this.writeDirect(0x02, Buffer.from([tone]));
+    }
+}
+exports.DuploTrainBaseSpeaker = DuploTrainBaseSpeaker;
+var Mode;
+(function (Mode) {
+    Mode[Mode["SOUND"] = 1] = "SOUND";
+    Mode[Mode["TONE"] = 2] = "TONE";
+})(Mode = exports.Mode || (exports.Mode = {}));
+//# sourceMappingURL=duplotrainbasespeaker.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_duplotrainbasespeedometer.js.html b/docs/devices_duplotrainbasespeedometer.js.html new file mode 100644 index 0000000..7dcd78c --- /dev/null +++ b/docs/devices_duplotrainbasespeedometer.js.html @@ -0,0 +1,259 @@ + + + + + + + node-poweredup Source: devices/duplotrainbasespeedometer.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/duplotrainbasespeedometer.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class DuploTraniBaseSpeedometer
+ * @extends Device
+ */
+class DuploTrainBaseSpeedometer extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.SPEED:
+                const speed = message.readInt16LE(4);
+                /**
+                 * Emits on a speed change.
+                 * @event DuploTrainBaseSpeedometer#speed
+                 * @type {object}
+                 * @param {number} speed
+                 */
+                this.notify("speed", { speed });
+                break;
+        }
+    }
+}
+exports.DuploTrainBaseSpeedometer = DuploTrainBaseSpeedometer;
+var Mode;
+(function (Mode) {
+    Mode[Mode["SPEED"] = 0] = "SPEED";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "speed": Mode.SPEED
+};
+//# sourceMappingURL=duplotrainbasespeedometer.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_hubled.js.html b/docs/devices_hubled.js.html new file mode 100644 index 0000000..8e2cfa7 --- /dev/null +++ b/docs/devices_hubled.js.html @@ -0,0 +1,285 @@ + + + + + + + node-poweredup Source: devices/hubled.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/hubled.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class HubLED
+ * @extends Device
+ */
+class HubLED extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.HUB_LED);
+    }
+    /**
+     * Set the color of the LED on the Hub via a color value.
+     * @method HubLED#setColor
+     * @param {Color} color
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    setColor(color) {
+        return new Promise((resolve, reject) => {
+            if (typeof color === "boolean") {
+                color = 0;
+            }
+            if (this.isWeDo2SmartHub) {
+                this.send(Buffer.from([0x06, 0x17, 0x01, 0x01]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
+                this.send(Buffer.from([0x06, 0x04, 0x01, color]), Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
+            }
+            else {
+                this.subscribe(Mode.COLOR);
+                this.writeDirect(0x00, Buffer.from([color]));
+            }
+            return resolve();
+        });
+    }
+    /**
+     * Set the color of the LED on the Hub via RGB values.
+     * @method HubLED#setRGB
+     * @param {number} red
+     * @param {number} green
+     * @param {number} blue
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    setRGB(red, green, blue) {
+        return new Promise((resolve, reject) => {
+            if (this.isWeDo2SmartHub) {
+                this.send(Buffer.from([0x06, 0x17, 0x01, 0x02]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
+                this.send(Buffer.from([0x06, 0x04, 0x03, red, green, blue]), Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
+            }
+            else {
+                this.subscribe(Mode.RGB);
+                this.writeDirect(0x01, Buffer.from([red, green, blue]));
+            }
+            return resolve();
+        });
+    }
+}
+exports.HubLED = HubLED;
+var Mode;
+(function (Mode) {
+    Mode[Mode["COLOR"] = 0] = "COLOR";
+    Mode[Mode["RGB"] = 1] = "RGB";
+})(Mode = exports.Mode || (exports.Mode = {}));
+//# sourceMappingURL=hubled.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_light.js.html b/docs/devices_light.js.html new file mode 100644 index 0000000..2a28e4a --- /dev/null +++ b/docs/devices_light.js.html @@ -0,0 +1,271 @@ + + + + + + + node-poweredup Source: devices/light.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/light.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+const utils_1 = require("../utils");
+/**
+ * @class Light
+ * @extends Device
+ */
+class Light extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.LIGHT);
+    }
+    /**
+     * Set the light brightness.
+     * @method Light#setBrightness
+     * @param {number} brightness Brightness value between 0-100 (0 is off)
+     * @returns {Promise} Resolved upon successful completion of command.
+     */
+    setBrightness(brightness, interrupt = true) {
+        if (interrupt) {
+            this.cancelEventTimer();
+        }
+        return new Promise((resolve) => {
+            this.writeDirect(0x00, Buffer.from([brightness]));
+            return resolve();
+        });
+    }
+    /**
+     * Ramp the light brightness.
+     * @method Light#rampBrightness
+     * @param {number} fromBrightness Brightness value between 0-100 (0 is off)
+     * @param {number} toBrightness Brightness value between 0-100 (0 is off)
+     * @param {number} time How long the ramp should last (in milliseconds).
+     * @returns {Promise} Resolved upon successful completion of command.
+     */
+    rampBrightness(fromBrightness, toBrightness, time) {
+        this.cancelEventTimer();
+        return new Promise((resolve) => {
+            utils_1.calculateRamp(this, fromBrightness, toBrightness, time)
+                .on("changePower", (power) => {
+                this.setBrightness(power, false);
+            })
+                .on("finished", resolve);
+        });
+    }
+}
+exports.Light = Light;
+//# sourceMappingURL=light.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_mediumlinearmotor.js.html b/docs/devices_mediumlinearmotor.js.html new file mode 100644 index 0000000..c7fe1d7 --- /dev/null +++ b/docs/devices_mediumlinearmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/mediumlinearmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/mediumlinearmotor.js

+ +
+
+
"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 tachomotor_1 = require("./tachomotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class MediumLinearMotor
+ * @extends TachoMotor
+ */
+class MediumLinearMotor extends tachomotor_1.TachoMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.MEDIUM_LINEAR_MOTOR);
+    }
+}
+exports.MediumLinearMotor = MediumLinearMotor;
+//# sourceMappingURL=mediumlinearmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_motionsensor.js.html b/docs/devices_motionsensor.js.html new file mode 100644 index 0000000..28ef61a --- /dev/null +++ b/docs/devices_motionsensor.js.html @@ -0,0 +1,263 @@ + + + + + + + node-poweredup Source: devices/motionsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/motionsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class MotionSensor
+ * @extends Device
+ */
+class MotionSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.MOTION_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.DISTANCE:
+                let distance = message[this.isWeDo2SmartHub ? 2 : 4];
+                if (message[this.isWeDo2SmartHub ? 3 : 5] === 1) {
+                    distance = distance + 255;
+                }
+                distance *= 10;
+                /**
+                 * Emits when a distance sensor is activated.
+                 * @event MotionSensor#distance
+                 * @type {object}
+                 * @param {number} distance Distance, in millimeters.
+                 */
+                this.notify("distance", { distance });
+                break;
+        }
+    }
+}
+exports.MotionSensor = MotionSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["DISTANCE"] = 0] = "DISTANCE";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "distance": Mode.DISTANCE
+};
+//# sourceMappingURL=motionsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_movehubmediumlinearmotor.js.html b/docs/devices_movehubmediumlinearmotor.js.html new file mode 100644 index 0000000..bae7f27 --- /dev/null +++ b/docs/devices_movehubmediumlinearmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/movehubmediumlinearmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/movehubmediumlinearmotor.js

+ +
+
+
"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 tachomotor_1 = require("./tachomotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class MoveHubMediumLinearMotor
+ * @extends TachoMotor
+ */
+class MoveHubMediumLinearMotor extends tachomotor_1.TachoMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR);
+    }
+}
+exports.MoveHubMediumLinearMotor = MoveHubMediumLinearMotor;
+//# sourceMappingURL=movehubmediumlinearmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_movehubtiltsensor.js.html b/docs/devices_movehubtiltsensor.js.html new file mode 100644 index 0000000..7dfe5f4 --- /dev/null +++ b/docs/devices_movehubtiltsensor.js.html @@ -0,0 +1,261 @@ + + + + + + + node-poweredup Source: devices/movehubtiltsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/movehubtiltsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class MoveHubTiltSensor
+ * @extends Device
+ */
+class MoveHubTiltSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.MOVE_HUB_TILT_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.TILT:
+                /**
+                 * Emits when a tilt sensor is activated.
+                 * @event MoveHubTiltSensor#tilt
+                 * @type {object}
+                 * @param {number} x
+                 * @param {number} y
+                 */
+                const x = -message.readInt8(4);
+                const y = message.readInt8(5);
+                this.notify("tilt", { x, y });
+                break;
+        }
+    }
+}
+exports.MoveHubTiltSensor = MoveHubTiltSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["TILT"] = 0] = "TILT";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "tilt": Mode.TILT
+};
+//# sourceMappingURL=movehubtiltsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_piezobuzzer.js.html b/docs/devices_piezobuzzer.js.html new file mode 100644 index 0000000..c94232f --- /dev/null +++ b/docs/devices_piezobuzzer.js.html @@ -0,0 +1,253 @@ + + + + + + + node-poweredup Source: devices/piezobuzzer.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/piezobuzzer.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class PiezoBuzzer
+ * @extends Device
+ */
+class PiezoBuzzer extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.PIEZO_BUZZER);
+    }
+    /**
+     * Play a tone on the Hub's in-built buzzer
+     * @method PiezoBuzzer#playTone
+     * @param {number} frequency
+     * @param {number} time How long the tone should play for (in milliseconds).
+     * @returns {Promise} Resolved upon successful completion of command (ie. once the tone has finished playing).
+     */
+    playTone(frequency, time) {
+        return new Promise((resolve) => {
+            const data = Buffer.from([0x05, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00]);
+            data.writeUInt16LE(frequency, 3);
+            data.writeUInt16LE(time, 5);
+            this.send(data, Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
+            global.setTimeout(resolve, time);
+        });
+    }
+}
+exports.PiezoBuzzer = PiezoBuzzer;
+//# sourceMappingURL=piezobuzzer.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_remotecontrolbutton.js.html b/docs/devices_remotecontrolbutton.js.html new file mode 100644 index 0000000..b9fefad --- /dev/null +++ b/docs/devices_remotecontrolbutton.js.html @@ -0,0 +1,265 @@ + + + + + + + node-poweredup Source: devices/remotecontrolbutton.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/remotecontrolbutton.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class RemoteControlButton
+ * @extends Device
+ */
+class RemoteControlButton extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.REMOTE_CONTROL_BUTTON);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.BUTTON_EVENTS:
+                /**
+                 * Emits when a button on the remote is pressed or released.
+                 * @event RemoteControlButton#button
+                 * @type {object}
+                 * @param {number} event
+                 */
+                const event = message[4];
+                this.notify("remoteButton", { event });
+                break;
+        }
+    }
+}
+exports.RemoteControlButton = RemoteControlButton;
+var Mode;
+(function (Mode) {
+    Mode[Mode["BUTTON_EVENTS"] = 0] = "BUTTON_EVENTS";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "remoteButton": Mode.BUTTON_EVENTS
+};
+exports.ButtonState = {
+    "UP": 0x01,
+    "DOWN": 0xff,
+    "STOP": 0x7f,
+    "RELEASED": 0x00,
+};
+//# sourceMappingURL=remotecontrolbutton.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_simplemediumlinearmotor.js.html b/docs/devices_simplemediumlinearmotor.js.html new file mode 100644 index 0000000..aca97f7 --- /dev/null +++ b/docs/devices_simplemediumlinearmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/simplemediumlinearmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/simplemediumlinearmotor.js

+ +
+
+
"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 basicmotor_1 = require("./basicmotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class SimpleMediumLinearMotor
+ * @extends Device
+ */
+class SimpleMediumLinearMotor extends basicmotor_1.BasicMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR);
+    }
+}
+exports.SimpleMediumLinearMotor = SimpleMediumLinearMotor;
+//# sourceMappingURL=simplemediumlinearmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_tachomotor.js.html b/docs/devices_tachomotor.js.html new file mode 100644 index 0000000..cc35032 --- /dev/null +++ b/docs/devices_tachomotor.js.html @@ -0,0 +1,348 @@ + + + + + + + node-poweredup Source: devices/tachomotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/tachomotor.js

+ +
+
+
"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 basicmotor_1 = require("./basicmotor");
+const Consts = __importStar(require("../consts"));
+const utils_1 = require("../utils");
+/**
+ * @class TachoMotor
+ * @extends BasicMotor
+ */
+class TachoMotor extends basicmotor_1.BasicMotor {
+    constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.UNKNOWN) {
+        super(hub, portId, Object.assign({}, modeMap, exports.ModeMap), type);
+        this._brakeStyle = Consts.BrakingStyle.BRAKE;
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.ROTATION:
+                const degrees = message.readInt32LE(this.isWeDo2SmartHub ? 2 : 4);
+                /**
+                 * Emits when a rotation sensor is activated.
+                 * @event TachoMotor#rotate
+                 * @type {object}
+                 * @param {number} rotation
+                 */
+                this.notify("rotate", { degrees });
+                break;
+        }
+    }
+    /**
+     * Set the braking style of the motor.
+     *
+     * Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.
+     * @method TachoMotor#setBrakingStyle
+     * @param {number} style Either BRAKE or HOLD
+     */
+    setBrakingStyle(style) {
+        this._brakeStyle = style;
+    }
+    /**
+     * Set the motor speed.
+     * @method TachoMotor#setSpeed
+     * @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    setSpeed(speed, time) {
+        if (!this.isVirtualPort && speed instanceof Array) {
+            throw new Error("Only virtual ports can accept multiple speeds");
+        }
+        if (this.isWeDo2SmartHub) {
+            throw new Error("Motor speed is not available on the WeDo 2.0 Smart Hub");
+        }
+        this.cancelEventTimer();
+        return new Promise((resolve) => {
+            this._busy = true;
+            if (speed === undefined || speed === null) {
+                speed = 100;
+            }
+            let message;
+            if (time !== undefined) {
+                if (speed instanceof Array) {
+                    message = Buffer.from([0x81, this.portId, 0x11, 0x0a, 0x00, 0x00, utils_1.mapSpeed(speed[0]), utils_1.mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x00]);
+                }
+                else {
+                    message = Buffer.from([0x81, this.portId, 0x11, 0x09, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
+                }
+                message.writeUInt16LE(time, 4);
+            }
+            else {
+                if (speed instanceof Array) {
+                    message = Buffer.from([0x81, this.portId, 0x11, 0x08, utils_1.mapSpeed(speed[0]), utils_1.mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x00]);
+                }
+                else {
+                    message = Buffer.from([0x81, this.portId, 0x11, 0x07, utils_1.mapSpeed(speed), 0x64, 0x03, 0x64, this._brakeStyle, 0x00]);
+                }
+            }
+            this.send(message);
+            this._finished = () => {
+                return resolve();
+            };
+        });
+    }
+    /**
+     * Rotate a motor by a given amount of degrees.
+     * @method TachoMotor#rotateByDegrees
+     * @param {number} degrees How much the motor should be rotated (in degrees).
+     * @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
+     * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+     */
+    rotateByDegrees(degrees, speed) {
+        if (!this.isVirtualPort && speed instanceof Array) {
+            throw new Error("Only virtual ports can accept multiple speeds");
+        }
+        if (this.isWeDo2SmartHub) {
+            throw new Error("Rotation is not available on the WeDo 2.0 Smart Hub");
+        }
+        this.cancelEventTimer();
+        return new Promise((resolve) => {
+            this._busy = true;
+            if (speed === undefined || speed === null) {
+                speed = 100;
+            }
+            let message;
+            if (speed instanceof Array) {
+                message = Buffer.from([0x81, this.portId, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed[0]), utils_1.mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x03]);
+            }
+            else {
+                message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x03]);
+            }
+            message.writeUInt32LE(degrees, 4);
+            this.send(message);
+            this._finished = () => {
+                return resolve();
+            };
+        });
+    }
+}
+exports.TachoMotor = TachoMotor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["ROTATION"] = 2] = "ROTATION";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "rotate": Mode.ROTATION
+};
+//# sourceMappingURL=tachomotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_techniccolorsensor.js.html b/docs/devices_techniccolorsensor.js.html new file mode 100644 index 0000000..c11d85e --- /dev/null +++ b/docs/devices_techniccolorsensor.js.html @@ -0,0 +1,285 @@ + + + + + + + node-poweredup Source: devices/techniccolorsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/techniccolorsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicColorSensor
+ * @extends Device
+ */
+class TechnicColorSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_COLOR_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.COLOR:
+                if (message[4] <= 10) {
+                    const color = message[4];
+                    /**
+                     * Emits when a color sensor is activated.
+                     * @event TechnicColorSensor#color
+                     * @type {object}
+                     * @param {Color} color
+                     */
+                    this.notify("color", { color });
+                }
+                break;
+            case Mode.REFLECTIVITY:
+                const reflect = message[4];
+                /**
+                 * Emits when the light reflectivity changes.
+                 * @event TechnicColorSensor#reflect
+                 * @type {object}
+                 * @param {number} reflect Percentage, from 0 to 100.
+                 */
+                this.notify("reflect", { reflect });
+                break;
+            case Mode.AMBIENT_LIGHT:
+                const ambient = message[4];
+                /**
+                 * Emits when the ambient light changes.
+                 * @event TechnicColorSensor#ambient
+                 * @type {object}
+                 * @param {number} ambient Percentage, from 0 to 100.
+                 */
+                this.notify("ambient", { ambient });
+                break;
+        }
+    }
+}
+exports.TechnicColorSensor = TechnicColorSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["COLOR"] = 0] = "COLOR";
+    Mode[Mode["REFLECTIVITY"] = 1] = "REFLECTIVITY";
+    Mode[Mode["AMBIENT_LIGHT"] = 2] = "AMBIENT_LIGHT";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "color": Mode.COLOR,
+    "reflect": Mode.REFLECTIVITY,
+    "ambient": Mode.AMBIENT_LIGHT
+};
+//# sourceMappingURL=techniccolorsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicdistancesensor.js.html b/docs/devices_technicdistancesensor.js.html new file mode 100644 index 0000000..f496ce4 --- /dev/null +++ b/docs/devices_technicdistancesensor.js.html @@ -0,0 +1,283 @@ + + + + + + + node-poweredup Source: devices/technicdistancesensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicdistancesensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicDistanceSensor
+ * @extends Device
+ */
+class TechnicDistanceSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_DISTANCE_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.DISTANCE:
+                const distance = message.readUInt16LE(4);
+                /**
+                 * Emits when the detected distance changes (Slow sampling covers 40mm to 2500mm).
+                 * @event TechnicDistanceSensor#distance
+                 * @type {object}
+                 * @param {number} distance Distance, from 40 to 2500mm
+                 */
+                this.notify("distance", { distance });
+                break;
+            case Mode.FAST_DISTANCE:
+                const fastDistance = message.readUInt16LE(4);
+                /**
+                 * Emits when the detected distance changes (Fast sampling covers 50mm to 320mm).
+                 * @event TechnicDistanceSensor#fastDistance
+                 * @type {object}
+                 * @param {number} fastDistance Distance, from 50 to 320mm
+                 */
+                this.notify("fastDistance", { fastDistance });
+                break;
+        }
+    }
+    /**
+     * Set the brightness (or turn on/off) the lights around the eyes.
+     * @method TechnicDistanceSensor#setBrightness
+     * @param {number} topLeft Top left quadrant (above left eye). 0-100 brightness.
+     * @param {number} bottomLeft Bottom left quadrant (below left eye). 0-100 brightness.
+     * @param {number} topRight Top right quadrant (above right eye). 0-100 brightness.
+     * @param {number} bottomRight Bottom right quadrant (below right eye). 0-100 brightness.
+     * @returns {Promise} Resolved upon successful issuance of the command.
+     */
+    setBrightness(topLeft, bottomLeft, topRight, bottomRight) {
+        this.writeDirect(0x05, Buffer.from([topLeft, topRight, bottomLeft, bottomRight]));
+    }
+}
+exports.TechnicDistanceSensor = TechnicDistanceSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["DISTANCE"] = 0] = "DISTANCE";
+    Mode[Mode["FAST_DISTANCE"] = 1] = "FAST_DISTANCE";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "distance": Mode.DISTANCE,
+    "fastDistance": Mode.FAST_DISTANCE
+};
+//# sourceMappingURL=technicdistancesensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicforcesensor.js.html b/docs/devices_technicforcesensor.js.html new file mode 100644 index 0000000..7717df7 --- /dev/null +++ b/docs/devices_technicforcesensor.js.html @@ -0,0 +1,283 @@ + + + + + + + node-poweredup Source: devices/technicforcesensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicforcesensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicForceSensor
+ * @extends Device
+ */
+class TechnicForceSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_FORCE_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.FORCE:
+                const force = message[4] / 10;
+                /**
+                 * Emits when force is applied.
+                 * @event TechnicForceSensor#force
+                 * @type {object}
+                 * @param {number} force Force, in newtons (0-10).
+                 */
+                this.notify("force", { force });
+                break;
+            case Mode.TOUCHED:
+                const touched = message[4] ? true : false;
+                /**
+                 * Emits when the sensor is touched.
+                 * @event TechnicForceSensor#touch
+                 * @type {object}
+                 * @param {boolean} touch Touched on/off (boolean).
+                 */
+                this.notify("touched", { touched });
+                break;
+            case Mode.TAPPED:
+                const tapped = message[4];
+                /**
+                 * Emits when the sensor is tapped.
+                 * @event TechnicForceSensor#tapped
+                 * @type {object}
+                 * @param {number} tapped How hard the sensor was tapped, from 0-3.
+                 */
+                this.notify("tapped", { tapped });
+                break;
+        }
+    }
+}
+exports.TechnicForceSensor = TechnicForceSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["FORCE"] = 0] = "FORCE";
+    Mode[Mode["TOUCHED"] = 1] = "TOUCHED";
+    Mode[Mode["TAPPED"] = 2] = "TAPPED";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "force": Mode.FORCE,
+    "touched": Mode.TOUCHED,
+    "tapped": Mode.TAPPED
+};
+//# sourceMappingURL=technicforcesensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_techniclargeangularmotor.js.html b/docs/devices_techniclargeangularmotor.js.html new file mode 100644 index 0000000..4496b5e --- /dev/null +++ b/docs/devices_techniclargeangularmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/techniclargeangularmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/techniclargeangularmotor.js

+ +
+
+
"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 absolutemotor_1 = require("./absolutemotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicLargeAngularMotor
+ * @extends AbsoluteMotor
+ */
+class TechnicLargeAngularMotor extends absolutemotor_1.AbsoluteMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR);
+    }
+}
+exports.TechnicLargeAngularMotor = TechnicLargeAngularMotor;
+//# sourceMappingURL=techniclargeangularmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_techniclargelinearmotor.js.html b/docs/devices_techniclargelinearmotor.js.html new file mode 100644 index 0000000..66bf54b --- /dev/null +++ b/docs/devices_techniclargelinearmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/techniclargelinearmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/techniclargelinearmotor.js

+ +
+
+
"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 absolutemotor_1 = require("./absolutemotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicLargeLinearMotor
+ * @extends AbsoluteMotor
+ */
+class TechnicLargeLinearMotor extends absolutemotor_1.AbsoluteMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR);
+    }
+}
+exports.TechnicLargeLinearMotor = TechnicLargeLinearMotor;
+//# sourceMappingURL=techniclargelinearmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicmediumangularmotor.js.html b/docs/devices_technicmediumangularmotor.js.html new file mode 100644 index 0000000..29b1c09 --- /dev/null +++ b/docs/devices_technicmediumangularmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/technicmediumangularmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicmediumangularmotor.js

+ +
+
+
"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 absolutemotor_1 = require("./absolutemotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicMediumAngularMotor
+ * @extends AbsoluteMotor
+ */
+class TechnicMediumAngularMotor extends absolutemotor_1.AbsoluteMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR);
+    }
+}
+exports.TechnicMediumAngularMotor = TechnicMediumAngularMotor;
+//# sourceMappingURL=technicmediumangularmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicmediumhubaccelerometersensor.js.html b/docs/devices_technicmediumhubaccelerometersensor.js.html new file mode 100644 index 0000000..78f1415 --- /dev/null +++ b/docs/devices_technicmediumhubaccelerometersensor.js.html @@ -0,0 +1,263 @@ + + + + + + + node-poweredup Source: devices/technicmediumhubaccelerometersensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicmediumhubaccelerometersensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicMediumHubAccelerometerSensor
+ * @extends Device
+ */
+class TechnicMediumHubAccelerometerSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.ACCEL:
+                /**
+                 * Emits when accelerometer detects movement. Measured in mG.
+                 * @event TechnicMediumHubAccelerometerSensor#accel
+                 * @type {object}
+                 * @param {number} x
+                 * @param {number} y
+                 * @param {number} z
+                 */
+                const x = Math.round(message.readInt16LE(4) / 4.096);
+                const y = Math.round(message.readInt16LE(6) / 4.096);
+                const z = Math.round(message.readInt16LE(8) / 4.096);
+                this.notify("accel", { x, y, z });
+                break;
+        }
+    }
+}
+exports.TechnicMediumHubAccelerometerSensor = TechnicMediumHubAccelerometerSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["ACCEL"] = 0] = "ACCEL";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "accel": Mode.ACCEL
+};
+//# sourceMappingURL=technicmediumhubaccelerometersensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicmediumhubgyrosensor.js.html b/docs/devices_technicmediumhubgyrosensor.js.html new file mode 100644 index 0000000..df5c560 --- /dev/null +++ b/docs/devices_technicmediumhubgyrosensor.js.html @@ -0,0 +1,263 @@ + + + + + + + node-poweredup Source: devices/technicmediumhubgyrosensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicmediumhubgyrosensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicMediumHubGyroSensor
+ * @extends Device
+ */
+class TechnicMediumHubGyroSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.GYRO:
+                /**
+                 * Emits when gyroscope detects movement. Measured in DPS - degrees per second.
+                 * @event TechnicMediumHubGyroSensor#gyro
+                 * @type {object}
+                 * @param {number} x
+                 * @param {number} y
+                 * @param {number} z
+                 */
+                const x = Math.round(message.readInt16LE(4) * 7 / 400);
+                const y = Math.round(message.readInt16LE(6) * 7 / 400);
+                const z = Math.round(message.readInt16LE(8) * 7 / 400);
+                this.notify("gyro", { x, y, z });
+                break;
+        }
+    }
+}
+exports.TechnicMediumHubGyroSensor = TechnicMediumHubGyroSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["GYRO"] = 0] = "GYRO";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "gyro": Mode.GYRO
+};
+//# sourceMappingURL=technicmediumhubgyrosensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicmediumhubtiltsensor.js.html b/docs/devices_technicmediumhubtiltsensor.js.html new file mode 100644 index 0000000..6a6b01b --- /dev/null +++ b/docs/devices_technicmediumhubtiltsensor.js.html @@ -0,0 +1,263 @@ + + + + + + + node-poweredup Source: devices/technicmediumhubtiltsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicmediumhubtiltsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicMediumHubTiltSensor
+ * @extends Device
+ */
+class TechnicMediumHubTiltSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.TILT:
+                /**
+                 * Emits when a tilt sensor is activated.
+                 * @event TechnicMediumHubTiltSensor#tilt
+                 * @type {object}
+                 * @param {number} x
+                 * @param {number} y
+                 * @param {number} z
+                 */
+                const z = -message.readInt16LE(4);
+                const y = message.readInt16LE(6);
+                const x = message.readInt16LE(8);
+                this.notify("tilt", { x, y, z });
+                break;
+        }
+    }
+}
+exports.TechnicMediumHubTiltSensor = TechnicMediumHubTiltSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["TILT"] = 0] = "TILT";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "tilt": Mode.TILT
+};
+//# sourceMappingURL=technicmediumhubtiltsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_technicxlargelinearmotor.js.html b/docs/devices_technicxlargelinearmotor.js.html new file mode 100644 index 0000000..69c2baf --- /dev/null +++ b/docs/devices_technicxlargelinearmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/technicxlargelinearmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/technicxlargelinearmotor.js

+ +
+
+
"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 absolutemotor_1 = require("./absolutemotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TechnicXLargeLinearMotor
+ * @extends AbsoluteMotor
+ */
+class TechnicXLargeLinearMotor extends absolutemotor_1.AbsoluteMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR);
+    }
+}
+exports.TechnicXLargeLinearMotor = TechnicXLargeLinearMotor;
+//# sourceMappingURL=technicxlargelinearmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_tiltsensor.js.html b/docs/devices_tiltsensor.js.html new file mode 100644 index 0000000..e5a40c1 --- /dev/null +++ b/docs/devices_tiltsensor.js.html @@ -0,0 +1,261 @@ + + + + + + + node-poweredup Source: devices/tiltsensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/tiltsensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TiltSensor
+ * @extends Device
+ */
+class TiltSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.TILT_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.TILT:
+                const x = message.readInt8(this.isWeDo2SmartHub ? 2 : 4);
+                const y = message.readInt8(this.isWeDo2SmartHub ? 3 : 5);
+                /**
+                 * Emits when a tilt sensor is activated.
+                 * @event TiltSensor#tilt
+                 * @type {object}
+                 * @param {number} x
+                 * @param {number} y
+                 */
+                this.notify("tilt", { x, y });
+                break;
+        }
+    }
+}
+exports.TiltSensor = TiltSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["TILT"] = 0] = "TILT";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "tilt": Mode.TILT
+};
+//# sourceMappingURL=tiltsensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_trainmotor.js.html b/docs/devices_trainmotor.js.html new file mode 100644 index 0000000..499a7ad --- /dev/null +++ b/docs/devices_trainmotor.js.html @@ -0,0 +1,237 @@ + + + + + + + node-poweredup Source: devices/trainmotor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/trainmotor.js

+ +
+
+
"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 basicmotor_1 = require("./basicmotor");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class TrainMotor
+ * @extends BasicMotor
+ */
+class TrainMotor extends basicmotor_1.BasicMotor {
+    constructor(hub, portId) {
+        super(hub, portId, {}, Consts.DeviceType.TRAIN_MOTOR);
+    }
+}
+exports.TrainMotor = TrainMotor;
+//# sourceMappingURL=trainmotor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/devices_voltagesensor.js.html b/docs/devices_voltagesensor.js.html new file mode 100644 index 0000000..ec04501 --- /dev/null +++ b/docs/devices_voltagesensor.js.html @@ -0,0 +1,284 @@ + + + + + + + node-poweredup Source: devices/voltagesensor.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: devices/voltagesensor.js

+ +
+
+
"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 device_1 = require("./device");
+const Consts = __importStar(require("../consts"));
+/**
+ * @class VoltageSensor
+ * @extends Device
+ */
+class VoltageSensor extends device_1.Device {
+    constructor(hub, portId) {
+        super(hub, portId, exports.ModeMap, Consts.DeviceType.VOLTAGE_SENSOR);
+    }
+    receive(message) {
+        const mode = this._mode;
+        switch (mode) {
+            case Mode.VOLTAGE:
+                if (this.isWeDo2SmartHub) {
+                    const voltage = message.readInt16LE(2) / 40;
+                    this.notify("voltage", { voltage });
+                }
+                else {
+                    let maxVoltageValue = MaxVoltageValue[this.hub.type];
+                    if (maxVoltageValue === undefined) {
+                        maxVoltageValue = MaxVoltageValue[Consts.HubType.UNKNOWN];
+                    }
+                    let maxVoltageRaw = MaxVoltageRaw[this.hub.type];
+                    if (maxVoltageRaw === undefined) {
+                        maxVoltageRaw = MaxVoltageRaw[Consts.HubType.UNKNOWN];
+                    }
+                    const voltage = message.readUInt16LE(4) * maxVoltageValue / maxVoltageRaw;
+                    /**
+                     * Emits when a voltage change is detected.
+                     * @event VoltageSensor#voltage
+                     * @type {object}
+                     * @param {number} voltage
+                     */
+                    this.notify("voltage", { voltage });
+                }
+                break;
+        }
+    }
+}
+exports.VoltageSensor = VoltageSensor;
+var Mode;
+(function (Mode) {
+    Mode[Mode["VOLTAGE"] = 0] = "VOLTAGE";
+})(Mode = exports.Mode || (exports.Mode = {}));
+exports.ModeMap = {
+    "voltage": Mode.VOLTAGE
+};
+const MaxVoltageValue = {
+    [Consts.HubType.UNKNOWN]: 9.615,
+    [Consts.HubType.DUPLO_TRAIN_BASE]: 6.4,
+    [Consts.HubType.REMOTE_CONTROL]: 6.4,
+};
+const MaxVoltageRaw = {
+    [Consts.HubType.UNKNOWN]: 3893,
+    [Consts.HubType.DUPLO_TRAIN_BASE]: 3047,
+    [Consts.HubType.REMOTE_CONTROL]: 3200,
+    [Consts.HubType.TECHNIC_MEDIUM_HUB]: 4095,
+};
+//# sourceMappingURL=voltagesensor.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + +
+ + + + node-poweredup by Nathan Kellenicki licensed under the MIT license. + + + + Documentation generated by JSDoc 3.6.3 + + on Mon Feb 24th 2020 + + using the DocStrap template. + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/duplotrainbase.js.html b/docs/duplotrainbase.js.html index 45a3553..a5a8eea 100644 --- a/docs/duplotrainbase.js.html +++ b/docs/duplotrainbase.js.html @@ -40,7 +40,7 @@ @@ -262,7 +262,7 @@ exports.DuploTrainBase = DuploTrainBase; Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Tue Dec 3rd 2019 using the DocStrap template. diff --git a/docs/global.html b/docs/global.html index 87b9672..2d215b1 100644 --- a/docs/global.html +++ b/docs/global.html @@ -33,14 +33,14 @@ @@ -161,8 +161,8 @@

-
-

ButtonState

+
+

BrakingStyle

@@ -201,7 +201,7 @@ - PRESSED + HOLD @@ -218,14 +218,14 @@ -

0

+

127

- RELEASED + BRAKE @@ -242,79 +242,7 @@ -

1

- - - - - - - UP - - - - - -number - - - - - - - - - - -

2

- - - - - - - DOWN - - - - - -number - - - - - - - - - - -

3

- - - - - - - STOP - - - - - -number - - - - - - - - - - -

4

+

128

@@ -356,7 +284,150 @@ +
+ + + + + + + + + + + + + + + +
+
+

BrakingStyle

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
HOLD + + +number + + + + +

127

BRAKE + + +number + + + + +

128

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -571,7 +642,222 @@ +
+ + + + + + + + + + + + + + + +
+
+

ButtonState

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
PRESSED + + +number + + + + +

0

RELEASED + + +number + + + + +

1

UP + + +number + + + + +

2

DOWN + + +number + + + + +

3

STOP + + +number + + + + +

4

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -954,7 +1240,7 @@
@@ -1337,7 +1623,7 @@ @@ -1421,7 +1707,7 @@ - BASIC_MOTOR + SIMPLE_MEDIUM_LINEAR_MOTOR @@ -1637,7 +1923,7 @@ - BOOST_DISTANCE + COLOR_DISTANCE_SENSOR @@ -1661,7 +1947,7 @@ - BOOST_TACHO_MOTOR + MEDIUM_LINEAR_MOTOR @@ -1685,7 +1971,7 @@ - BOOST_MOVE_HUB_MOTOR + MOVE_HUB_MEDIUM_LINEAR_MOTOR @@ -2092,7 +2378,7 @@ - BASIC_MOTOR + SIMPLE_MEDIUM_LINEAR_MOTOR @@ -2308,7 +2594,7 @@ - BOOST_DISTANCE + COLOR_DISTANCE_SENSOR @@ -2332,7 +2618,7 @@ - BOOST_TACHO_MOTOR + MEDIUM_LINEAR_MOTOR @@ -2356,7 +2642,7 @@ - BOOST_MOVE_HUB_MOTOR + MOVE_HUB_MEDIUM_LINEAR_MOTOR @@ -2894,7 +3180,7 @@ @@ -3109,7 +3395,7 @@ @@ -3217,7 +3503,7 @@ - BOOST_MOVE_HUB + MOVE_HUB @@ -3480,7 +3766,7 @@ - BOOST_MOVE_HUB + MOVE_HUB @@ -3704,7 +3990,7 @@ Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Fri Feb 7th 2020 using the DocStrap template. diff --git a/docs/hub.js.html b/docs/hub.js.html index 3f5f9ef..8d0fa15 100644 --- a/docs/hub.js.html +++ b/docs/hub.js.html @@ -40,7 +40,7 @@ @@ -122,6 +122,10 @@ class Hub extends events_1.EventEmitter { this.autoSubscribe = !!autoSubscribe; this._bleDevice = device; device.on("disconnect", () => { + /** + * Emits when the hub is disconnected. + * @event Hub#disconnect + */ this.emit("disconnect"); }); } @@ -315,14 +319,14 @@ class Hub extends events_1.EventEmitter { port.type = type; if (this.autoSubscribe) { this._activatePortDevice(port.value, type, this._getModeForDeviceType(type), 0x00); - /** - * Emits when a motor or sensor is attached to the Hub. - * @event Hub#attach - * @param {string} port - * @param {DeviceType} type - */ - this.emit("attach", port.id, type); } + /** + * Emits when a motor or sensor is attached to the Hub. + * @event Hub#attach + * @param {string} port + * @param {DeviceType} type + */ + this.emit("attach", port.id, type); } else { port.type = Consts.DeviceType.UNKNOWN; @@ -477,7 +481,7 @@ exports.Hub = Hub; Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Tue Dec 3rd 2019 using the DocStrap template. diff --git a/docs/hubs_basehub.js.html b/docs/hubs_basehub.js.html new file mode 100644 index 0000000..2df9b5f --- /dev/null +++ b/docs/hubs_basehub.js.html @@ -0,0 +1,576 @@ + + + + + + + node-poweredup Source: hubs/basehub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/basehub.js

+ +
+
+
"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 events_1 = require("events");
+const colordistancesensor_1 = require("../devices/colordistancesensor");
+const currentsensor_1 = require("../devices/currentsensor");
+const device_1 = require("../devices/device");
+const duplotrainbasecolorsensor_1 = require("../devices/duplotrainbasecolorsensor");
+const duplotrainbasemotor_1 = require("../devices/duplotrainbasemotor");
+const duplotrainbasespeaker_1 = require("../devices/duplotrainbasespeaker");
+const duplotrainbasespeedometer_1 = require("../devices/duplotrainbasespeedometer");
+const hubled_1 = require("../devices/hubled");
+const light_1 = require("../devices/light");
+const mediumlinearmotor_1 = require("../devices/mediumlinearmotor");
+const motionsensor_1 = require("../devices/motionsensor");
+const movehubmediumlinearmotor_1 = require("../devices/movehubmediumlinearmotor");
+const movehubtiltsensor_1 = require("../devices/movehubtiltsensor");
+const piezobuzzer_1 = require("../devices/piezobuzzer");
+const remotecontrolbutton_1 = require("../devices/remotecontrolbutton");
+const simplemediumlinearmotor_1 = require("../devices/simplemediumlinearmotor");
+const techniccolorsensor_1 = require("../devices/techniccolorsensor");
+const technicdistancesensor_1 = require("../devices/technicdistancesensor");
+const technicforcesensor_1 = require("../devices/technicforcesensor");
+const techniclargeangularmotor_1 = require("../devices/techniclargeangularmotor");
+const techniclargelinearmotor_1 = require("../devices/techniclargelinearmotor");
+const technicmediumangularmotor_1 = require("../devices/technicmediumangularmotor");
+const technicmediumhubaccelerometersensor_1 = require("../devices/technicmediumhubaccelerometersensor");
+const technicmediumhubgyrosensor_1 = require("../devices/technicmediumhubgyrosensor");
+const technicmediumhubtiltsensor_1 = require("../devices/technicmediumhubtiltsensor");
+const technicxlargelinearmotor_1 = require("../devices/technicxlargelinearmotor");
+const tiltsensor_1 = require("../devices/tiltsensor");
+const trainmotor_1 = require("../devices/trainmotor");
+const voltagesensor_1 = require("../devices/voltagesensor");
+const Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("basehub");
+/**
+ * @class BaseHub
+ * @extends EventEmitter
+ */
+class BaseHub extends events_1.EventEmitter {
+    constructor(bleDevice, portMap = {}, type = Consts.HubType.UNKNOWN) {
+        super();
+        this._attachedDevices = {};
+        this._name = "";
+        this._firmwareVersion = "0.0.00.0000";
+        this._hardwareVersion = "0.0.00.0000";
+        this._primaryMACAddress = "00:00:00:00:00:00";
+        this._batteryLevel = 100;
+        this._rssi = -60;
+        this._portMap = {};
+        this._virtualPorts = [];
+        this._attachCallbacks = [];
+        this.setMaxListeners(23); // Technic Medium Hub has 9 built in devices + 4 external ports. Node.js throws a warning after 10 attached event listeners.
+        this._type = type;
+        this._bleDevice = bleDevice;
+        this._portMap = Object.assign({}, portMap);
+        bleDevice.on("disconnect", () => {
+            /**
+             * Emits when the hub is disconnected.
+             * @event Hub#disconnect
+             */
+            this.emit("disconnect");
+        });
+    }
+    /**
+     * @readonly
+     * @property {string} name Name of the hub
+     */
+    get name() {
+        return this._bleDevice.name;
+    }
+    /**
+     * @readonly
+     * @property {string} type Hub type
+     */
+    get type() {
+        return this._type;
+    }
+    /**
+     * @readonly
+     * @property {string[]} ports Array of port names
+     */
+    get ports() {
+        return Object.keys(this._portMap);
+    }
+    /**
+     * @readonly
+     * @property {string} firmwareVersion Firmware version of the hub
+     */
+    get firmwareVersion() {
+        return this._firmwareVersion;
+    }
+    /**
+     * @readonly
+     * @property {string} hardwareVersion Hardware version of the hub
+     */
+    get hardwareVersion() {
+        return this._hardwareVersion;
+    }
+    /**
+     * @readonly
+     * @property {string} primaryMACAddress Primary MAC address of the hub
+     */
+    get primaryMACAddress() {
+        return this._primaryMACAddress;
+    }
+    /**
+     * @readonly
+     * @property {string} uuid UUID of the hub
+     */
+    get uuid() {
+        return this._bleDevice.uuid;
+    }
+    /**
+     * @readonly
+     * @property {number} batteryLevel Battery level of the hub (Percentage between 0-100)
+     */
+    get batteryLevel() {
+        return this._batteryLevel;
+    }
+    /**
+     * @readonly
+     * @property {number} rssi Signal strength of the hub
+     */
+    get rssi() {
+        return this._rssi;
+    }
+    /**
+     * Connect to the Hub.
+     * @method Hub#connect
+     * @returns {Promise} Resolved upon successful connect.
+     */
+    connect() {
+        return new Promise(async (connectResolve, connectReject) => {
+            if (this._bleDevice.connecting) {
+                return connectReject("Already connecting");
+            }
+            else if (this._bleDevice.connected) {
+                return connectReject("Already connected");
+            }
+            await this._bleDevice.connect();
+            return connectResolve();
+        });
+    }
+    /**
+     * Disconnect the Hub.
+     * @method Hub#disconnect
+     * @returns {Promise} Resolved upon successful disconnect.
+     */
+    disconnect() {
+        return this._bleDevice.disconnect();
+    }
+    /**
+     * Retrieves the device attached to a given port.
+     * @method Hub#getDeviceAtPort
+     * @param {string} portName The name of the port to retrieve the device from.
+     * @returns {Device | undefined} The device attached to the port.
+     */
+    getDeviceAtPort(portName) {
+        const portId = this._portMap[portName];
+        if (portId !== undefined) {
+            return this._attachedDevices[portId];
+        }
+        else {
+            return undefined;
+        }
+    }
+    /**
+     * Retrieves the device attached to a given port, waiting until one is attached if there isn't one.
+     *
+     * Note: If a device is never attached, the returned promise may never resolve.
+     * @method Hub#waitForDeviceAtPort
+     * @param {string} portName The name of the port to retrieve the device from.
+     * @returns {Promise} Resolved once a device is attached, or resolved immediately if a device is already attached.
+     */
+    waitForDeviceAtPort(portName) {
+        return new Promise((resolve) => {
+            const existingDevice = this.getDeviceAtPort(portName);
+            if (existingDevice) {
+                return resolve(existingDevice);
+            }
+            this._attachCallbacks.push((device) => {
+                if (device.portName === portName) {
+                    resolve(device);
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            });
+        });
+    }
+    /**
+     * Retrieves all attached devices.
+     * @method Hub#getDevices
+     * @returns {Device[]} Array of all attached devices.
+     */
+    getDevices() {
+        return Object.values(this._attachedDevices);
+    }
+    /**
+     * Retrieves an array of devices of the specified type.
+     * @method Hub#getDevicesByType
+     * @param {number} deviceType The device type to lookup.
+     * @returns {Device[]} Array of all devices of the specified type.
+     */
+    getDevicesByType(deviceType) {
+        return this.getDevices().filter((device) => device.type === deviceType);
+    }
+    /**
+     * Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.
+     *
+     * Note: If a device is never attached, the returned promise may never resolve.
+     * @method Hub#waitForDeviceByType
+     * @param {number} deviceType The device type to lookup.
+     * @returns {Promise} Resolved once a device is attached, or resolved immediately if a device is already attached.
+     */
+    waitForDeviceByType(deviceType) {
+        return new Promise((resolve) => {
+            const existingDevices = this.getDevicesByType(deviceType);
+            if (existingDevices.length >= 1) {
+                return resolve(existingDevices[0]);
+            }
+            this._attachCallbacks.push((device) => {
+                if (device.type === deviceType) {
+                    resolve(device);
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            });
+        });
+    }
+    getPortNameForPortId(portId) {
+        for (const port of Object.keys(this._portMap)) {
+            if (this._portMap[port] === portId) {
+                return port;
+            }
+        }
+        return;
+    }
+    isPortVirtual(portId) {
+        return (this._virtualPorts.indexOf(portId) > -1);
+    }
+    /**
+     * Sleep a given amount of time.
+     *
+     * Note: This is a helper method to make it easier to add delays into a chain of commands.
+     * @method Hub#sleep
+     * @param {number} delay How long to sleep (in milliseconds).
+     * @returns {Promise} Resolved after the delay is finished.
+     */
+    sleep(delay) {
+        return new Promise((resolve) => {
+            global.setTimeout(resolve, delay);
+        });
+    }
+    /**
+     * Wait until a given list of concurrently running commands are complete.
+     *
+     * Note: This is a helper method to make it easier to wait for concurrent commands to complete.
+     * @method Hub#wait
+     * @param {Array<Promise<any>>} commands Array of executing commands.
+     * @returns {Promise} Resolved after the commands are finished.
+     */
+    wait(commands) {
+        return Promise.all(commands);
+    }
+    send(message, uuid, callback) {
+        if (callback) {
+            callback();
+        }
+    }
+    subscribe(portId, deviceType, mode) {
+        // NK Do nothing here
+    }
+    unsubscribe(portId, deviceType, mode) {
+        // NK Do nothing here
+    }
+    _attachDevice(device) {
+        this._attachedDevices[device.portId] = device;
+        /**
+         * Emits when a device is attached to the Hub.
+         * @event Hub#attach
+         * @param {Device} device
+         */
+        this.emit("attach", device);
+        debug(`Attached device type ${device.type} (${Consts.DeviceTypeNames[device.type]}) on port ${device.portName} (${device.portId})`);
+        let i = this._attachCallbacks.length;
+        while (i--) {
+            const callback = this._attachCallbacks[i];
+            if (callback(device)) {
+                this._attachCallbacks.splice(i, 1);
+            }
+        }
+    }
+    _detachDevice(device) {
+        delete this._attachedDevices[device.portId];
+        /**
+         * Emits when a device is detached from the Hub.
+         * @event Hub#detach
+         * @param {Device} device
+         */
+        this.emit("detach", device);
+        debug(`Detached device type ${device.type} (${Consts.DeviceTypeNames[device.type]}) on port ${device.portName} (${device.portId})`);
+    }
+    _createDevice(deviceType, portId) {
+        let constructor;
+        // NK TODO: This needs to go in a better place
+        const deviceConstructors = {
+            [Consts.DeviceType.LIGHT]: light_1.Light,
+            [Consts.DeviceType.TRAIN_MOTOR]: trainmotor_1.TrainMotor,
+            [Consts.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR]: simplemediumlinearmotor_1.SimpleMediumLinearMotor,
+            [Consts.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR]: movehubmediumlinearmotor_1.MoveHubMediumLinearMotor,
+            [Consts.DeviceType.MOTION_SENSOR]: motionsensor_1.MotionSensor,
+            [Consts.DeviceType.TILT_SENSOR]: tiltsensor_1.TiltSensor,
+            [Consts.DeviceType.MOVE_HUB_TILT_SENSOR]: movehubtiltsensor_1.MoveHubTiltSensor,
+            [Consts.DeviceType.PIEZO_BUZZER]: piezobuzzer_1.PiezoBuzzer,
+            [Consts.DeviceType.TECHNIC_COLOR_SENSOR]: techniccolorsensor_1.TechnicColorSensor,
+            [Consts.DeviceType.TECHNIC_DISTANCE_SENSOR]: technicdistancesensor_1.TechnicDistanceSensor,
+            [Consts.DeviceType.TECHNIC_FORCE_SENSOR]: technicforcesensor_1.TechnicForceSensor,
+            [Consts.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR]: technicmediumhubtiltsensor_1.TechnicMediumHubTiltSensor,
+            [Consts.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR]: technicmediumhubgyrosensor_1.TechnicMediumHubGyroSensor,
+            [Consts.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER]: technicmediumhubaccelerometersensor_1.TechnicMediumHubAccelerometerSensor,
+            [Consts.DeviceType.MEDIUM_LINEAR_MOTOR]: mediumlinearmotor_1.MediumLinearMotor,
+            [Consts.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR]: technicmediumangularmotor_1.TechnicMediumAngularMotor,
+            [Consts.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR]: techniclargeangularmotor_1.TechnicLargeAngularMotor,
+            [Consts.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR]: techniclargelinearmotor_1.TechnicLargeLinearMotor,
+            [Consts.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR]: technicxlargelinearmotor_1.TechnicXLargeLinearMotor,
+            [Consts.DeviceType.COLOR_DISTANCE_SENSOR]: colordistancesensor_1.ColorDistanceSensor,
+            [Consts.DeviceType.VOLTAGE_SENSOR]: voltagesensor_1.VoltageSensor,
+            [Consts.DeviceType.CURRENT_SENSOR]: currentsensor_1.CurrentSensor,
+            [Consts.DeviceType.REMOTE_CONTROL_BUTTON]: remotecontrolbutton_1.RemoteControlButton,
+            [Consts.DeviceType.HUB_LED]: hubled_1.HubLED,
+            [Consts.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR]: duplotrainbasecolorsensor_1.DuploTrainBaseColorSensor,
+            [Consts.DeviceType.DUPLO_TRAIN_BASE_MOTOR]: duplotrainbasemotor_1.DuploTrainBaseMotor,
+            [Consts.DeviceType.DUPLO_TRAIN_BASE_SPEAKER]: duplotrainbasespeaker_1.DuploTrainBaseSpeaker,
+            [Consts.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER]: duplotrainbasespeedometer_1.DuploTrainBaseSpeedometer
+        };
+        constructor = deviceConstructors[deviceType];
+        if (constructor) {
+            return new constructor(this, portId);
+        }
+        else {
+            return new device_1.Device(this, portId, undefined, deviceType);
+        }
+    }
+    _getDeviceByPortId(portId) {
+        return this._attachedDevices[portId];
+    }
+}
+exports.BaseHub = BaseHub;
+//# sourceMappingURL=basehub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_boostmovehub.js.html b/docs/hubs_boostmovehub.js.html new file mode 100644 index 0000000..2c3b967 --- /dev/null +++ b/docs/hubs_boostmovehub.js.html @@ -0,0 +1,276 @@ + + + + + + + node-poweredup Source: hubs/boostmovehub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/boostmovehub.js

+ +
+
+
"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+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 compare_versions_1 = __importDefault(require("compare-versions"));
+const lpf2hub_1 = require("./lpf2hub");
+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 {
+    constructor(device) {
+        super(device, Consts.HubType.BOOST_MOVE_HUB);
+        this._currentPort = 0x3b;
+        this._voltagePort = 0x3c;
+        this._portNames = {
+            "A": 0,
+            "B": 1,
+            "C": 2,
+            "D": 3,
+            "TILT": 58
+        };
+        debug("Discovered Boost Move Hub");
+    }
+    static IsBoostMoveHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.BOOST_MOVE_HUB_ID);
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Boost Move Hub");
+            await super.connect();
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+    _checkFirmware(version) {
+        if (compare_versions_1.default("2.0.00.0017", version) === 1) {
+            throw new Error(`Your Boost Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
+        }
+    }
+}
+exports.BoostMoveHub = BoostMoveHub;
+//# sourceMappingURL=boostmovehub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_controlplushub.js.html b/docs/hubs_controlplushub.js.html new file mode 100644 index 0000000..fcb26cc --- /dev/null +++ b/docs/hubs_controlplushub.js.html @@ -0,0 +1,273 @@ + + + + + + + node-poweredup Source: hubs/controlplushub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/controlplushub.js

+ +
+
+
"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 Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("ControlPlusHub");
+/**
+ * The ControlPlusHub is emitted if the discovered device is a Control+ Hub.
+ * @class ControlPlusHub
+ * @extends LPF2Hub
+ * @extends Hub
+ */
+class ControlPlusHub extends lpf2hub_1.LPF2Hub {
+    constructor(device) {
+        super(device, Consts.HubType.CONTROL_PLUS_HUB);
+        this._currentPort = 0x3b;
+        this._currentMaxMA = 4175;
+        this._voltagePort = 0x3c;
+        this._voltageMaxRaw = 4095;
+        this._voltageMaxV = 9.615;
+        this._portNames = {
+            "A": 0,
+            "B": 1,
+            "C": 2,
+            "D": 3,
+            "ACCEL": 97,
+            "GYRO": 98,
+            "TILT": 99
+        };
+        debug("Discovered Control+ Hub");
+    }
+    static IsControlPlusHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.CONTROL_PLUS_LARGE_HUB);
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Control+ Hub");
+            await super.connect();
+            this.send(Buffer.from([0x41, 0x3d, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.LPF2_ALL); // Temperature
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+}
+exports.ControlPlusHub = ControlPlusHub;
+//# sourceMappingURL=controlplushub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_duplotrainbase.js.html b/docs/hubs_duplotrainbase.js.html new file mode 100644 index 0000000..71d68f5 --- /dev/null +++ b/docs/hubs_duplotrainbase.js.html @@ -0,0 +1,263 @@ + + + + + + + node-poweredup Source: hubs/duplotrainbase.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/duplotrainbase.js

+ +
+
+
"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 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 BaseHub
+ */
+class DuploTrainBase extends lpf2hub_1.LPF2Hub {
+    static IsDuploTrainBase(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_BASE_ID);
+    }
+    constructor(device) {
+        super(device, exports.PortMap, Consts.HubType.DUPLO_TRAIN_BASE);
+        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();
+        });
+    }
+}
+exports.DuploTrainBase = DuploTrainBase;
+exports.PortMap = {
+    "MOTOR": 0,
+    "COLOR": 18,
+    "SPEEDOMETER": 19
+};
+//# sourceMappingURL=duplotrainbase.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_hub.js.html b/docs/hubs_hub.js.html new file mode 100644 index 0000000..061d1dd --- /dev/null +++ b/docs/hubs_hub.js.html @@ -0,0 +1,275 @@ + + + + + + + node-poweredup Source: hubs/hub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/hub.js

+ +
+
+
"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+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 compare_versions_1 = __importDefault(require("compare-versions"));
+const lpf2hub_1 = require("./lpf2hub");
+const Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("hub");
+/**
+ * The Hub is emitted if the discovered device is a Hub.
+ * @class Hub
+ * @extends LPF2Hub
+ * @extends BaseHub
+ */
+class Hub extends lpf2hub_1.LPF2Hub {
+    constructor(device) {
+        super(device, exports.PortMap, Consts.HubType.HUB);
+        this._currentPort = 0x3b;
+        debug("Discovered Powered UP Hub");
+    }
+    static IsHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.HUB_ID);
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Powered UP Hub");
+            await super.connect();
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+    _checkFirmware(version) {
+        if (compare_versions_1.default("1.1.00.0004", version) === 1) {
+            throw new Error(`Your Powered Up Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
+        }
+    }
+}
+exports.Hub = Hub;
+exports.PortMap = {
+    "A": 0,
+    "B": 1,
+    "HUB_LED": 50,
+    "CURRENT_SENSOR": 59,
+    "VOLTAGE_SENSOR": 60
+};
+//# sourceMappingURL=hub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_lpf2hub.js.html b/docs/hubs_lpf2hub.js.html new file mode 100644 index 0000000..0189f19 --- /dev/null +++ b/docs/hubs_lpf2hub.js.html @@ -0,0 +1,561 @@ + + + + + + + node-poweredup Source: hubs/lpf2hub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/lpf2hub.js

+ +
+
+
"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 basehub_1 = require("./basehub");
+const Consts = __importStar(require("../consts"));
+const utils_1 = require("../utils");
+const Debug = require("debug");
+const debug = Debug("lpf2hub");
+const modeInfoDebug = Debug("lpf2hubmodeinfo");
+/**
+ * @class LPF2Hub
+ * @extends BaseHub
+ */
+class LPF2Hub extends basehub_1.BaseHub {
+    constructor() {
+        super(...arguments);
+        this._messageBuffer = Buffer.alloc(0);
+        this._propertyRequestCallbacks = {};
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("LPF2Hub connecting");
+            await super.connect();
+            await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.LPF2_HUB);
+            this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, this._parseMessage.bind(this));
+            await this.sleep(500);
+            this._requestHubPropertyReports(0x02); // Activate button reports
+            await this._requestHubPropertyValue(0x03); // Request firmware version
+            await this._requestHubPropertyValue(0x04); // Request hardware version
+            this._requestHubPropertyReports(0x05); // Activate RSSI updates
+            this._requestHubPropertyReports(0x06); // Activate battery level reports
+            await this._requestHubPropertyValue(0x0d); // Request primary MAC address
+            this.emit("connect");
+            debug("LPF2Hub connected");
+            resolve();
+        });
+    }
+    /**
+     * Shutdown the Hub.
+     * @method LPF2Hub#shutdown
+     * @returns {Promise} Resolved upon successful disconnect.
+     */
+    shutdown() {
+        return new Promise((resolve, reject) => {
+            this.send(Buffer.from([0x02, 0x01]), Consts.BLECharacteristic.LPF2_ALL, () => {
+                return resolve();
+            });
+        });
+    }
+    /**
+     * Set the name of the Hub.
+     * @method LPF2Hub#setName
+     * @param {string} name New name of the hub (14 characters or less, ASCII only).
+     * @returns {Promise} Resolved upon successful issuance of command.
+     */
+    setName(name) {
+        if (name.length > 14) {
+            throw new Error("Name must be 14 characters or less");
+        }
+        return new Promise((resolve, reject) => {
+            let data = Buffer.from([0x01, 0x01, 0x01]);
+            data = Buffer.concat([data, Buffer.from(name, "ascii")]);
+            // Send this twice, as sometimes the first time doesn't take
+            this.send(data, Consts.BLECharacteristic.LPF2_ALL);
+            this.send(data, Consts.BLECharacteristic.LPF2_ALL);
+            this._name = name;
+            return resolve();
+        });
+    }
+    send(message, uuid, callback) {
+        message = Buffer.concat([Buffer.alloc(2), message]);
+        message[0] = message.length;
+        debug("Sent Message (LPF2_ALL)", message);
+        this._bleDevice.writeToCharacteristic(uuid, message, callback);
+    }
+    subscribe(portId, deviceType, mode) {
+        this.send(Buffer.from([0x41, portId, mode, 0x01, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.LPF2_ALL);
+    }
+    unsubscribe(portId, mode) {
+        this.send(Buffer.from([0x41, portId, mode, 0x01, 0x00, 0x00, 0x00, 0x00]), Consts.BLECharacteristic.LPF2_ALL);
+    }
+    /**
+     * Combines two ports with into a single virtual port.
+     *
+     * Note: The devices attached to the ports must be of the same device type.
+     * @method LPF2Hub#createVirtualPort
+     * @param {string} firstPortName First port name
+     * @param {string} secondPortName Second port name
+     * @returns {Promise} Resolved upon successful issuance of command.
+     */
+    createVirtualPort(firstPortName, secondPortName) {
+        const firstDevice = this.getDeviceAtPort(firstPortName);
+        if (!firstDevice) {
+            throw new Error(`Port ${firstPortName} does not have an attached device`);
+        }
+        const secondDevice = this.getDeviceAtPort(secondPortName);
+        if (!secondDevice) {
+            throw new Error(`Port ${secondPortName} does not have an attached device`);
+        }
+        if (firstDevice.type !== secondDevice.type) {
+            throw new Error(`Both devices must be of the same type to create a virtual port`);
+        }
+        this.send(Buffer.from([0x61, 0x01, firstDevice.portId, secondDevice.portId]), Consts.BLECharacteristic.LPF2_ALL);
+    }
+    _checkFirmware(version) {
+        return;
+    }
+    _parseMessage(data) {
+        if (data) {
+            this._messageBuffer = Buffer.concat([this._messageBuffer, data]);
+        }
+        if (this._messageBuffer.length <= 0) {
+            return;
+        }
+        const len = this._messageBuffer[0];
+        if (len >= this._messageBuffer.length) {
+            const message = this._messageBuffer.slice(0, len);
+            this._messageBuffer = this._messageBuffer.slice(len);
+            debug("Received Message (LPF2_ALL)", message);
+            switch (message[2]) {
+                case 0x01: {
+                    const property = message[3];
+                    const callback = this._propertyRequestCallbacks[property];
+                    if (callback) {
+                        callback(message);
+                    }
+                    else {
+                        this._parseHubPropertyResponse(message);
+                    }
+                    delete this._propertyRequestCallbacks[property];
+                    break;
+                }
+                case 0x04: {
+                    this._parsePortMessage(message);
+                    break;
+                }
+                case 0x43: {
+                    this._parsePortInformationResponse(message);
+                    break;
+                }
+                case 0x44: {
+                    this._parseModeInformationResponse(message);
+                    break;
+                }
+                case 0x45: {
+                    this._parseSensorMessage(message);
+                    break;
+                }
+                case 0x82: {
+                    this._parsePortAction(message);
+                    break;
+                }
+            }
+            if (this._messageBuffer.length > 0) {
+                this._parseMessage();
+            }
+        }
+    }
+    _requestHubPropertyValue(property) {
+        return new Promise((resolve) => {
+            this._propertyRequestCallbacks[property] = (message) => {
+                this._parseHubPropertyResponse(message);
+                return resolve();
+            };
+            this.send(Buffer.from([0x01, property, 0x05]), Consts.BLECharacteristic.LPF2_ALL);
+        });
+    }
+    _requestHubPropertyReports(property) {
+        this.send(Buffer.from([0x01, property, 0x02]), Consts.BLECharacteristic.LPF2_ALL);
+    }
+    _parseHubPropertyResponse(message) {
+        // Button press reports
+        if (message[3] === 0x02) {
+            if (message[5] === 1) {
+                /**
+                 * Emits when a button is pressed.
+                 * @event LPF2Hub#button
+                 * @param {string} button
+                 * @param {ButtonState} state
+                 */
+                this.emit("button", { event: Consts.ButtonState.PRESSED });
+                return;
+            }
+            else if (message[5] === 0) {
+                this.emit("button", { event: Consts.ButtonState.RELEASED });
+                return;
+            }
+            // Firmware version
+        }
+        else if (message[3] === 0x03) {
+            this._firmwareVersion = utils_1.decodeVersion(message.readInt32LE(5));
+            this._checkFirmware(this._firmwareVersion);
+            // Hardware version
+        }
+        else if (message[3] === 0x04) {
+            this._hardwareVersion = utils_1.decodeVersion(message.readInt32LE(5));
+            // RSSI update
+        }
+        else if (message[3] === 0x05) {
+            const rssi = message.readInt8(5);
+            if (rssi !== 0) {
+                this._rssi = rssi;
+                this.emit("rssi", { rssi: this._rssi });
+            }
+            // primary MAC Address
+        }
+        else if (message[3] === 0x0d) {
+            this._primaryMACAddress = utils_1.decodeMACAddress(message.slice(5));
+            // Battery level reports
+        }
+        else if (message[3] === 0x06) {
+            const batteryLevel = message[5];
+            if (batteryLevel !== this._batteryLevel) {
+                this._batteryLevel = batteryLevel;
+                this.emit("batteryLevel", { batteryLevel });
+            }
+        }
+    }
+    _parsePortMessage(message) {
+        const portId = message[3];
+        const event = message[4];
+        const deviceType = event ? message.readUInt16LE(5) : 0;
+        // Handle device attachments
+        if (event === 0x01) {
+            if (modeInfoDebug.enabled) {
+                const deviceTypeName = Consts.DeviceTypeNames[message[5]] || "Unknown";
+                modeInfoDebug(`Port ${utils_1.toHex(portId)}, type ${utils_1.toHex(deviceType, 4)} (${deviceTypeName})`);
+                const hwVersion = utils_1.decodeVersion(message.readInt32LE(7));
+                const swVersion = utils_1.decodeVersion(message.readInt32LE(11));
+                modeInfoDebug(`Port ${utils_1.toHex(portId)}, hardware version ${hwVersion}, software version ${swVersion}`);
+                this._sendPortInformationRequest(portId);
+            }
+            const device = this._createDevice(deviceType, portId);
+            this._attachDevice(device);
+            // Handle device detachments
+        }
+        else if (event === 0x00) {
+            const device = this._getDeviceByPortId(portId);
+            if (device) {
+                this._detachDevice(device);
+                if (this.isPortVirtual(portId)) {
+                    const portName = this.getPortNameForPortId(portId);
+                    if (portName) {
+                        delete this._portMap[portName];
+                    }
+                    this._virtualPorts = this._virtualPorts.filter((virtualPortId) => virtualPortId !== portId);
+                }
+            }
+            // Handle virtual port creation
+        }
+        else if (event === 0x02) {
+            const firstPortName = this.getPortNameForPortId(message[7]);
+            const secondPortName = this.getPortNameForPortId(message[8]);
+            // @ts-ignore NK These should never be undefined
+            const virtualPortName = firstPortName + secondPortName;
+            const virtualPortId = message[3];
+            this._portMap[virtualPortName] = virtualPortId;
+            this._virtualPorts.push(virtualPortId);
+            const device = this._createDevice(deviceType, virtualPortId);
+            this._attachDevice(device);
+        }
+    }
+    _sendPortInformationRequest(port) {
+        this.send(Buffer.from([0x21, port, 0x01]), Consts.BLECharacteristic.LPF2_ALL);
+        this.send(Buffer.from([0x21, port, 0x02]), Consts.BLECharacteristic.LPF2_ALL); // Mode combinations
+    }
+    _parsePortInformationResponse(message) {
+        const port = message[3];
+        if (message[4] === 2) {
+            const modeCombinationMasks = [];
+            for (let i = 5; i < message.length; i += 2) {
+                modeCombinationMasks.push(message.readUInt16LE(i));
+            }
+            modeInfoDebug(`Port ${utils_1.toHex(port)}, mode combinations [${modeCombinationMasks.map((c) => utils_1.toBin(c, 0)).join(", ")}]`);
+            return;
+        }
+        const count = message[6];
+        const input = utils_1.toBin(message.readUInt16LE(7), count);
+        const output = utils_1.toBin(message.readUInt16LE(9), count);
+        modeInfoDebug(`Port ${utils_1.toHex(port)}, total modes ${count}, input modes ${input}, output modes ${output}`);
+        for (let i = 0; i < count; i++) {
+            this._sendModeInformationRequest(port, i, 0x00); // Mode Name
+            this._sendModeInformationRequest(port, i, 0x01); // RAW Range
+            this._sendModeInformationRequest(port, i, 0x02); // PCT Range
+            this._sendModeInformationRequest(port, i, 0x03); // SI Range
+            this._sendModeInformationRequest(port, i, 0x04); // SI Symbol
+            this._sendModeInformationRequest(port, i, 0x80); // Value Format
+        }
+    }
+    _sendModeInformationRequest(port, mode, type) {
+        this.send(Buffer.from([0x22, port, mode, type]), Consts.BLECharacteristic.LPF2_ALL);
+    }
+    _parseModeInformationResponse(message) {
+        const port = utils_1.toHex(message[3]);
+        const mode = message[4];
+        const type = message[5];
+        switch (type) {
+            case 0x00: // Mode Name
+                modeInfoDebug(`Port ${port}, mode ${mode}, name ${message.slice(6, message.length).toString()}`);
+                break;
+            case 0x01: // RAW Range
+                modeInfoDebug(`Port ${port}, mode ${mode}, RAW min ${message.readFloatLE(6)}, max ${message.readFloatLE(10)}`);
+                break;
+            case 0x02: // PCT Range
+                modeInfoDebug(`Port ${port}, mode ${mode}, PCT min ${message.readFloatLE(6)}, max ${message.readFloatLE(10)}`);
+                break;
+            case 0x03: // SI Range
+                modeInfoDebug(`Port ${port}, mode ${mode}, SI min ${message.readFloatLE(6)}, max ${message.readFloatLE(10)}`);
+                break;
+            case 0x04: // SI Symbol
+                modeInfoDebug(`Port ${port}, mode ${mode}, SI symbol ${message.slice(6, message.length).toString()}`);
+                break;
+            case 0x80: // Value Format
+                const numValues = message[6];
+                const dataType = ["8bit", "16bit", "32bit", "float"][message[7]];
+                const totalFigures = message[8];
+                const decimals = message[9];
+                modeInfoDebug(`Port ${port}, mode ${mode}, Value ${numValues} x ${dataType}, Decimal format ${totalFigures}.${decimals}`);
+        }
+    }
+    _parsePortAction(message) {
+        const portId = message[3];
+        const device = this._getDeviceByPortId(portId);
+        if (device) {
+            const finished = (message[4] === 0x0a);
+            if (finished) {
+                device.finish();
+            }
+        }
+    }
+    _parseSensorMessage(message) {
+        const portId = message[3];
+        const device = this._getDeviceByPortId(portId);
+        if (device) {
+            device.receive(message);
+        }
+    }
+}
+exports.LPF2Hub = LPF2Hub;
+//# sourceMappingURL=lpf2hub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_movehub.js.html b/docs/hubs_movehub.js.html new file mode 100644 index 0000000..65cf59e --- /dev/null +++ b/docs/hubs_movehub.js.html @@ -0,0 +1,277 @@ + + + + + + + node-poweredup Source: hubs/movehub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/movehub.js

+ +
+
+
"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+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 compare_versions_1 = __importDefault(require("compare-versions"));
+const lpf2hub_1 = require("./lpf2hub");
+const Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("movehub");
+/**
+ * The MoveHub is emitted if the discovered device is a Move Hub.
+ * @class MoveHub
+ * @extends LPF2Hub
+ * @extends BaseHub
+ */
+class MoveHub extends lpf2hub_1.LPF2Hub {
+    static IsMoveHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.MOVE_HUB_ID);
+    }
+    constructor(device) {
+        super(device, exports.PortMap, Consts.HubType.MOVE_HUB);
+        debug("Discovered Move Hub");
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Move Hub");
+            await super.connect();
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+    _checkFirmware(version) {
+        if (compare_versions_1.default("2.0.00.0017", version) === 1) {
+            throw new Error(`Your Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
+        }
+    }
+}
+exports.MoveHub = MoveHub;
+exports.PortMap = {
+    "A": 0,
+    "B": 1,
+    "C": 2,
+    "D": 3,
+    "HUB_LED": 50,
+    "TILT_SENSOR": 58,
+    "CURRENT_SENSOR": 59,
+    "VOLTAGE_SENSOR": 60
+};
+//# sourceMappingURL=movehub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_puphub.js.html b/docs/hubs_puphub.js.html new file mode 100644 index 0000000..0d749eb --- /dev/null +++ b/docs/hubs_puphub.js.html @@ -0,0 +1,273 @@ + + + + + + + node-poweredup Source: hubs/puphub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/puphub.js

+ +
+
+
"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+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 compare_versions_1 = __importDefault(require("compare-versions"));
+const lpf2hub_1 = require("./lpf2hub");
+const Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("puphub");
+/**
+ * The PUPHub is emitted if the discovered device is a Powered UP Hub.
+ * @class PUPHub
+ * @extends LPF2Hub
+ * @extends Hub
+ */
+class PUPHub extends lpf2hub_1.LPF2Hub {
+    constructor(device) {
+        super(device, Consts.HubType.POWERED_UP_HUB);
+        this._currentPort = 0x3b;
+        this._voltagePort = 0x3c;
+        this._portNames = {
+            "A": 0,
+            "B": 1
+        };
+        debug("Discovered Powered UP Hub");
+    }
+    static IsPUPHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_HUB_ID);
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Powered UP Hub");
+            await super.connect();
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+    _checkFirmware(version) {
+        if (compare_versions_1.default("1.1.00.0004", version) === 1) {
+            throw new Error(`Your Powered Up Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
+        }
+    }
+}
+exports.PUPHub = PUPHub;
+//# sourceMappingURL=puphub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_pupremote.js.html b/docs/hubs_pupremote.js.html new file mode 100644 index 0000000..525a59a --- /dev/null +++ b/docs/hubs_pupremote.js.html @@ -0,0 +1,266 @@ + + + + + + + node-poweredup Source: hubs/pupremote.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/pupremote.js

+ +
+
+
"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 Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("pupremote");
+/**
+ * The PUPRemote is emitted if the discovered device is a Powered UP Remote.
+ * @class PUPRemote
+ * @extends LPF2Hub
+ * @extends Hub
+ */
+class PUPRemote extends lpf2hub_1.LPF2Hub {
+    constructor(device) {
+        super(device, Consts.HubType.POWERED_UP_REMOTE);
+        this._ledPort = 0x34;
+        this._voltagePort = 0x3b;
+        this._voltageMaxV = 6.4;
+        this._voltageMaxRaw = 3200;
+        this._portNames = {
+            "LEFT": 0,
+            "RIGHT": 1
+        };
+        debug("Discovered Powered UP Remote");
+    }
+    static IsPUPRemote(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_REMOTE_ID);
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Powered UP Remote");
+            await super.connect();
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+}
+exports.PUPRemote = PUPRemote;
+//# sourceMappingURL=pupremote.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_remotecontrol.js.html b/docs/hubs_remotecontrol.js.html new file mode 100644 index 0000000..cb5f467 --- /dev/null +++ b/docs/hubs_remotecontrol.js.html @@ -0,0 +1,265 @@ + + + + + + + node-poweredup Source: hubs/remotecontrol.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/remotecontrol.js

+ +
+
+
"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 Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("remotecontrol");
+/**
+ * The RemoteControl is emitted if the discovered device is a Remote Control.
+ * @class RemoteControl
+ * @extends LPF2Hub
+ * @extends BaseHub
+ */
+class RemoteControl extends lpf2hub_1.LPF2Hub {
+    static IsRemoteControl(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.REMOTE_CONTROL_ID);
+    }
+    constructor(device) {
+        super(device, exports.PortMap, Consts.HubType.REMOTE_CONTROL);
+        debug("Discovered Powered UP Remote");
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Powered UP Remote");
+            await super.connect();
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+}
+exports.RemoteControl = RemoteControl;
+exports.PortMap = {
+    "LEFT": 0,
+    "RIGHT": 1,
+    "HUB_LED": 52,
+    "VOLTAGE_SENSOR": 59,
+    "REMOTE_CONTROL_RSSI": 60
+};
+//# sourceMappingURL=remotecontrol.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_technicmediumhub.js.html b/docs/hubs_technicmediumhub.js.html new file mode 100644 index 0000000..f208bae --- /dev/null +++ b/docs/hubs_technicmediumhub.js.html @@ -0,0 +1,271 @@ + + + + + + + node-poweredup Source: hubs/technicmediumhub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/technicmediumhub.js

+ +
+
+
"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 Consts = __importStar(require("../consts"));
+const Debug = require("debug");
+const debug = Debug("technicmediumhub");
+/**
+ * The TechnicMediumHub is emitted if the discovered device is a Technic Medium Hub.
+ * @class TechnicMediumHub
+ * @extends LPF2Hub
+ * @extends BaseHub
+ */
+class TechnicMediumHub extends lpf2hub_1.LPF2Hub {
+    static IsTechnicMediumHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+            peripheral.advertisement.manufacturerData &&
+            peripheral.advertisement.manufacturerData.length > 3 &&
+            peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.TECHNIC_MEDIUM_HUB);
+    }
+    constructor(device) {
+        super(device, exports.PortMap, Consts.HubType.TECHNIC_MEDIUM_HUB);
+        debug("Discovered Control+ Hub");
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to Control+ Hub");
+            await super.connect();
+            this.send(Buffer.from([0x41, 0x3d, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.LPF2_ALL); // Temperature
+            debug("Connect completed");
+            return resolve();
+        });
+    }
+}
+exports.TechnicMediumHub = TechnicMediumHub;
+exports.PortMap = {
+    "A": 0,
+    "B": 1,
+    "C": 2,
+    "D": 3,
+    "HUB_LED": 50,
+    "CURRENT_SENSOR": 59,
+    "VOLTAGE_SENSOR": 60,
+    "ACCELEROMETER": 97,
+    "GYRO_SENSOR": 98,
+    "TILT_SENSOR": 99
+};
+//# sourceMappingURL=technicmediumhub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/hubs_wedo2smarthub.js.html b/docs/hubs_wedo2smarthub.js.html new file mode 100644 index 0000000..89ebc50 --- /dev/null +++ b/docs/hubs_wedo2smarthub.js.html @@ -0,0 +1,417 @@ + + + + + + + node-poweredup Source: hubs/wedo2smarthub.js + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: hubs/wedo2smarthub.js

+ +
+
+
"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 basehub_1 = require("./basehub");
+const Consts = __importStar(require("../consts"));
+const utils_1 = require("../utils");
+const Debug = require("debug");
+const debug = Debug("wedo2smarthub");
+/**
+ * The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
+ * @class WeDo2SmartHub
+ * @extends BaseHub
+ */
+class WeDo2SmartHub extends basehub_1.BaseHub {
+    constructor(device) {
+        super(device, exports.PortMap, Consts.HubType.WEDO2_SMART_HUB);
+        this._lastTiltX = 0;
+        this._lastTiltY = 0;
+        debug("Discovered WeDo 2.0 Smart Hub");
+    }
+    static IsWeDo2SmartHub(peripheral) {
+        return (peripheral.advertisement &&
+            peripheral.advertisement.serviceUuids &&
+            peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.WEDO2_SMART_HUB.replace(/-/g, "")) >= 0);
+    }
+    connect() {
+        return new Promise(async (resolve, reject) => {
+            debug("Connecting to WeDo 2.0 Smart Hub");
+            await super.connect();
+            await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB);
+            await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_2);
+            if (!utils_1.isWebBluetooth) {
+                await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_3);
+                await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_4);
+                await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_5);
+            }
+            else {
+                await this._bleDevice.discoverCharacteristicsForService("battery_service");
+                await this._bleDevice.discoverCharacteristicsForService("device_information");
+            }
+            debug("Connect completed");
+            this.emit("connect");
+            resolve();
+            this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE, this._parsePortMessage.bind(this));
+            this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE, this._parseSensorMessage.bind(this));
+            this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON, this._parseSensorMessage.bind(this));
+            if (!utils_1.isWebBluetooth) {
+                this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, this._parseBatteryMessage.bind(this));
+                this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, (err, data) => {
+                    if (data) {
+                        this._parseBatteryMessage(data);
+                    }
+                });
+            }
+            else {
+                this._bleDevice.readFromCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", (err, data) => {
+                    if (data) {
+                        this._parseBatteryMessage(data);
+                    }
+                });
+                this._bleDevice.subscribeToCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", this._parseHighCurrentAlert.bind(this));
+            }
+            this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT, this._parseHighCurrentAlert.bind(this));
+            if (!utils_1.isWebBluetooth) {
+                this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION, (err, data) => {
+                    if (data) {
+                        this._parseFirmwareRevisionString(data);
+                    }
+                });
+            }
+            else {
+                this._bleDevice.readFromCharacteristic("00002a26-0000-1000-8000-00805f9b34fb", (err, data) => {
+                    if (data) {
+                        this._parseFirmwareRevisionString(data);
+                    }
+                });
+            }
+        });
+    }
+    /**
+     * Shutdown the Hub.
+     * @method WeDo2SmartHub#shutdown
+     * @returns {Promise} Resolved upon successful disconnect.
+     */
+    shutdown() {
+        return new Promise((resolve, reject) => {
+            this.send(Buffer.from([0x00]), Consts.BLECharacteristic.WEDO2_DISCONNECT, () => {
+                return resolve();
+            });
+        });
+    }
+    /**
+     * Set the name of the Hub.
+     * @method WeDo2SmartHub#setName
+     * @param {string} name New name of the hub (14 characters or less, ASCII only).
+     * @returns {Promise} Resolved upon successful issuance of command.
+     */
+    setName(name) {
+        if (name.length > 14) {
+            throw new Error("Name must be 14 characters or less");
+        }
+        return new Promise((resolve, reject) => {
+            const data = Buffer.from(name, "ascii");
+            // Send this twice, as sometimes the first time doesn't take
+            this.send(data, Consts.BLECharacteristic.WEDO2_NAME_ID);
+            this.send(data, Consts.BLECharacteristic.WEDO2_NAME_ID);
+            this._name = name;
+            return resolve();
+        });
+    }
+    send(message, uuid, callback) {
+        if (debug.enabled) {
+            debug(`Sent Message (${this._getCharacteristicNameFromUUID(uuid)})`, message);
+        }
+        this._bleDevice.writeToCharacteristic(uuid, message, callback);
+    }
+    subscribe(portId, deviceType, mode) {
+        this.send(Buffer.from([0x01, 0x02, portId, deviceType, mode, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
+    }
+    unsubscribe(portId, deviceType, mode) {
+        this.send(Buffer.from([0x01, 0x02, portId, deviceType, mode, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
+    }
+    _getCharacteristicNameFromUUID(uuid) {
+        const keys = Object.keys(Consts.BLECharacteristic);
+        for (let i = 0; i < keys.length; i++) {
+            const key = keys[i];
+            if (Consts.BLECharacteristic[key] === uuid) {
+                return key;
+            }
+        }
+        return "UNKNOWN";
+    }
+    _parseHighCurrentAlert(data) {
+        debug("Received Message (WEDO2_HIGH_CURRENT_ALERT)", data);
+    }
+    _parseBatteryMessage(data) {
+        debug("Received Message (WEDO2_BATTERY)", data);
+        const batteryLevel = data[0];
+        if (batteryLevel !== this._batteryLevel) {
+            this._batteryLevel = batteryLevel;
+            this.emit("batteryLevel", { batteryLevel });
+        }
+    }
+    _parseFirmwareRevisionString(data) {
+        debug("Received Message (WEDO2_FIRMWARE_REVISION)", data);
+        this._firmwareVersion = data.toString();
+    }
+    _parsePortMessage(data) {
+        debug("Received Message (WEDO2_PORT_TYPE)", data);
+        const portId = data[0];
+        const event = data[1];
+        const deviceType = event ? data[3] : 0;
+        if (event === 0x01) {
+            const device = this._createDevice(deviceType, portId);
+            this._attachDevice(device);
+        }
+        else if (event === 0x00) {
+            const device = this._getDeviceByPortId(portId);
+            if (device) {
+                this._detachDevice(device);
+            }
+        }
+    }
+    _parseSensorMessage(message) {
+        debug("Received Message (WEDO2_SENSOR_VALUE)", message);
+        if (message[0] === 0x01) {
+            /**
+             * Emits when a button is pressed.
+             * @event WeDo2SmartHub#button
+             * @param {string} button
+             * @param {ButtonState} state
+             */
+            this.emit("button", { event: Consts.ButtonState.PRESSED });
+            return;
+        }
+        else if (message[0] === 0x00) {
+            this.emit("button", { event: Consts.ButtonState.RELEASED });
+            return;
+        }
+        const portId = message[1];
+        const device = this._getDeviceByPortId(portId);
+        if (device) {
+            device.receive(message);
+        }
+    }
+}
+exports.WeDo2SmartHub = WeDo2SmartHub;
+exports.PortMap = {
+    "A": 1,
+    "B": 2,
+    "CURRENT_SENSOR": 3,
+    "VOLTAGE_SENSOR": 4,
+    "PIEZO_BUZZER": 5,
+    "HUB_LED": 6
+};
+//# sourceMappingURL=wedo2smarthub.js.map
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/index.html b/docs/index.html index a3c6c91..71d39a8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,21 +33,14 @@ - - @@ -103,15 +96,17 @@

Drone
NPM Version

node-poweredup - A Javascript module to interface with LEGO Powered Up components.

+

Announcements

+

Important: v6.0.0 is a complete re-architecting of this library. Improvements include proper device and mode support through an external Device object, correct handling of firmware features, and promise-based functionality for interfacing with device attachments. Although many new features were added, existing code will almost surely break upon upgrade.

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, LEGO Powered Up released in 2018, and LEGO Technic CONTROL+ released in 2019. 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 - starting with LEGO Education WeDo 2.0 released in 2016, LEGO Boost released in 2017, LEGO Powered Up released in 2018, LEGO Technic CONTROL+ released in 2019, and LEGO Education SPIKE Prime released in 2020. It also includes the 2018 Duplo App-Controlled Train sets.

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.

Node.js Installation

-

Node.js v8.0 required.

+

Node.js v8.0+ required.

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.

-

Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B.

+

Note: node-poweredup has been tested on macOS 10.15 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.

@@ -218,6 +213,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Yes 42099
42100
SPIKE Prime Medium Motor45678Motor/SensorPartialYesYesYes45678
SPIKE Prime Large Motor45678Motor/SensorPartialYesYesYes45678
SPIKE Prime Color Sensor45678SensorNoYesYesYes45678
SPIKE Prime Distance Sensor45678SensorNoYesYesYes45678
SPIKE Prime Force Sensor45678SensorNoYesYesYes45678

In addition, the Hubs themselves have certain built-in features which this library exposes.

@@ -272,13 +317,13 @@

Known Issues and Limitations

Documentation

@@ -290,17 +335,22 @@ const poweredUP = new PoweredUP.PoweredUP(); poweredUP.on("discover", async (hub) => { // Wait to discover a Hub console.log(`Discovered ${hub.name}!`); 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"); - await hub.sleep(3000); // Sleep for 3 seconds before starting while (true) { // Repeat indefinitely - console.log("Running motor B at speed 75"); - hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely + console.log("Running motor B at speed 50"); + 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"); - 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 - console.log("Running motor A at speed -50 for 1 seconds"); - 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 + console.log("Running motor A at speed -30 for 1 second"); + 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 } }); @@ -360,7 +410,7 @@ console.log("Scanning for Hubs..."); Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Mon Feb 24th 2020 using the DocStrap template. diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index cd18f54..866aef4 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -40,7 +40,7 @@ @@ -332,7 +332,7 @@ class LPF2Hub extends hub_1.Hub { // primary MAC Address } else if (data[3] === 0x0d) { - this._primaryMACAddress = LPF2Hub.decodeMACAddress(data.slice(4, 10)); + this._primaryMACAddress = LPF2Hub.decodeMACAddress(data.slice(5)); // Battery level reports } else if (data[3] === 0x06) { @@ -571,12 +571,27 @@ class LPF2Hub extends hub_1.Hub { this.emit("tilt", "TILT", this._lastTiltX, this._lastTiltY, this._lastTiltZ); break; } - case Consts.DeviceType.CONTROL_PLUS_ACCELEROMETER: { - const accelX = Math.round((data.readInt16LE(4) / 28571) * 2000); - const accelY = Math.round((data.readInt16LE(6) / 28571) * 2000); - const accelZ = Math.round((data.readInt16LE(8) / 28571) * 2000); + case Consts.DeviceType.CONTROL_PLUS_GYRO: { + const gyroX = Math.round(data.readInt16LE(4) * 7 / 400); + const gyroY = Math.round(data.readInt16LE(6) * 7 / 400); + const gyroZ = Math.round(data.readInt16LE(8) * 7 / 400); /** - * Emits when accelerometer detects movement. Measured in DPS - degrees per second. + * Emits when gyroscope detects movement. Measured in DPS - degrees per second. + * @event LPF2Hub#gyro + * @param {string} port + * @param {number} x + * @param {number} y + * @param {number} z + */ + this.emit("gyro", "GYRO", gyroX, gyroY, gyroZ); + break; + } + case Consts.DeviceType.CONTROL_PLUS_ACCELEROMETER: { + const accelX = Math.round(data.readInt16LE(4) / 4.096); + const accelY = Math.round(data.readInt16LE(6) / 4.096); + const accelZ = Math.round(data.readInt16LE(8) / 4.096); + /** + * Emits when accelerometer detects movement. Measured in mG. * @event LPF2Hub#accel * @param {string} port * @param {number} x @@ -682,7 +697,7 @@ exports.LPF2Hub = LPF2Hub; Documentation generated by JSDoc 3.6.3 - on Wed Nov 13th 2019 + on Tue Dec 3rd 2019 using the DocStrap template. diff --git a/docs/poweredup-node.js.html b/docs/poweredup-node.js.html index 9a30885..46a1b7d 100644 --- a/docs/poweredup-node.js.html +++ b/docs/poweredup-node.js.html @@ -33,14 +33,14 @@ @@ -86,13 +86,13 @@
"use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-const boostmovehub_1 = require("./boostmovehub");
-const controlplushub_1 = require("./controlplushub");
-const duplotrainbase_1 = require("./duplotrainbase");
-const nobledevice_1 = require("./nobledevice");
-const puphub_1 = require("./puphub");
-const pupremote_1 = require("./pupremote");
-const wedo2smarthub_1 = require("./wedo2smarthub");
+const nobleabstraction_1 = require("./nobleabstraction");
+const duplotrainbase_1 = require("./hubs/duplotrainbase");
+const hub_1 = require("./hubs/hub");
+const movehub_1 = require("./hubs/movehub");
+const remotecontrol_1 = require("./hubs/remotecontrol");
+const technicmediumhub_1 = require("./hubs/technicmediumhub");
+const wedo2smarthub_1 = require("./hubs/wedo2smarthub");
 const events_1 = require("events");
 const Debug = require("debug");
 const debug = Debug("poweredup");
@@ -122,7 +122,6 @@ noble.on("stateChange", (state) => {
 class PoweredUP extends events_1.EventEmitter {
     constructor() {
         super();
-        this.autoSubscribe = true;
         this._connectedHubs = {};
         this._discoveryEventHandler = this._discoveryEventHandler.bind(this);
     }
@@ -156,60 +155,69 @@ class PoweredUP extends events_1.EventEmitter {
     }
     /**
      * Retrieve a list of Powered UP Hubs.
-     * @method PoweredUP#getConnectedHubs
-     * @returns {Hub[]}
+     * @method PoweredUP#getHubs
+     * @returns {BaseHub[]}
      */
-    getConnectedHubs() {
-        return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]);
+    getHubs() {
+        return Object.values(this._connectedHubs);
     }
     /**
      * Retrieve a Powered UP Hub by UUID.
-     * @method PoweredUP#getConnectedHubByUUID
+     * @method PoweredUP#getHubByUUID
      * @param {string} uuid
-     * @returns {Hub | null}
+     * @returns {BaseHub | null}
      */
-    getConnectedHubByUUID(uuid) {
+    getHubByUUID(uuid) {
         return this._connectedHubs[uuid];
     }
     /**
      * Retrieve a Powered UP Hub by primary MAC address.
-     * @method PoweredUP#getConnectedHubByPrimaryMACAddress
+     * @method PoweredUP#getHubByPrimaryMACAddress
      * @param {string} address
-     * @returns {Hub}
+     * @returns {BaseHub}
      */
-    getConnectedHubByPrimaryMACAddress(address) {
-        return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]).filter((hub) => hub.primaryMACAddress === address)[0];
+    getHubByPrimaryMACAddress(address) {
+        return Object.values(this._connectedHubs).filter((hub) => hub.primaryMACAddress === address)[0];
     }
     /**
      * Retrieve a list of Powered UP Hub by name.
-     * @method PoweredUP#getConnectedHubsByName
+     * @method PoweredUP#getHubsByName
      * @param {string} name
-     * @returns {Hub[]}
+     * @returns {BaseHub[]}
      */
-    getConnectedHubsByName(name) {
-        return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]).filter((hub) => hub.name === name);
+    getHubsByName(name) {
+        return Object.values(this._connectedHubs).filter((hub) => hub.name === name);
+    }
+    /**
+     * Retrieve a list of Powered UP Hub by type.
+     * @method PoweredUP#getHubsByType
+     * @param {string} name
+     * @returns {BaseHub[]}
+     */
+    getHubsByType(hubType) {
+        return Object.values(this._connectedHubs).filter((hub) => hub.type === hubType);
     }
     async _discoveryEventHandler(peripheral) {
         peripheral.removeAllListeners();
-        const device = new nobledevice_1.NobleDevice(peripheral);
+        const device = new nobleabstraction_1.NobleDevice(peripheral);
         let hub;
         if (await wedo2smarthub_1.WeDo2SmartHub.IsWeDo2SmartHub(peripheral)) {
-            hub = new wedo2smarthub_1.WeDo2SmartHub(device, this.autoSubscribe);
+            hub = new wedo2smarthub_1.WeDo2SmartHub(device);
         }
-        else if (await boostmovehub_1.BoostMoveHub.IsBoostMoveHub(peripheral)) {
-            hub = new boostmovehub_1.BoostMoveHub(device, this.autoSubscribe);
+        else if (await movehub_1.MoveHub.IsMoveHub(peripheral)) {
+            hub = new movehub_1.MoveHub(device);
         }
-        else if (await puphub_1.PUPHub.IsPUPHub(peripheral)) {
-            hub = new puphub_1.PUPHub(device, this.autoSubscribe);
+        else if (await hub_1.Hub.IsHub(peripheral)) {
+            hub = new hub_1.Hub(device);
         }
-        else if (await pupremote_1.PUPRemote.IsPUPRemote(peripheral)) {
-            hub = new pupremote_1.PUPRemote(device, this.autoSubscribe);
+        else if (await remotecontrol_1.RemoteControl.IsRemoteControl(peripheral)) {
+            hub = new remotecontrol_1.RemoteControl(device);
         }
         else if (await duplotrainbase_1.DuploTrainBase.IsDuploTrainBase(peripheral)) {
-            hub = new duplotrainbase_1.DuploTrainBase(device, this.autoSubscribe);
+            hub = new duplotrainbase_1.DuploTrainBase(device);
         }
-        else if (await controlplushub_1.ControlPlusHub.IsControlPlusHub(peripheral)) {
-            hub = new controlplushub_1.ControlPlusHub(device, this.autoSubscribe);
+        else if (await technicmediumhub_1.TechnicMediumHub.IsTechnicMediumHub(peripheral)) {
+            hub = new technicmediumhub_1.TechnicMediumHub(device);
         }
         else {
             return;
@@ -230,7 +238,7 @@ class PoweredUP extends events_1.EventEmitter {
             /**
              * Emits when a Powered UP Hub device is found.
              * @event PoweredUP#discover
-             * @param {WeDo2SmartHub | BoostMoveHub | ControlPlusHub | PUPHub | PUPRemote | DuploTrainBase} hub
+             * @param {WeDo2SmartHub | MoveHub | TechnicMediumHub | Hub | RemoteControl | DuploTrainBase} hub
              */
             this.emit("discover", hub);
         });
@@ -282,7 +290,7 @@ exports.PoweredUP = PoweredUP;
 
 	Documentation generated by JSDoc 3.6.3
 	
-		on Wed Nov 13th 2019
+		on Fri Feb 7th 2020
 	
 	using the DocStrap template.
 
diff --git a/docs/puphub.js.html b/docs/puphub.js.html
index 65cb01a..3219250 100644
--- a/docs/puphub.js.html
+++ b/docs/puphub.js.html
@@ -40,7 +40,7 @@
 			
 			
@@ -417,7 +417,7 @@ exports.PUPHub = PUPHub;
 
 	Documentation generated by JSDoc 3.6.3
 	
-		on Wed Nov 13th 2019
+		on Tue Dec 3rd 2019
 	
 	using the DocStrap template.
 
diff --git a/docs/pupremote.js.html b/docs/pupremote.js.html
index 65499c0..c7e9543 100644
--- a/docs/pupremote.js.html
+++ b/docs/pupremote.js.html
@@ -40,7 +40,7 @@
 			
 			
@@ -181,7 +181,7 @@ exports.PUPRemote = PUPRemote;
 
 	Documentation generated by JSDoc 3.6.3
 	
-		on Wed Nov 13th 2019
+		on Tue Dec 3rd 2019
 	
 	using the DocStrap template.
 
diff --git a/docs/quicksearch.html b/docs/quicksearch.html
index a8ae974..e4b37d1 100644
--- a/docs/quicksearch.html
+++ b/docs/quicksearch.html
@@ -7,7 +7,7 @@
     
 
     
 
     
-
-
-
-
-
-

Vernie / PlayStation DualShock 4 Remote Control

-
-Scan for Vernie -
-
-Current Color:
 
-
- - - \ No newline at end of file diff --git a/examples/vernie_remote.js b/examples/vernie_remote.js index c621030..4bb93bb 100644 --- a/examples/vernie_remote.js +++ b/examples/vernie_remote.js @@ -16,55 +16,65 @@ let remote = null; poweredUP.on("discover", async (hub) => { // Wait to discover Vernie and Remote - if (hub instanceof PoweredUP.BoostMoveHub) { + if (hub.type === PoweredUP.Consts.HubType.MOVE_HUB) { vernie = hub; await vernie.connect(); - vernie.setLEDColor(PoweredUP.Consts.Color.BLUE); + const led = await vernie.waitForDeviceByType(PoweredUP.Consts.DeviceType.HUB_LED); + led.setColor(PoweredUP.Consts.Color.BLUE); console.log(`Connected to Vernie (${vernie.name})!`); - } else if (hub instanceof PoweredUP.PUPRemote) { + } else if (hub.type === PoweredUP.Consts.HubType.REMOTE_CONTROL) { remote = hub; - remote.on("button", async (button, state) => { + remote.on("remoteButton", async (device, { event }) => { if (vernie) { - switch (state) { + const leftTrack = await vernie.waitForDeviceAtPort("A"); + const rightTrack = await vernie.waitForDeviceAtPort("B"); + const head = await vernie.waitForDeviceAtPort("D"); + + console.log(event); + + switch (event) { case PoweredUP.Consts.ButtonState.UP: // If up is pressed, move the track forward { - vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 50); + console.log(device.portName); + device.portName === "LEFT" ? leftTrack.setSpeed(50) : rightTrack.setSpeed(50); break; } case PoweredUP.Consts.ButtonState.DOWN: // If down is pressed, move the track backwards { - vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", -50); + device.portName === "LEFT" ? leftTrack.setSpeed(-50) : rightTrack.setSpeed(-50); break; } case PoweredUP.Consts.ButtonState.RELEASED: // Stop the track when the button is released { - if (button !== "GREEN") { - vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 0); - } + device.portName === "LEFT" ? leftTrack.setPower(0) : rightTrack.setPower(0); break; } case PoweredUP.Consts.ButtonState.STOP: // Move the head left or right when a red button is pressed { - await vernie.setMotorAngle("D", 35, button === "LEFT" ? -20 : 20); - break; - } - case PoweredUP.Consts.ButtonState.PRESSED: // Fire when the green button is pressed - { - if (button === "GREEN") { - await vernie.setMotorAngle("D", 80, 20); - await vernie.setMotorAngle("D", 80, -20); - } + await head.rotateByDegrees(35, device.portName === "LEFT" ? -20 : 20); break; } } } - }) + }); + + hub.on("button", async ({ event }) => { + console.log(event); + if (vernie) { + const head = await vernie.waitForDeviceAtPort("D"); + if (event === PoweredUP.Consts.ButtonState.PRESSED) { + await head.rotateByDegrees(80, 20); + await head.rotateByDegrees(80, -20); + } + } + }); await remote.connect(); - remote.setLEDColor(PoweredUP.Consts.Color.BLUE); + const led = await remote.waitForDeviceByType(PoweredUP.Consts.DeviceType.HUB_LED); + led.setColor(PoweredUP.Consts.Color.BLUE); console.log(`Connected to Powered UP Remote (${remote.name})!`); } diff --git a/examples/web_bluetooth.html b/examples/web_bluetooth.html index 5e63c35..ce68b23 100644 --- a/examples/web_bluetooth.html +++ b/examples/web_bluetooth.html @@ -3,8 +3,8 @@ Web Bluetooth node-poweredup Example - - + +