From 311c296d09c6ac6d2565b604cf39c77acfc666de Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 4 Apr 2019 14:05:09 -0700 Subject: [PATCH] Initial SPIKE Prime commit --- docs/BoostMoveHub.html | 6 +- docs/DuploTrainBase.html | 6 +- docs/Hub.html | 6 +- docs/LPF2Hub.html | 6 +- docs/PUPHub.html | 6 +- docs/PUPRemote.html | 6 +- docs/PoweredUP.html | 16 +- docs/SPIKEPrimeHub.html | 5679 +++++++++++++++++++++++++++++++ docs/WeDo2SmartHub.html | 6 +- docs/boostmovehub.js.html | 6 +- docs/classes.list.html | 1413 +++++++- docs/consts.js.html | 7 +- docs/duplotrainbase.js.html | 6 +- docs/global.html | 22 +- docs/hub.js.html | 6 +- docs/index.html | 6 +- docs/lpf2hub.js.html | 6 +- docs/poweredup-node.js.html | 9 +- docs/puphub.js.html | 6 +- docs/pupremote.js.html | 6 +- docs/quicksearch.html | 2 +- docs/spikeprimehub.js.html | 445 +++ docs/wedo2smarthub.js.html | 6 +- examples/vernie_ds4_remote.html | 97 + src/poweredup-browser.ts | 51 +- src/poweredup-node.ts | 4 +- 26 files changed, 7736 insertions(+), 99 deletions(-) create mode 100644 docs/SPIKEPrimeHub.html create mode 100644 docs/spikeprimehub.js.html create mode 100644 examples/vernie_ds4_remote.html diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index 6663abc..ef2a2d4 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -33,14 +33,14 @@ @@ -5585,7 +5585,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 7bf11f2..4dfb938 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -33,14 +33,14 @@ @@ -4188,7 +4188,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/Hub.html b/docs/Hub.html index 1101fb4..9228c9b 100644 --- a/docs/Hub.html +++ b/docs/Hub.html @@ -33,14 +33,14 @@ @@ -2467,7 +2467,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index b85f4b3..49e9c1d 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -33,14 +33,14 @@ @@ -4444,7 +4444,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/PUPHub.html b/docs/PUPHub.html index 3982326..ac5047c 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -33,14 +33,14 @@ @@ -5157,7 +5157,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index d2a42a7..b313ab3 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -33,14 +33,14 @@ @@ -3409,7 +3409,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/PoweredUP.html b/docs/PoweredUP.html index abed4b4..ebe441d 100644 --- a/docs/PoweredUP.html +++ b/docs/PoweredUP.html @@ -33,14 +33,14 @@ @@ -316,7 +316,7 @@ @@ -427,7 +427,7 @@ @@ -585,7 +585,7 @@ @@ -781,7 +781,7 @@ @@ -939,7 +939,7 @@ @@ -1018,7 +1018,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/SPIKEPrimeHub.html b/docs/SPIKEPrimeHub.html new file mode 100644 index 0000000..0771e58 --- /dev/null +++ b/docs/SPIKEPrimeHub.html @@ -0,0 +1,5679 @@ + + + + + + + node-poweredup Class: SPIKEPrimeHub + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: SPIKEPrimeHub

+
+ +
+ +

+ SPIKEPrimeHub +

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

new SPIKEPrimeHub()

+ + +
+
+ + +
+

The SPIKEPrimeHub is emitted if the discovered device is a SPIKE Prime 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> name

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

Name 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()

+ + +
+
+ + +
+

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:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + +
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).

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 + + + +
+
+ + + + + +
+ + + +
+
+

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 + + + +
+
+ + + + + +
+ + + +
+
+

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 + + + +
+
+ + + + + +
+ + + +
+
+

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 + + + +
+
+ + + + + +
+ +
+ + + + + +

Events

+ +
+ +
+
+

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 + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

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:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

tilt

+ + +
+
+ + +
+

Emits when a tilt sensor is activated.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +

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

x + + +number + + + + +
y + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html index 146bd74..d36ffce 100644 --- a/docs/WeDo2SmartHub.html +++ b/docs/WeDo2SmartHub.html @@ -33,14 +33,14 @@ @@ -5158,7 +5158,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/boostmovehub.js.html b/docs/boostmovehub.js.html index 86007eb..1f475a5 100644 --- a/docs/boostmovehub.js.html +++ b/docs/boostmovehub.js.html @@ -33,14 +33,14 @@ @@ -351,7 +351,7 @@ exports.BoostMoveHub = BoostMoveHub; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/classes.list.html b/docs/classes.list.html index 545ae99..aed4e1f 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -33,14 +33,14 @@ @@ -170,6 +170,9 @@
PUPRemote
+
SPIKEPrimeHub
+
+
WeDo2SmartHub
@@ -3853,7 +3856,7 @@ @@ -5595,6 +5598,1408 @@ + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

button

+ + +
+
+ + +
+

Emits when a button is pressed.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
button + + +string + + + + +
state + + +ButtonState + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

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:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

tilt

+ + +
+
+ + +
+

Emits when a tilt sensor is activated.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +

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

x + + +number + + + + +
y + + +number + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+

attach

+ + +
+
+ + +
+

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

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +
type + + +DeviceType + + + + +
+ + + + +
+ + + + + + + +
Inherited From:
+
+ +
+ + @@ -6681,7 +8086,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/consts.js.html b/docs/consts.js.html index c3d733b..745f27d 100644 --- a/docs/consts.js.html +++ b/docs/consts.js.html @@ -33,14 +33,14 @@ @@ -103,6 +103,7 @@ var HubType; 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["SPIKE_PRIME_HUB"] = 6] = "SPIKE_PRIME_HUB"; })(HubType = exports.HubType || (exports.HubType = {})); // tslint:disable-next-line exports.HubTypeNames = Object.keys(HubType).reduce((result, item) => { @@ -300,7 +301,7 @@ var BLECharacteristic; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/duplotrainbase.js.html b/docs/duplotrainbase.js.html index abfa1e3..4fe8e98 100644 --- a/docs/duplotrainbase.js.html +++ b/docs/duplotrainbase.js.html @@ -33,14 +33,14 @@ @@ -300,7 +300,7 @@ exports.DuploTrainBase = DuploTrainBase; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/global.html b/docs/global.html index 3452e84..049ba7c 100644 --- a/docs/global.html +++ b/docs/global.html @@ -33,14 +33,14 @@ @@ -356,7 +356,7 @@
@@ -571,7 +571,7 @@ @@ -954,7 +954,7 @@ @@ -1337,7 +1337,7 @@ @@ -1816,7 +1816,7 @@ @@ -2295,7 +2295,7 @@ @@ -2510,7 +2510,7 @@ @@ -2725,7 +2725,7 @@ @@ -3272,7 +3272,7 @@ Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/hub.js.html b/docs/hub.js.html index 31e7310..81cfab4 100644 --- a/docs/hub.js.html +++ b/docs/hub.js.html @@ -33,14 +33,14 @@ @@ -449,7 +449,7 @@ exports.Hub = Hub; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/index.html b/docs/index.html index 54ce455..51a0136 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,14 +33,14 @@ @@ -312,7 +312,7 @@ console.log("Scanning for Hubs...");

More examples are Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index 221bbfb..6388bce 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -33,14 +33,14 @@

@@ -503,7 +503,7 @@ exports.LPF2Hub = LPF2Hub; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/poweredup-node.js.html b/docs/poweredup-node.js.html index bf1061c..966fbf0 100644 --- a/docs/poweredup-node.js.html +++ b/docs/poweredup-node.js.html @@ -33,14 +33,14 @@ @@ -129,7 +129,7 @@ class PoweredUP extends events_1.EventEmitter { * Begin scanning for Powered UP Hub devices. * @method PoweredUP#scan */ - scan() { + async scan() { wantScan = true; if (!discoveryEventAttached) { noble.on("discover", this._discoveryEventHandler); @@ -139,6 +139,7 @@ class PoweredUP extends events_1.EventEmitter { debug("Scanning started"); startScanning(); } + return true; } /** * Stop scanning for Powered UP Hub devices. @@ -268,7 +269,7 @@ exports.PoweredUP = PoweredUP; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/puphub.js.html b/docs/puphub.js.html index 901eb12..0b42331 100644 --- a/docs/puphub.js.html +++ b/docs/puphub.js.html @@ -33,14 +33,14 @@ @@ -308,7 +308,7 @@ exports.PUPHub = PUPHub; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/pupremote.js.html b/docs/pupremote.js.html index 42016b9..3aad3a6 100644 --- a/docs/pupremote.js.html +++ b/docs/pupremote.js.html @@ -33,14 +33,14 @@ @@ -238,7 +238,7 @@ exports.PUPRemote = PUPRemote; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 34b9173..fb65403 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/wedo2smarthub.js.html b/docs/wedo2smarthub.js.html index 8795764..13f0dca 100644 --- a/docs/wedo2smarthub.js.html +++ b/docs/wedo2smarthub.js.html @@ -33,14 +33,14 @@ @@ -540,7 +540,7 @@ exports.WeDo2SmartHub = WeDo2SmartHub; Documentation generated by JSDoc 3.5.5 - on Wed Mar 20th 2019 + on Thu Apr 4th 2019 using the DocStrap template. diff --git a/examples/vernie_ds4_remote.html b/examples/vernie_ds4_remote.html new file mode 100644 index 0000000..ab5dd25 --- /dev/null +++ b/examples/vernie_ds4_remote.html @@ -0,0 +1,97 @@ + + + + +Vernie / PlayStation DualShock 4 Remote Control + + + + + + +

Vernie / PlayStation DualShock 4 Remote Control

+
+Scan for Vernie +
+
+Current Color:
 
+
+ + + \ No newline at end of file diff --git a/src/poweredup-browser.ts b/src/poweredup-browser.ts index f0e4903..8d10176 100644 --- a/src/poweredup-browser.ts +++ b/src/poweredup-browser.ts @@ -40,29 +40,36 @@ export class PoweredUP extends EventEmitter { */ public async scan () { - const device = await navigator.bluetooth.requestDevice({ - filters: [ - { - services: [ - Consts.BLEService.WEDO2_SMART_HUB - ] - }, - { - services: [ - Consts.BLEService.LPF2_HUB - ] - } - ], - optionalServices: [ - Consts.BLEService.WEDO2_SMART_HUB_2, - "battery_service", - "device_information" - ] - }); + try { - // @ts-ignore - const server = await device.gatt.connect(); - this._discoveryEventHandler.call(this, server); + const device = await navigator.bluetooth.requestDevice({ + filters: [ + { + services: [ + Consts.BLEService.WEDO2_SMART_HUB + ] + }, + { + services: [ + Consts.BLEService.LPF2_HUB + ] + } + ], + optionalServices: [ + Consts.BLEService.WEDO2_SMART_HUB_2, + "battery_service", + "device_information" + ] + }); + + // @ts-ignore + const server = await device.gatt.connect(); + this._discoveryEventHandler.call(this, server); + return true; + + } catch (err) { + return false; + } } diff --git a/src/poweredup-node.ts b/src/poweredup-node.ts index e02e2af..5981812 100644 --- a/src/poweredup-node.ts +++ b/src/poweredup-node.ts @@ -59,7 +59,7 @@ export class PoweredUP extends EventEmitter { * Begin scanning for Powered UP Hub devices. * @method PoweredUP#scan */ - public scan () { + public async scan () { wantScan = true; if (!discoveryEventAttached) { @@ -71,6 +71,8 @@ export class PoweredUP extends EventEmitter { debug("Scanning started"); startScanning(); } + + return true; }