Better motor control, better documentation
This commit is contained in:
parent
07ea88d8b8
commit
f782317468
192
DOCS.md
192
DOCS.md
@ -3,11 +3,9 @@
|
|||||||
<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="#LPF2Hub">LPF2Hub</a> ⇐ <code><a href="#Hub">Hub</a></code></dt>
|
<dt><a href="#LPF2Hub">LPF2Hub</a> ⇐ <code>Hub</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
<dt><a href="#WeDo2Hub">WeDo2Hub</a> ⇐ <code><a href="#Hub">Hub</a></code></dt>
|
<dt><a href="#WeDo2Hub">WeDo2Hub</a> ⇐ <code>Hub</code></dt>
|
||||||
<dd></dd>
|
|
||||||
<dt><a href="#Hub">Hub</a> ⇐ <code>EventEmitter</code></dt>
|
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
@ -20,8 +18,8 @@
|
|||||||
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
||||||
* [.scan()](#LPF2+scan)
|
* [.scan()](#LPF2+scan)
|
||||||
* [.stop()](#LPF2+stop)
|
* [.stop()](#LPF2+stop)
|
||||||
* [.getConnectedHubByUUID(uuid)](#LPF2+getConnectedHubByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
* [.getConnectedHubByUUID(uuid)](#LPF2+getConnectedHubByUUID) ⇒ <code>Hub</code> \| <code>null</code>
|
||||||
* [.getConnectedHubs()](#LPF2+getConnectedHubs) ⇒ [<code>Array.<Hub></code>](#Hub)
|
* [.getConnectedHubs()](#LPF2+getConnectedHubs) ⇒ <code>Array.<Hub></code>
|
||||||
* ["discover" (hub)](#LPF2+event_discover)
|
* ["discover" (hub)](#LPF2+event_discover)
|
||||||
|
|
||||||
<a name="LPF2+scan"></a>
|
<a name="LPF2+scan"></a>
|
||||||
@ -38,7 +36,7 @@ Stop scanning for LPF2 Hub devices.
|
|||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
<a name="LPF2+getConnectedHubByUUID"></a>
|
<a name="LPF2+getConnectedHubByUUID"></a>
|
||||||
|
|
||||||
### lpF2.getConnectedHubByUUID(uuid) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
### lpF2.getConnectedHubByUUID(uuid) ⇒ <code>Hub</code> \| <code>null</code>
|
||||||
Retrieve a LPF2 Hub by UUID.
|
Retrieve a LPF2 Hub by UUID.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
@ -49,7 +47,7 @@ Retrieve a LPF2 Hub by UUID.
|
|||||||
|
|
||||||
<a name="LPF2+getConnectedHubs"></a>
|
<a name="LPF2+getConnectedHubs"></a>
|
||||||
|
|
||||||
### lpF2.getConnectedHubs() ⇒ [<code>Array.<Hub></code>](#Hub)
|
### lpF2.getConnectedHubs() ⇒ <code>Array.<Hub></code>
|
||||||
Retrieve a list of LPF2 Hubs.
|
Retrieve a list of LPF2 Hubs.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
@ -66,11 +64,11 @@ Emits when a LPF2 Hub device is found.
|
|||||||
|
|
||||||
<a name="LPF2Hub"></a>
|
<a name="LPF2Hub"></a>
|
||||||
|
|
||||||
## LPF2Hub ⇐ [<code>Hub</code>](#Hub)
|
## LPF2Hub ⇐ <code>Hub</code>
|
||||||
**Kind**: global class
|
**Kind**: global class
|
||||||
**Extends**: [<code>Hub</code>](#Hub)
|
**Extends**: <code>Hub</code>
|
||||||
|
|
||||||
* [LPF2Hub](#LPF2Hub) ⇐ [<code>Hub</code>](#Hub)
|
* [LPF2Hub](#LPF2Hub) ⇐ <code>Hub</code>
|
||||||
* [new LPF2Hub()](#new_LPF2Hub_new)
|
* [new LPF2Hub()](#new_LPF2Hub_new)
|
||||||
* [.name](#Hub+name)
|
* [.name](#Hub+name)
|
||||||
* [.uuid](#Hub+uuid)
|
* [.uuid](#Hub+uuid)
|
||||||
@ -348,11 +346,11 @@ Emits when an attached motor or sensor is detached from the Hub.
|
|||||||
|
|
||||||
<a name="WeDo2Hub"></a>
|
<a name="WeDo2Hub"></a>
|
||||||
|
|
||||||
## WeDo2Hub ⇐ [<code>Hub</code>](#Hub)
|
## WeDo2Hub ⇐ <code>Hub</code>
|
||||||
**Kind**: global class
|
**Kind**: global class
|
||||||
**Extends**: [<code>Hub</code>](#Hub)
|
**Extends**: <code>Hub</code>
|
||||||
|
|
||||||
* [WeDo2Hub](#WeDo2Hub) ⇐ [<code>Hub</code>](#Hub)
|
* [WeDo2Hub](#WeDo2Hub) ⇐ <code>Hub</code>
|
||||||
* [new WeDo2Hub()](#new_WeDo2Hub_new)
|
* [new WeDo2Hub()](#new_WeDo2Hub_new)
|
||||||
* [.name](#Hub+name)
|
* [.name](#Hub+name)
|
||||||
* [.uuid](#Hub+uuid)
|
* [.uuid](#Hub+uuid)
|
||||||
@ -642,169 +640,3 @@ Emits when an attached motor or sensor is detached from the Hub.
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| port | <code>string</code> |
|
| port | <code>string</code> |
|
||||||
|
|
||||||
<a name="Hub"></a>
|
|
||||||
|
|
||||||
## Hub ⇐ <code>EventEmitter</code>
|
|
||||||
**Kind**: global class
|
|
||||||
**Extends**: <code>EventEmitter</code>
|
|
||||||
|
|
||||||
* [Hub](#Hub) ⇐ <code>EventEmitter</code>
|
|
||||||
* [.name](#Hub+name)
|
|
||||||
* [.uuid](#Hub+uuid)
|
|
||||||
* [.rssi](#Hub+rssi)
|
|
||||||
* [.batteryLevel](#Hub+batteryLevel)
|
|
||||||
* [.current](#Hub+current)
|
|
||||||
* [.connect()](#Hub+connect) ⇒ <code>Promise</code>
|
|
||||||
* [.disconnect()](#Hub+disconnect) ⇒ <code>Promise</code>
|
|
||||||
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ <code>Promise</code>
|
|
||||||
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ <code>Promise</code>
|
|
||||||
* [.sleep(delay)](#Hub+sleep) ⇒ <code>Promise</code>
|
|
||||||
* [.wait(commands)](#Hub+wait) ⇒ <code>Promise</code>
|
|
||||||
* ["attach" (port, type)](#Hub+event_attach)
|
|
||||||
* ["detach" (port)](#Hub+event_detach)
|
|
||||||
|
|
||||||
<a name="Hub+name"></a>
|
|
||||||
|
|
||||||
### hub.name
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| name | <code>string</code> | Name of the hub |
|
|
||||||
|
|
||||||
<a name="Hub+uuid"></a>
|
|
||||||
|
|
||||||
### hub.uuid
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| uuid | <code>string</code> | UUID of the hub |
|
|
||||||
|
|
||||||
<a name="Hub+rssi"></a>
|
|
||||||
|
|
||||||
### hub.rssi
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| rssi | <code>number</code> | Signal strength of the hub |
|
|
||||||
|
|
||||||
<a name="Hub+batteryLevel"></a>
|
|
||||||
|
|
||||||
### hub.batteryLevel
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| batteryLevel | <code>number</code> | Battery level of the hub (Percentage between 0-100) |
|
|
||||||
|
|
||||||
<a name="Hub+current"></a>
|
|
||||||
|
|
||||||
### hub.current
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| current | <code>number</code> | Current usage of the hub (Amps) |
|
|
||||||
|
|
||||||
<a name="Hub+connect"></a>
|
|
||||||
|
|
||||||
### hub.connect() ⇒ <code>Promise</code>
|
|
||||||
Connect to the Hub.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful connect.
|
|
||||||
<a name="Hub+disconnect"></a>
|
|
||||||
|
|
||||||
### hub.disconnect() ⇒ <code>Promise</code>
|
|
||||||
Disconnect the Hub.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful disconnect.
|
|
||||||
<a name="Hub+subscribe"></a>
|
|
||||||
|
|
||||||
### hub.subscribe(port, [mode]) ⇒ <code>Promise</code>
|
|
||||||
Subscribe to sensor notifications on a given port.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| port | <code>string</code> | |
|
|
||||||
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
|
||||||
|
|
||||||
### hub.unsubscribe(port) ⇒ <code>Promise</code>
|
|
||||||
Unsubscribe to sensor notifications on a given port.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
|
||||||
|
|
||||||
| Param | Type |
|
|
||||||
| --- | --- |
|
|
||||||
| port | <code>string</code> |
|
|
||||||
|
|
||||||
<a name="Hub+sleep"></a>
|
|
||||||
|
|
||||||
### hub.sleep(delay) ⇒ <code>Promise</code>
|
|
||||||
Sleep a given amount of time.
|
|
||||||
|
|
||||||
This is a helper method to make it easier to add delays into a chain of commands.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved after the delay is finished.
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| delay | <code>number</code> | How long to sleep (in milliseconds). |
|
|
||||||
|
|
||||||
<a name="Hub+wait"></a>
|
|
||||||
|
|
||||||
### hub.wait(commands) ⇒ <code>Promise</code>
|
|
||||||
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.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved after the commands are finished.
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| commands | <code>Array.<Promise.<any>></code> | Array of executing commands. |
|
|
||||||
|
|
||||||
<a name="Hub+event_attach"></a>
|
|
||||||
|
|
||||||
### "attach" (port, type)
|
|
||||||
Emits when a motor or sensor is attached to the Hub.
|
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>Hub</code>](#Hub)
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| port | <code>string</code> | |
|
|
||||||
| type | <code>number</code> | A number representing one of the peripheral consts. |
|
|
||||||
|
|
||||||
<a name="Hub+event_detach"></a>
|
|
||||||
|
|
||||||
### "detach" (port)
|
|
||||||
Emits when an attached motor or sensor is detached from the Hub.
|
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>Hub</code>](#Hub)
|
|
||||||
|
|
||||||
| Param | Type |
|
|
||||||
| --- | --- |
|
|
||||||
| port | <code>string</code> |
|
|
||||||
|
|
||||||
|
192
README.md
192
README.md
@ -53,11 +53,9 @@ 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="#LPF2Hub">LPF2Hub</a> ⇐ <code><a href="#Hub">Hub</a></code></dt>
|
<dt><a href="#LPF2Hub">LPF2Hub</a> ⇐ <code>Hub</code></dt>
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
<dt><a href="#WeDo2Hub">WeDo2Hub</a> ⇐ <code><a href="#Hub">Hub</a></code></dt>
|
<dt><a href="#WeDo2Hub">WeDo2Hub</a> ⇐ <code>Hub</code></dt>
|
||||||
<dd></dd>
|
|
||||||
<dt><a href="#Hub">Hub</a> ⇐ <code>EventEmitter</code></dt>
|
|
||||||
<dd></dd>
|
<dd></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
@ -70,8 +68,8 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R
|
|||||||
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
||||||
* [.scan()](#LPF2+scan)
|
* [.scan()](#LPF2+scan)
|
||||||
* [.stop()](#LPF2+stop)
|
* [.stop()](#LPF2+stop)
|
||||||
* [.getConnectedHubByUUID(uuid)](#LPF2+getConnectedHubByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
* [.getConnectedHubByUUID(uuid)](#LPF2+getConnectedHubByUUID) ⇒ <code>Hub</code> \| <code>null</code>
|
||||||
* [.getConnectedHubs()](#LPF2+getConnectedHubs) ⇒ [<code>Array.<Hub></code>](#Hub)
|
* [.getConnectedHubs()](#LPF2+getConnectedHubs) ⇒ <code>Array.<Hub></code>
|
||||||
* ["discover" (hub)](#LPF2+event_discover)
|
* ["discover" (hub)](#LPF2+event_discover)
|
||||||
|
|
||||||
<a name="LPF2+scan"></a>
|
<a name="LPF2+scan"></a>
|
||||||
@ -88,7 +86,7 @@ Stop scanning for LPF2 Hub devices.
|
|||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
<a name="LPF2+getConnectedHubByUUID"></a>
|
<a name="LPF2+getConnectedHubByUUID"></a>
|
||||||
|
|
||||||
### lpF2.getConnectedHubByUUID(uuid) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
### lpF2.getConnectedHubByUUID(uuid) ⇒ <code>Hub</code> \| <code>null</code>
|
||||||
Retrieve a LPF2 Hub by UUID.
|
Retrieve a LPF2 Hub by UUID.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
@ -99,7 +97,7 @@ Retrieve a LPF2 Hub by UUID.
|
|||||||
|
|
||||||
<a name="LPF2+getConnectedHubs"></a>
|
<a name="LPF2+getConnectedHubs"></a>
|
||||||
|
|
||||||
### lpF2.getConnectedHubs() ⇒ [<code>Array.<Hub></code>](#Hub)
|
### lpF2.getConnectedHubs() ⇒ <code>Array.<Hub></code>
|
||||||
Retrieve a list of LPF2 Hubs.
|
Retrieve a list of LPF2 Hubs.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
@ -116,11 +114,11 @@ Emits when a LPF2 Hub device is found.
|
|||||||
|
|
||||||
<a name="LPF2Hub"></a>
|
<a name="LPF2Hub"></a>
|
||||||
|
|
||||||
## LPF2Hub ⇐ [<code>Hub</code>](#Hub)
|
## LPF2Hub ⇐ <code>Hub</code>
|
||||||
**Kind**: global class
|
**Kind**: global class
|
||||||
**Extends**: [<code>Hub</code>](#Hub)
|
**Extends**: <code>Hub</code>
|
||||||
|
|
||||||
* [LPF2Hub](#LPF2Hub) ⇐ [<code>Hub</code>](#Hub)
|
* [LPF2Hub](#LPF2Hub) ⇐ <code>Hub</code>
|
||||||
* [new LPF2Hub()](#new_LPF2Hub_new)
|
* [new LPF2Hub()](#new_LPF2Hub_new)
|
||||||
* [.name](#Hub+name)
|
* [.name](#Hub+name)
|
||||||
* [.uuid](#Hub+uuid)
|
* [.uuid](#Hub+uuid)
|
||||||
@ -398,11 +396,11 @@ Emits when an attached motor or sensor is detached from the Hub.
|
|||||||
|
|
||||||
<a name="WeDo2Hub"></a>
|
<a name="WeDo2Hub"></a>
|
||||||
|
|
||||||
## WeDo2Hub ⇐ [<code>Hub</code>](#Hub)
|
## WeDo2Hub ⇐ <code>Hub</code>
|
||||||
**Kind**: global class
|
**Kind**: global class
|
||||||
**Extends**: [<code>Hub</code>](#Hub)
|
**Extends**: <code>Hub</code>
|
||||||
|
|
||||||
* [WeDo2Hub](#WeDo2Hub) ⇐ [<code>Hub</code>](#Hub)
|
* [WeDo2Hub](#WeDo2Hub) ⇐ <code>Hub</code>
|
||||||
* [new WeDo2Hub()](#new_WeDo2Hub_new)
|
* [new WeDo2Hub()](#new_WeDo2Hub_new)
|
||||||
* [.name](#Hub+name)
|
* [.name](#Hub+name)
|
||||||
* [.uuid](#Hub+uuid)
|
* [.uuid](#Hub+uuid)
|
||||||
@ -692,169 +690,3 @@ Emits when an attached motor or sensor is detached from the Hub.
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| port | <code>string</code> |
|
| port | <code>string</code> |
|
||||||
|
|
||||||
<a name="Hub"></a>
|
|
||||||
|
|
||||||
## Hub ⇐ <code>EventEmitter</code>
|
|
||||||
**Kind**: global class
|
|
||||||
**Extends**: <code>EventEmitter</code>
|
|
||||||
|
|
||||||
* [Hub](#Hub) ⇐ <code>EventEmitter</code>
|
|
||||||
* [.name](#Hub+name)
|
|
||||||
* [.uuid](#Hub+uuid)
|
|
||||||
* [.rssi](#Hub+rssi)
|
|
||||||
* [.batteryLevel](#Hub+batteryLevel)
|
|
||||||
* [.current](#Hub+current)
|
|
||||||
* [.connect()](#Hub+connect) ⇒ <code>Promise</code>
|
|
||||||
* [.disconnect()](#Hub+disconnect) ⇒ <code>Promise</code>
|
|
||||||
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ <code>Promise</code>
|
|
||||||
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ <code>Promise</code>
|
|
||||||
* [.sleep(delay)](#Hub+sleep) ⇒ <code>Promise</code>
|
|
||||||
* [.wait(commands)](#Hub+wait) ⇒ <code>Promise</code>
|
|
||||||
* ["attach" (port, type)](#Hub+event_attach)
|
|
||||||
* ["detach" (port)](#Hub+event_detach)
|
|
||||||
|
|
||||||
<a name="Hub+name"></a>
|
|
||||||
|
|
||||||
### hub.name
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| name | <code>string</code> | Name of the hub |
|
|
||||||
|
|
||||||
<a name="Hub+uuid"></a>
|
|
||||||
|
|
||||||
### hub.uuid
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| uuid | <code>string</code> | UUID of the hub |
|
|
||||||
|
|
||||||
<a name="Hub+rssi"></a>
|
|
||||||
|
|
||||||
### hub.rssi
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| rssi | <code>number</code> | Signal strength of the hub |
|
|
||||||
|
|
||||||
<a name="Hub+batteryLevel"></a>
|
|
||||||
|
|
||||||
### hub.batteryLevel
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| batteryLevel | <code>number</code> | Battery level of the hub (Percentage between 0-100) |
|
|
||||||
|
|
||||||
<a name="Hub+current"></a>
|
|
||||||
|
|
||||||
### hub.current
|
|
||||||
**Kind**: instance property of [<code>Hub</code>](#Hub)
|
|
||||||
**Read only**: true
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| current | <code>number</code> | Current usage of the hub (Amps) |
|
|
||||||
|
|
||||||
<a name="Hub+connect"></a>
|
|
||||||
|
|
||||||
### hub.connect() ⇒ <code>Promise</code>
|
|
||||||
Connect to the Hub.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful connect.
|
|
||||||
<a name="Hub+disconnect"></a>
|
|
||||||
|
|
||||||
### hub.disconnect() ⇒ <code>Promise</code>
|
|
||||||
Disconnect the Hub.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful disconnect.
|
|
||||||
<a name="Hub+subscribe"></a>
|
|
||||||
|
|
||||||
### hub.subscribe(port, [mode]) ⇒ <code>Promise</code>
|
|
||||||
Subscribe to sensor notifications on a given port.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| port | <code>string</code> | |
|
|
||||||
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
|
||||||
|
|
||||||
### hub.unsubscribe(port) ⇒ <code>Promise</code>
|
|
||||||
Unsubscribe to sensor notifications on a given port.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved upon successful issuance of command.
|
|
||||||
|
|
||||||
| Param | Type |
|
|
||||||
| --- | --- |
|
|
||||||
| port | <code>string</code> |
|
|
||||||
|
|
||||||
<a name="Hub+sleep"></a>
|
|
||||||
|
|
||||||
### hub.sleep(delay) ⇒ <code>Promise</code>
|
|
||||||
Sleep a given amount of time.
|
|
||||||
|
|
||||||
This is a helper method to make it easier to add delays into a chain of commands.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved after the delay is finished.
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| delay | <code>number</code> | How long to sleep (in milliseconds). |
|
|
||||||
|
|
||||||
<a name="Hub+wait"></a>
|
|
||||||
|
|
||||||
### hub.wait(commands) ⇒ <code>Promise</code>
|
|
||||||
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.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
|
||||||
**Returns**: <code>Promise</code> - Resolved after the commands are finished.
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| commands | <code>Array.<Promise.<any>></code> | Array of executing commands. |
|
|
||||||
|
|
||||||
<a name="Hub+event_attach"></a>
|
|
||||||
|
|
||||||
### "attach" (port, type)
|
|
||||||
Emits when a motor or sensor is attached to the Hub.
|
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>Hub</code>](#Hub)
|
|
||||||
|
|
||||||
| Param | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| port | <code>string</code> | |
|
|
||||||
| type | <code>number</code> | A number representing one of the peripheral consts. |
|
|
||||||
|
|
||||||
<a name="Hub+event_detach"></a>
|
|
||||||
|
|
||||||
### "detach" (port)
|
|
||||||
Emits when an attached motor or sensor is detached from the Hub.
|
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>Hub</code>](#Hub)
|
|
||||||
|
|
||||||
| Param | Type |
|
|
||||||
| --- | --- |
|
|
||||||
| port | <code>string</code> |
|
|
||||||
|
|
||||||
|
1
hub.ts
1
hub.ts
@ -11,6 +11,7 @@ const debug = Debug("hub");
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Hub
|
* @class Hub
|
||||||
|
* @ignore
|
||||||
* @extends EventEmitter
|
* @extends EventEmitter
|
||||||
*/
|
*/
|
||||||
export class Hub extends EventEmitter {
|
export class Hub extends EventEmitter {
|
||||||
|
@ -93,15 +93,12 @@ export class LPF2Hub extends Hub {
|
|||||||
*/
|
*/
|
||||||
public setLEDColor (color: number | boolean) {
|
public setLEDColor (color: number | boolean) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let data = Buffer.from([0x05, 0x00, 0x01, 0x02, 0x02]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
|
|
||||||
if (color === false) {
|
if (color === false) {
|
||||||
color = 0;
|
color = 0;
|
||||||
}
|
}
|
||||||
|
let data = Buffer.from([0x08, 0x00, 0x81, 0x32, 0x11, 0x51, 0x00, color]);
|
||||||
if (this.type === Consts.Hubs.POWERED_UP_REMOTE) {
|
if (this.type === Consts.Hubs.POWERED_UP_REMOTE) {
|
||||||
data = Buffer.from([0x08, 0x00, 0x81, 0x34, 0x11, 0x51, 0x00, color]);
|
data = Buffer.from([0x08, 0x00, 0x81, 0x34, 0x11, 0x51, 0x00, color]);
|
||||||
} else {
|
|
||||||
data = Buffer.from([0x08, 0x00, 0x81, 0x32, 0x11, 0x51, 0x00, color]);
|
|
||||||
}
|
}
|
||||||
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
|
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
|
||||||
return resolve();
|
return resolve();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user