Renamed Wedo2Hub to WeDo2SmartHub
This commit is contained in:
parent
d83b913a69
commit
b0d73761be
124
DOCS.md
124
DOCS.md
@ -3,7 +3,7 @@
|
|||||||
<dl>
|
<dl>
|
||||||
<dt><a href="#LPF2">LPF2</a> ⇐ <code>EventEmitter</code></dt>
|
<dt><a href="#LPF2">LPF2</a> ⇐ <code>EventEmitter</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
<dt><a href="#WeDo2Hub">WeDo2Hub</a> ⇐ <code>Hub</code></dt>
|
<dt><a href="#WeDo2SmartHub">WeDo2SmartHub</a> ⇐ <code>Hub</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
<dt><a href="#BoostMoveHub">BoostMoveHub</a> ⇐ <code>LPF2Hub</code></dt>
|
<dt><a href="#BoostMoveHub">BoostMoveHub</a> ⇐ <code>LPF2Hub</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
@ -64,47 +64,47 @@ Emits when a LPF2 Hub device is found.
|
|||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| hub | <code>WeDo2SmartHub</code> \| <code>LPF2Hub</code> |
|
| hub | [<code>WeDo2SmartHub</code>](#WeDo2SmartHub) \| <code>LPF2Hub</code> |
|
||||||
|
|
||||||
<a name="WeDo2Hub"></a>
|
<a name="WeDo2SmartHub"></a>
|
||||||
|
|
||||||
## WeDo2Hub ⇐ <code>Hub</code>
|
## WeDo2SmartHub ⇐ <code>Hub</code>
|
||||||
**Kind**: global class
|
**Kind**: global class
|
||||||
**Extends**: <code>Hub</code>
|
**Extends**: <code>Hub</code>
|
||||||
|
|
||||||
* [WeDo2Hub](#WeDo2Hub) ⇐ <code>Hub</code>
|
* [WeDo2SmartHub](#WeDo2SmartHub) ⇐ <code>Hub</code>
|
||||||
* [new WeDo2Hub()](#new_WeDo2Hub_new)
|
* [new WeDo2SmartHub()](#new_WeDo2SmartHub_new)
|
||||||
* [.name](#Hub+name)
|
* [.name](#Hub+name)
|
||||||
* [.uuid](#Hub+uuid)
|
* [.uuid](#Hub+uuid)
|
||||||
* [.rssi](#Hub+rssi)
|
* [.rssi](#Hub+rssi)
|
||||||
* [.batteryLevel](#Hub+batteryLevel)
|
* [.batteryLevel](#Hub+batteryLevel)
|
||||||
* [.setLEDColor(color)](#WeDo2Hub+setLEDColor) ⇒ <code>Promise</code>
|
* [.setLEDColor(color)](#WeDo2SmartHub+setLEDColor) ⇒ <code>Promise</code>
|
||||||
* [.setLEDRGB(red, green, blue)](#WeDo2Hub+setLEDRGB) ⇒ <code>Promise</code>
|
* [.setLEDRGB(red, green, blue)](#WeDo2SmartHub+setLEDRGB) ⇒ <code>Promise</code>
|
||||||
* [.setMotorSpeed(port, speed, [time])](#WeDo2Hub+setMotorSpeed) ⇒ <code>Promise</code>
|
* [.setMotorSpeed(port, speed, [time])](#WeDo2SmartHub+setMotorSpeed) ⇒ <code>Promise</code>
|
||||||
* [.playSound(frequency, time)](#WeDo2Hub+playSound) ⇒ <code>Promise</code>
|
* [.playSound(frequency, time)](#WeDo2SmartHub+playSound) ⇒ <code>Promise</code>
|
||||||
* [.connect()](#Hub+connect) ⇒ <code>Promise</code>
|
* [.connect()](#Hub+connect) ⇒ <code>Promise</code>
|
||||||
* [.disconnect()](#Hub+disconnect) ⇒ <code>Promise</code>
|
* [.disconnect()](#Hub+disconnect) ⇒ <code>Promise</code>
|
||||||
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ <code>Promise</code>
|
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ <code>Promise</code>
|
||||||
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ <code>Promise</code>
|
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ <code>Promise</code>
|
||||||
* [.sleep(delay)](#Hub+sleep) ⇒ <code>Promise</code>
|
* [.sleep(delay)](#Hub+sleep) ⇒ <code>Promise</code>
|
||||||
* [.wait(commands)](#Hub+wait) ⇒ <code>Promise</code>
|
* [.wait(commands)](#Hub+wait) ⇒ <code>Promise</code>
|
||||||
* ["button" (button, state)](#WeDo2Hub+event_button)
|
* ["button" (button, state)](#WeDo2SmartHub+event_button)
|
||||||
* ["distance" (port, distance)](#WeDo2Hub+event_distance)
|
* ["distance" (port, distance)](#WeDo2SmartHub+event_distance)
|
||||||
* ["color" (port, color)](#WeDo2Hub+event_color)
|
* ["color" (port, color)](#WeDo2SmartHub+event_color)
|
||||||
* ["tilt" (port, x, y)](#WeDo2Hub+event_tilt)
|
* ["tilt" (port, x, y)](#WeDo2SmartHub+event_tilt)
|
||||||
* ["rotate" (port, rotation)](#WeDo2Hub+event_rotate)
|
* ["rotate" (port, rotation)](#WeDo2SmartHub+event_rotate)
|
||||||
* ["attach" (port, type)](#Hub+event_attach)
|
* ["attach" (port, type)](#Hub+event_attach)
|
||||||
* ["detach" (port)](#Hub+event_detach)
|
* ["detach" (port)](#Hub+event_detach)
|
||||||
|
|
||||||
<a name="new_WeDo2Hub_new"></a>
|
<a name="new_WeDo2SmartHub_new"></a>
|
||||||
|
|
||||||
### new WeDo2Hub()
|
### new WeDo2SmartHub()
|
||||||
The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
||||||
|
|
||||||
<a name="Hub+name"></a>
|
<a name="Hub+name"></a>
|
||||||
|
|
||||||
### weDo2Hub.name
|
### weDo2SmartHub.name
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
|
|
||||||
<a name="Hub+uuid"></a>
|
<a name="Hub+uuid"></a>
|
||||||
|
|
||||||
### weDo2Hub.uuid
|
### weDo2SmartHub.uuid
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -125,8 +125,8 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
|
|
||||||
<a name="Hub+rssi"></a>
|
<a name="Hub+rssi"></a>
|
||||||
|
|
||||||
### weDo2Hub.rssi
|
### weDo2SmartHub.rssi
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -136,8 +136,8 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
|
|
||||||
<a name="Hub+batteryLevel"></a>
|
<a name="Hub+batteryLevel"></a>
|
||||||
|
|
||||||
### weDo2Hub.batteryLevel
|
### weDo2SmartHub.batteryLevel
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -145,24 +145,24 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| batteryLevel | <code>number</code> | Battery level of the hub (Percentage between 0-100) |
|
| batteryLevel | <code>number</code> | Battery level of the hub (Percentage between 0-100) |
|
||||||
|
|
||||||
<a name="WeDo2Hub+setLEDColor"></a>
|
<a name="WeDo2SmartHub+setLEDColor"></a>
|
||||||
|
|
||||||
### weDo2Hub.setLEDColor(color) ⇒ <code>Promise</code>
|
### weDo2SmartHub.setLEDColor(color) ⇒ <code>Promise</code>
|
||||||
Set the color of the LED on the Hub via a color value.
|
Set the color of the LED on the Hub via a color value.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| color | <code>number</code> | A number representing one of the LED color consts. |
|
| color | <code>number</code> | A number representing one of the LED color consts. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+setLEDRGB"></a>
|
<a name="WeDo2SmartHub+setLEDRGB"></a>
|
||||||
|
|
||||||
### weDo2Hub.setLEDRGB(red, green, blue) ⇒ <code>Promise</code>
|
### weDo2SmartHub.setLEDRGB(red, green, blue) ⇒ <code>Promise</code>
|
||||||
Set the color of the LED on the Hub via RGB values.
|
Set the color of the LED on the Hub via RGB values.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
@ -171,12 +171,12 @@ Set the color of the LED on the Hub via RGB values.
|
|||||||
| green | <code>number</code> |
|
| green | <code>number</code> |
|
||||||
| blue | <code>number</code> |
|
| blue | <code>number</code> |
|
||||||
|
|
||||||
<a name="WeDo2Hub+setMotorSpeed"></a>
|
<a name="WeDo2SmartHub+setMotorSpeed"></a>
|
||||||
|
|
||||||
### weDo2Hub.setMotorSpeed(port, speed, [time]) ⇒ <code>Promise</code>
|
### weDo2SmartHub.setMotorSpeed(port, speed, [time]) ⇒ <code>Promise</code>
|
||||||
Set the motor speed on a given port.
|
Set the motor speed on a given port.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
**Returns**: <code>Promise</code> - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -185,12 +185,12 @@ Set the motor speed on a given port.
|
|||||||
| speed | <code>number</code> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
|
| speed | <code>number</code> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
|
||||||
| [time] | <code>number</code> | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
|
| [time] | <code>number</code> | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+playSound"></a>
|
<a name="WeDo2SmartHub+playSound"></a>
|
||||||
|
|
||||||
### weDo2Hub.playSound(frequency, time) ⇒ <code>Promise</code>
|
### weDo2SmartHub.playSound(frequency, time) ⇒ <code>Promise</code>
|
||||||
Play a sound on the Hub's in-built buzzer
|
Play a sound on the Hub's in-built buzzer
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful completion of command (ie. once the sound has finished playing).
|
**Returns**: <code>Promise</code> - Resolved upon successful completion of command (ie. once the sound has finished playing).
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -200,25 +200,25 @@ Play a sound on the Hub's in-built buzzer
|
|||||||
|
|
||||||
<a name="Hub+connect"></a>
|
<a name="Hub+connect"></a>
|
||||||
|
|
||||||
### weDo2Hub.connect() ⇒ <code>Promise</code>
|
### weDo2SmartHub.connect() ⇒ <code>Promise</code>
|
||||||
Connect to the Hub.
|
Connect to the Hub.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Overrides**: [<code>connect</code>](#Hub+connect)
|
**Overrides**: [<code>connect</code>](#Hub+connect)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful connect.
|
**Returns**: <code>Promise</code> - Resolved upon successful connect.
|
||||||
<a name="Hub+disconnect"></a>
|
<a name="Hub+disconnect"></a>
|
||||||
|
|
||||||
### weDo2Hub.disconnect() ⇒ <code>Promise</code>
|
### weDo2SmartHub.disconnect() ⇒ <code>Promise</code>
|
||||||
Disconnect the Hub.
|
Disconnect the Hub.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful disconnect.
|
**Returns**: <code>Promise</code> - Resolved upon successful disconnect.
|
||||||
<a name="Hub+subscribe"></a>
|
<a name="Hub+subscribe"></a>
|
||||||
|
|
||||||
### weDo2Hub.subscribe(port, [mode]) ⇒ <code>Promise</code>
|
### weDo2SmartHub.subscribe(port, [mode]) ⇒ <code>Promise</code>
|
||||||
Subscribe to sensor notifications on a given port.
|
Subscribe to sensor notifications on a given port.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -228,10 +228,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
### weDo2Hub.unsubscribe(port) ⇒ <code>Promise</code>
|
### weDo2SmartHub.unsubscribe(port) ⇒ <code>Promise</code>
|
||||||
Unsubscribe to sensor notifications on a given port.
|
Unsubscribe to sensor notifications on a given port.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
@ -240,12 +240,12 @@ Unsubscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
<a name="Hub+sleep"></a>
|
<a name="Hub+sleep"></a>
|
||||||
|
|
||||||
### weDo2Hub.sleep(delay) ⇒ <code>Promise</code>
|
### weDo2SmartHub.sleep(delay) ⇒ <code>Promise</code>
|
||||||
Sleep a given amount of time.
|
Sleep a given amount of time.
|
||||||
|
|
||||||
This is a helper method to make it easier to add delays into a chain of commands.
|
This is a helper method to make it easier to add delays into a chain of commands.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved after the delay is finished.
|
**Returns**: <code>Promise</code> - Resolved after the delay is finished.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -254,60 +254,60 @@ This is a helper method to make it easier to add delays into a chain of commands
|
|||||||
|
|
||||||
<a name="Hub+wait"></a>
|
<a name="Hub+wait"></a>
|
||||||
|
|
||||||
### weDo2Hub.wait(commands) ⇒ <code>Promise</code>
|
### weDo2SmartHub.wait(commands) ⇒ <code>Promise</code>
|
||||||
Wait until a given list of concurrently running commands are complete.
|
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.
|
This is a helper method to make it easier to wait for concurrent commands to complete.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved after the commands are finished.
|
**Returns**: <code>Promise</code> - Resolved after the commands are finished.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| commands | <code>Array.<Promise.<any>></code> | Array of executing commands. |
|
| commands | <code>Array.<Promise.<any>></code> | Array of executing commands. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_button"></a>
|
<a name="WeDo2SmartHub+event_button"></a>
|
||||||
|
|
||||||
### "button" (button, state)
|
### "button" (button, state)
|
||||||
Emits when a button is pressed.
|
Emits when a button is pressed.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| button | <code>string</code> | |
|
| button | <code>string</code> | |
|
||||||
| state | <code>number</code> | A number representing one of the button state consts. |
|
| state | <code>number</code> | A number representing one of the button state consts. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_distance"></a>
|
<a name="WeDo2SmartHub+event_distance"></a>
|
||||||
|
|
||||||
### "distance" (port, distance)
|
### "distance" (port, distance)
|
||||||
Emits when a distance sensor is activated.
|
Emits when a distance sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | |
|
| port | <code>string</code> | |
|
||||||
| distance | <code>number</code> | Distance, in millimeters. |
|
| distance | <code>number</code> | Distance, in millimeters. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_color"></a>
|
<a name="WeDo2SmartHub+event_color"></a>
|
||||||
|
|
||||||
### "color" (port, color)
|
### "color" (port, color)
|
||||||
Emits when a color sensor is activated.
|
Emits when a color sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | |
|
| port | <code>string</code> | |
|
||||||
| color | <code>number</code> | A number representing one of the LED color consts. |
|
| color | <code>number</code> | A number representing one of the LED color consts. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_tilt"></a>
|
<a name="WeDo2SmartHub+event_tilt"></a>
|
||||||
|
|
||||||
### "tilt" (port, x, y)
|
### "tilt" (port, x, y)
|
||||||
Emits when a tilt sensor is activated.
|
Emits when a tilt sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
@ -315,12 +315,12 @@ Emits when a tilt sensor is activated.
|
|||||||
| x | <code>number</code> |
|
| x | <code>number</code> |
|
||||||
| y | <code>number</code> |
|
| y | <code>number</code> |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_rotate"></a>
|
<a name="WeDo2SmartHub+event_rotate"></a>
|
||||||
|
|
||||||
### "rotate" (port, rotation)
|
### "rotate" (port, rotation)
|
||||||
Emits when a rotation sensor is activated.
|
Emits when a rotation sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
@ -332,7 +332,7 @@ Emits when a rotation sensor is activated.
|
|||||||
### "attach" (port, type)
|
### "attach" (port, type)
|
||||||
Emits when a motor or sensor is attached to the Hub.
|
Emits when a motor or sensor is attached to the Hub.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
@ -344,7 +344,7 @@ Emits when a motor or sensor is attached to the Hub.
|
|||||||
### "detach" (port)
|
### "detach" (port)
|
||||||
Emits when an attached motor or sensor is detached from the Hub.
|
Emits when an attached motor or sensor is detached from the Hub.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
124
README.md
124
README.md
@ -53,7 +53,7 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R
|
|||||||
<dl>
|
<dl>
|
||||||
<dt><a href="#LPF2">LPF2</a> ⇐ <code>EventEmitter</code></dt>
|
<dt><a href="#LPF2">LPF2</a> ⇐ <code>EventEmitter</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
<dt><a href="#WeDo2Hub">WeDo2Hub</a> ⇐ <code>Hub</code></dt>
|
<dt><a href="#WeDo2SmartHub">WeDo2SmartHub</a> ⇐ <code>Hub</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
<dt><a href="#BoostMoveHub">BoostMoveHub</a> ⇐ <code>LPF2Hub</code></dt>
|
<dt><a href="#BoostMoveHub">BoostMoveHub</a> ⇐ <code>LPF2Hub</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
@ -114,47 +114,47 @@ Emits when a LPF2 Hub device is found.
|
|||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| hub | <code>WeDo2SmartHub</code> \| <code>LPF2Hub</code> |
|
| hub | [<code>WeDo2SmartHub</code>](#WeDo2SmartHub) \| <code>LPF2Hub</code> |
|
||||||
|
|
||||||
<a name="WeDo2Hub"></a>
|
<a name="WeDo2SmartHub"></a>
|
||||||
|
|
||||||
## WeDo2Hub ⇐ <code>Hub</code>
|
## WeDo2SmartHub ⇐ <code>Hub</code>
|
||||||
**Kind**: global class
|
**Kind**: global class
|
||||||
**Extends**: <code>Hub</code>
|
**Extends**: <code>Hub</code>
|
||||||
|
|
||||||
* [WeDo2Hub](#WeDo2Hub) ⇐ <code>Hub</code>
|
* [WeDo2SmartHub](#WeDo2SmartHub) ⇐ <code>Hub</code>
|
||||||
* [new WeDo2Hub()](#new_WeDo2Hub_new)
|
* [new WeDo2SmartHub()](#new_WeDo2SmartHub_new)
|
||||||
* [.name](#Hub+name)
|
* [.name](#Hub+name)
|
||||||
* [.uuid](#Hub+uuid)
|
* [.uuid](#Hub+uuid)
|
||||||
* [.rssi](#Hub+rssi)
|
* [.rssi](#Hub+rssi)
|
||||||
* [.batteryLevel](#Hub+batteryLevel)
|
* [.batteryLevel](#Hub+batteryLevel)
|
||||||
* [.setLEDColor(color)](#WeDo2Hub+setLEDColor) ⇒ <code>Promise</code>
|
* [.setLEDColor(color)](#WeDo2SmartHub+setLEDColor) ⇒ <code>Promise</code>
|
||||||
* [.setLEDRGB(red, green, blue)](#WeDo2Hub+setLEDRGB) ⇒ <code>Promise</code>
|
* [.setLEDRGB(red, green, blue)](#WeDo2SmartHub+setLEDRGB) ⇒ <code>Promise</code>
|
||||||
* [.setMotorSpeed(port, speed, [time])](#WeDo2Hub+setMotorSpeed) ⇒ <code>Promise</code>
|
* [.setMotorSpeed(port, speed, [time])](#WeDo2SmartHub+setMotorSpeed) ⇒ <code>Promise</code>
|
||||||
* [.playSound(frequency, time)](#WeDo2Hub+playSound) ⇒ <code>Promise</code>
|
* [.playSound(frequency, time)](#WeDo2SmartHub+playSound) ⇒ <code>Promise</code>
|
||||||
* [.connect()](#Hub+connect) ⇒ <code>Promise</code>
|
* [.connect()](#Hub+connect) ⇒ <code>Promise</code>
|
||||||
* [.disconnect()](#Hub+disconnect) ⇒ <code>Promise</code>
|
* [.disconnect()](#Hub+disconnect) ⇒ <code>Promise</code>
|
||||||
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ <code>Promise</code>
|
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ <code>Promise</code>
|
||||||
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ <code>Promise</code>
|
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ <code>Promise</code>
|
||||||
* [.sleep(delay)](#Hub+sleep) ⇒ <code>Promise</code>
|
* [.sleep(delay)](#Hub+sleep) ⇒ <code>Promise</code>
|
||||||
* [.wait(commands)](#Hub+wait) ⇒ <code>Promise</code>
|
* [.wait(commands)](#Hub+wait) ⇒ <code>Promise</code>
|
||||||
* ["button" (button, state)](#WeDo2Hub+event_button)
|
* ["button" (button, state)](#WeDo2SmartHub+event_button)
|
||||||
* ["distance" (port, distance)](#WeDo2Hub+event_distance)
|
* ["distance" (port, distance)](#WeDo2SmartHub+event_distance)
|
||||||
* ["color" (port, color)](#WeDo2Hub+event_color)
|
* ["color" (port, color)](#WeDo2SmartHub+event_color)
|
||||||
* ["tilt" (port, x, y)](#WeDo2Hub+event_tilt)
|
* ["tilt" (port, x, y)](#WeDo2SmartHub+event_tilt)
|
||||||
* ["rotate" (port, rotation)](#WeDo2Hub+event_rotate)
|
* ["rotate" (port, rotation)](#WeDo2SmartHub+event_rotate)
|
||||||
* ["attach" (port, type)](#Hub+event_attach)
|
* ["attach" (port, type)](#Hub+event_attach)
|
||||||
* ["detach" (port)](#Hub+event_detach)
|
* ["detach" (port)](#Hub+event_detach)
|
||||||
|
|
||||||
<a name="new_WeDo2Hub_new"></a>
|
<a name="new_WeDo2SmartHub_new"></a>
|
||||||
|
|
||||||
### new WeDo2Hub()
|
### new WeDo2SmartHub()
|
||||||
The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
||||||
|
|
||||||
<a name="Hub+name"></a>
|
<a name="Hub+name"></a>
|
||||||
|
|
||||||
### weDo2Hub.name
|
### weDo2SmartHub.name
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -164,8 +164,8 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
|
|
||||||
<a name="Hub+uuid"></a>
|
<a name="Hub+uuid"></a>
|
||||||
|
|
||||||
### weDo2Hub.uuid
|
### weDo2SmartHub.uuid
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -175,8 +175,8 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
|
|
||||||
<a name="Hub+rssi"></a>
|
<a name="Hub+rssi"></a>
|
||||||
|
|
||||||
### weDo2Hub.rssi
|
### weDo2SmartHub.rssi
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -186,8 +186,8 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
|
|
||||||
<a name="Hub+batteryLevel"></a>
|
<a name="Hub+batteryLevel"></a>
|
||||||
|
|
||||||
### weDo2Hub.batteryLevel
|
### weDo2SmartHub.batteryLevel
|
||||||
**Kind**: instance property of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance property of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Read only**: true
|
**Read only**: true
|
||||||
**Properties**
|
**Properties**
|
||||||
|
|
||||||
@ -195,24 +195,24 @@ The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| batteryLevel | <code>number</code> | Battery level of the hub (Percentage between 0-100) |
|
| batteryLevel | <code>number</code> | Battery level of the hub (Percentage between 0-100) |
|
||||||
|
|
||||||
<a name="WeDo2Hub+setLEDColor"></a>
|
<a name="WeDo2SmartHub+setLEDColor"></a>
|
||||||
|
|
||||||
### weDo2Hub.setLEDColor(color) ⇒ <code>Promise</code>
|
### weDo2SmartHub.setLEDColor(color) ⇒ <code>Promise</code>
|
||||||
Set the color of the LED on the Hub via a color value.
|
Set the color of the LED on the Hub via a color value.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| color | <code>number</code> | A number representing one of the LED color consts. |
|
| color | <code>number</code> | A number representing one of the LED color consts. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+setLEDRGB"></a>
|
<a name="WeDo2SmartHub+setLEDRGB"></a>
|
||||||
|
|
||||||
### weDo2Hub.setLEDRGB(red, green, blue) ⇒ <code>Promise</code>
|
### weDo2SmartHub.setLEDRGB(red, green, blue) ⇒ <code>Promise</code>
|
||||||
Set the color of the LED on the Hub via RGB values.
|
Set the color of the LED on the Hub via RGB values.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
@ -221,12 +221,12 @@ Set the color of the LED on the Hub via RGB values.
|
|||||||
| green | <code>number</code> |
|
| green | <code>number</code> |
|
||||||
| blue | <code>number</code> |
|
| blue | <code>number</code> |
|
||||||
|
|
||||||
<a name="WeDo2Hub+setMotorSpeed"></a>
|
<a name="WeDo2SmartHub+setMotorSpeed"></a>
|
||||||
|
|
||||||
### weDo2Hub.setMotorSpeed(port, speed, [time]) ⇒ <code>Promise</code>
|
### weDo2SmartHub.setMotorSpeed(port, speed, [time]) ⇒ <code>Promise</code>
|
||||||
Set the motor speed on a given port.
|
Set the motor speed on a given port.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
**Returns**: <code>Promise</code> - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -235,12 +235,12 @@ Set the motor speed on a given port.
|
|||||||
| speed | <code>number</code> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
|
| speed | <code>number</code> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
|
||||||
| [time] | <code>number</code> | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
|
| [time] | <code>number</code> | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+playSound"></a>
|
<a name="WeDo2SmartHub+playSound"></a>
|
||||||
|
|
||||||
### weDo2Hub.playSound(frequency, time) ⇒ <code>Promise</code>
|
### weDo2SmartHub.playSound(frequency, time) ⇒ <code>Promise</code>
|
||||||
Play a sound on the Hub's in-built buzzer
|
Play a sound on the Hub's in-built buzzer
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful completion of command (ie. once the sound has finished playing).
|
**Returns**: <code>Promise</code> - Resolved upon successful completion of command (ie. once the sound has finished playing).
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -250,25 +250,25 @@ Play a sound on the Hub's in-built buzzer
|
|||||||
|
|
||||||
<a name="Hub+connect"></a>
|
<a name="Hub+connect"></a>
|
||||||
|
|
||||||
### weDo2Hub.connect() ⇒ <code>Promise</code>
|
### weDo2SmartHub.connect() ⇒ <code>Promise</code>
|
||||||
Connect to the Hub.
|
Connect to the Hub.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Overrides**: [<code>connect</code>](#Hub+connect)
|
**Overrides**: [<code>connect</code>](#Hub+connect)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful connect.
|
**Returns**: <code>Promise</code> - Resolved upon successful connect.
|
||||||
<a name="Hub+disconnect"></a>
|
<a name="Hub+disconnect"></a>
|
||||||
|
|
||||||
### weDo2Hub.disconnect() ⇒ <code>Promise</code>
|
### weDo2SmartHub.disconnect() ⇒ <code>Promise</code>
|
||||||
Disconnect the Hub.
|
Disconnect the Hub.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful disconnect.
|
**Returns**: <code>Promise</code> - Resolved upon successful disconnect.
|
||||||
<a name="Hub+subscribe"></a>
|
<a name="Hub+subscribe"></a>
|
||||||
|
|
||||||
### weDo2Hub.subscribe(port, [mode]) ⇒ <code>Promise</code>
|
### weDo2SmartHub.subscribe(port, [mode]) ⇒ <code>Promise</code>
|
||||||
Subscribe to sensor notifications on a given port.
|
Subscribe to sensor notifications on a given port.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -278,10 +278,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
### weDo2Hub.unsubscribe(port) ⇒ <code>Promise</code>
|
### weDo2SmartHub.unsubscribe(port) ⇒ <code>Promise</code>
|
||||||
Unsubscribe to sensor notifications on a given port.
|
Unsubscribe to sensor notifications on a given port.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
@ -290,12 +290,12 @@ Unsubscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
<a name="Hub+sleep"></a>
|
<a name="Hub+sleep"></a>
|
||||||
|
|
||||||
### weDo2Hub.sleep(delay) ⇒ <code>Promise</code>
|
### weDo2SmartHub.sleep(delay) ⇒ <code>Promise</code>
|
||||||
Sleep a given amount of time.
|
Sleep a given amount of time.
|
||||||
|
|
||||||
This is a helper method to make it easier to add delays into a chain of commands.
|
This is a helper method to make it easier to add delays into a chain of commands.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved after the delay is finished.
|
**Returns**: <code>Promise</code> - Resolved after the delay is finished.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
@ -304,60 +304,60 @@ This is a helper method to make it easier to add delays into a chain of commands
|
|||||||
|
|
||||||
<a name="Hub+wait"></a>
|
<a name="Hub+wait"></a>
|
||||||
|
|
||||||
### weDo2Hub.wait(commands) ⇒ <code>Promise</code>
|
### weDo2SmartHub.wait(commands) ⇒ <code>Promise</code>
|
||||||
Wait until a given list of concurrently running commands are complete.
|
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.
|
This is a helper method to make it easier to wait for concurrent commands to complete.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
**Returns**: <code>Promise</code> - Resolved after the commands are finished.
|
**Returns**: <code>Promise</code> - Resolved after the commands are finished.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| commands | <code>Array.<Promise.<any>></code> | Array of executing commands. |
|
| commands | <code>Array.<Promise.<any>></code> | Array of executing commands. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_button"></a>
|
<a name="WeDo2SmartHub+event_button"></a>
|
||||||
|
|
||||||
### "button" (button, state)
|
### "button" (button, state)
|
||||||
Emits when a button is pressed.
|
Emits when a button is pressed.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| button | <code>string</code> | |
|
| button | <code>string</code> | |
|
||||||
| state | <code>number</code> | A number representing one of the button state consts. |
|
| state | <code>number</code> | A number representing one of the button state consts. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_distance"></a>
|
<a name="WeDo2SmartHub+event_distance"></a>
|
||||||
|
|
||||||
### "distance" (port, distance)
|
### "distance" (port, distance)
|
||||||
Emits when a distance sensor is activated.
|
Emits when a distance sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | |
|
| port | <code>string</code> | |
|
||||||
| distance | <code>number</code> | Distance, in millimeters. |
|
| distance | <code>number</code> | Distance, in millimeters. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_color"></a>
|
<a name="WeDo2SmartHub+event_color"></a>
|
||||||
|
|
||||||
### "color" (port, color)
|
### "color" (port, color)
|
||||||
Emits when a color sensor is activated.
|
Emits when a color sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | |
|
| port | <code>string</code> | |
|
||||||
| color | <code>number</code> | A number representing one of the LED color consts. |
|
| color | <code>number</code> | A number representing one of the LED color consts. |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_tilt"></a>
|
<a name="WeDo2SmartHub+event_tilt"></a>
|
||||||
|
|
||||||
### "tilt" (port, x, y)
|
### "tilt" (port, x, y)
|
||||||
Emits when a tilt sensor is activated.
|
Emits when a tilt sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
@ -365,12 +365,12 @@ Emits when a tilt sensor is activated.
|
|||||||
| x | <code>number</code> |
|
| x | <code>number</code> |
|
||||||
| y | <code>number</code> |
|
| y | <code>number</code> |
|
||||||
|
|
||||||
<a name="WeDo2Hub+event_rotate"></a>
|
<a name="WeDo2SmartHub+event_rotate"></a>
|
||||||
|
|
||||||
### "rotate" (port, rotation)
|
### "rotate" (port, rotation)
|
||||||
Emits when a rotation sensor is activated.
|
Emits when a rotation sensor is activated.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
@ -382,7 +382,7 @@ Emits when a rotation sensor is activated.
|
|||||||
### "attach" (port, type)
|
### "attach" (port, type)
|
||||||
Emits when a motor or sensor is attached to the Hub.
|
Emits when a motor or sensor is attached to the Hub.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
@ -394,7 +394,7 @@ Emits when a motor or sensor is attached to the Hub.
|
|||||||
### "detach" (port)
|
### "detach" (port)
|
||||||
Emits when an attached motor or sensor is detached from the Hub.
|
Emits when an attached motor or sensor is detached from the Hub.
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: event emitted by [<code>WeDo2SmartHub</code>](#WeDo2SmartHub)
|
||||||
|
|
||||||
| Param | Type |
|
| Param | Type |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"types": "dist/lpf2.d.ts",
|
"types": "dist/lpf2.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tslint -c tslint.json \"*.ts\" && tsc",
|
"build": "tslint -c tslint.json \"*.ts\" && tsc",
|
||||||
"docs": "jsdoc2md dist/lpf2.js dist/lpf2hub.js dist/wedo2hub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/hub.js dist/consts.js > DOCS.md",
|
"docs": "jsdoc2md dist/lpf2.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/hub.js dist/consts.js > DOCS.md",
|
||||||
"readme": "cat ABOUT.md DOCS.md > README.md",
|
"readme": "cat ABOUT.md DOCS.md > README.md",
|
||||||
"all": "npm run build && npm run docs && npm run readme",
|
"all": "npm run build && npm run docs && npm run readme",
|
||||||
"prepublishOnly": "tsc"
|
"prepublishOnly": "tsc"
|
||||||
|
@ -7,12 +7,12 @@ import * as Consts from "./consts";
|
|||||||
|
|
||||||
import Debug = require("debug");
|
import Debug = require("debug");
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
const debug = Debug("wedo2hub");
|
const debug = Debug("wedo2smarthub");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The WeDo2Hub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
* The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
||||||
* @class WeDo2Hub
|
* @class WeDo2SmartHub
|
||||||
* @extends Hub
|
* @extends Hub
|
||||||
*/
|
*/
|
||||||
export class WeDo2SmartHub extends Hub {
|
export class WeDo2SmartHub extends Hub {
|
||||||
@ -55,7 +55,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color of the LED on the Hub via a color value.
|
* Set the color of the LED on the Hub via a color value.
|
||||||
* @method WeDo2Hub#setLEDColor
|
* @method WeDo2SmartHub#setLEDColor
|
||||||
* @param {number} color A number representing one of the LED color consts.
|
* @param {number} color A number representing one of the LED color consts.
|
||||||
* @returns {Promise} Resolved upon successful issuance of command.
|
* @returns {Promise} Resolved upon successful issuance of command.
|
||||||
*/
|
*/
|
||||||
@ -75,7 +75,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color of the LED on the Hub via RGB values.
|
* Set the color of the LED on the Hub via RGB values.
|
||||||
* @method WeDo2Hub#setLEDRGB
|
* @method WeDo2SmartHub#setLEDRGB
|
||||||
* @param {number} red
|
* @param {number} red
|
||||||
* @param {number} green
|
* @param {number} green
|
||||||
* @param {number} blue
|
* @param {number} blue
|
||||||
@ -94,7 +94,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the motor speed on a given port.
|
* Set the motor speed on a given port.
|
||||||
* @method WeDo2Hub#setMotorSpeed
|
* @method WeDo2SmartHub#setMotorSpeed
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
* @param {number} speed 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 to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
|
* @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
|
||||||
@ -117,7 +117,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Play a sound on the Hub's in-built buzzer
|
* Play a sound on the Hub's in-built buzzer
|
||||||
* @method WeDo2Hub#playSound
|
* @method WeDo2SmartHub#playSound
|
||||||
* @param {number} frequency
|
* @param {number} frequency
|
||||||
* @param {number} time How long the sound should play for (in milliseconds).
|
* @param {number} time How long the sound should play for (in milliseconds).
|
||||||
* @returns {Promise} Resolved upon successful completion of command (ie. once the sound has finished playing).
|
* @returns {Promise} Resolved upon successful completion of command (ie. once the sound has finished playing).
|
||||||
@ -181,7 +181,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
if (data[0] === 0x01) {
|
if (data[0] === 0x01) {
|
||||||
/**
|
/**
|
||||||
* Emits when a button is pressed.
|
* Emits when a button is pressed.
|
||||||
* @event WeDo2Hub#button
|
* @event WeDo2SmartHub#button
|
||||||
* @param {string} button
|
* @param {string} button
|
||||||
* @param {number} state A number representing one of the button state consts.
|
* @param {number} state A number representing one of the button state consts.
|
||||||
*/
|
*/
|
||||||
@ -208,7 +208,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Emits when a distance sensor is activated.
|
* Emits when a distance sensor is activated.
|
||||||
* @event WeDo2Hub#distance
|
* @event WeDo2SmartHub#distance
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number} distance Distance, in millimeters.
|
* @param {number} distance Distance, in millimeters.
|
||||||
*/
|
*/
|
||||||
@ -220,7 +220,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
const distance = data[2];
|
const distance = data[2];
|
||||||
/**
|
/**
|
||||||
* Emits when a color sensor is activated.
|
* Emits when a color sensor is activated.
|
||||||
* @event WeDo2Hub#color
|
* @event WeDo2SmartHub#color
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number} color A number representing one of the LED color consts.
|
* @param {number} color A number representing one of the LED color consts.
|
||||||
*/
|
*/
|
||||||
@ -239,7 +239,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Emits when a tilt sensor is activated.
|
* Emits when a tilt sensor is activated.
|
||||||
* @event WeDo2Hub#tilt
|
* @event WeDo2SmartHub#tilt
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number} x
|
* @param {number} x
|
||||||
* @param {number} y
|
* @param {number} y
|
||||||
@ -252,7 +252,7 @@ export class WeDo2SmartHub extends Hub {
|
|||||||
const rotation = data.readInt32LE(2);
|
const rotation = data.readInt32LE(2);
|
||||||
/**
|
/**
|
||||||
* Emits when a rotation sensor is activated.
|
* Emits when a rotation sensor is activated.
|
||||||
* @event WeDo2Hub#rotate
|
* @event WeDo2SmartHub#rotate
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number} rotation
|
* @param {number} rotation
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user