From 4db9a6528c0902544ea94e34b4c813649cc53304 Mon Sep 17 00:00:00 2001 From: Nathan Kunicki Date: Wed, 1 Aug 2018 11:19:55 +0100 Subject: [PATCH] Docs maintain class hierarchy --- DOCS.md | 681 +++++++++++++++++++++++++++++++++++++++++++++++- README.md | 681 +++++++++++++++++++++++++++++++++++++++++++++++- boostmovehub.ts | 1 + package.json | 2 +- puphub.ts | 1 + pupremote.ts | 1 + 6 files changed, 1360 insertions(+), 7 deletions(-) diff --git a/DOCS.md b/DOCS.md index 458d732..eb64484 100644 --- a/DOCS.md +++ b/DOCS.md @@ -354,19 +354,92 @@ Emits when an attached motor or sensor is detached from the Hub. ## BoostMoveHub ⇐ LPF2Hub **Kind**: global class -**Extends**: LPF2Hub +**Extends**: LPF2Hub, Hub * [BoostMoveHub](#BoostMoveHub) ⇐ LPF2Hub * [new BoostMoveHub()](#new_BoostMoveHub_new) + * [.current](#LPF2Hub+current) + * [.name](#Hub+name) + * [.uuid](#Hub+uuid) + * [.rssi](#Hub+rssi) + * [.batteryLevel](#Hub+batteryLevel) * [.setLEDColor(color)](#BoostMoveHub+setLEDColor) ⇒ Promise * [.setMotorSpeed(port, speed, [time])](#BoostMoveHub+setMotorSpeed) ⇒ Promise * [.setMotorAngle(port, angle, [speed])](#BoostMoveHub+setMotorAngle) ⇒ Promise + * [.connect()](#Hub+connect) ⇒ Promise + * [.disconnect()](#Hub+disconnect) ⇒ Promise + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise + * [.sleep(delay)](#Hub+sleep) ⇒ Promise + * [.wait(commands)](#Hub+wait) ⇒ Promise + * ["button" (button, state)](#LPF2Hub+event_button) + * ["distance" (port, distance)](#LPF2Hub+event_distance) + * ["color" (port, color)](#LPF2Hub+event_color) + * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) + * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) + * ["attach" (port, type)](#Hub+event_attach) + * ["detach" (port)](#Hub+event_detach) ### new BoostMoveHub() The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. + + +### boostMoveHub.current +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| current | number | Current usage of the hub (Amps) | + + + +### boostMoveHub.name +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | string | Name of the hub | + + + +### boostMoveHub.uuid +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| uuid | string | UUID of the hub | + + + +### boostMoveHub.rssi +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rssi | number | Signal strength of the hub | + + + +### boostMoveHub.batteryLevel +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| batteryLevel | number | Battery level of the hub (Percentage between 0-100) | + ### boostMoveHub.setLEDColor(color) ⇒ Promise @@ -407,22 +480,247 @@ Rotate a motor by a given angle. | angle | number | | How much the motor should be rotated (in degrees). | | [speed] | number | 100 | How fast the motor should be rotated. | + + +### boostMoveHub.connect() ⇒ Promise +Connect to the Hub. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [connect](#Hub+connect) +**Returns**: Promise - Resolved upon successful connect. + + +### boostMoveHub.disconnect() ⇒ Promise +Disconnect the Hub. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved upon successful disconnect. + + +### boostMoveHub.subscribe(port, [mode]) ⇒ Promise +Subscribe to sensor notifications on a given port. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | + + + +### boostMoveHub.unsubscribe(port) ⇒ Promise +Unsubscribe to sensor notifications on a given port. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | +| --- | --- | +| port | string | + + + +### boostMoveHub.sleep(delay) ⇒ Promise +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 [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved after the delay is finished. + +| Param | Type | Description | +| --- | --- | --- | +| delay | number | How long to sleep (in milliseconds). | + + + +### boostMoveHub.wait(commands) ⇒ Promise +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 [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved after the commands are finished. + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array.<Promise.<any>> | Array of executing commands. | + + + +### "button" (button, state) +Emits when a button is pressed. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| button | string | | +| state | number | A number representing one of the button state consts. | + + + +### "distance" (port, distance) +Emits when a distance sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| distance | number | Distance, in millimeters. | + + + +### "color" (port, color) +Emits when a color sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | + + + +### "tilt" (port, x, y) +Emits when a tilt sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| 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 | | + + + +### "rotate" (port, rotation) +Emits when a rotation sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | +| --- | --- | +| port | string | +| rotation | number | + + + +### "attach" (port, type) +Emits when a motor or sensor is attached to the Hub. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| type | number | A number representing one of the peripheral consts. | + + + +### "detach" (port) +Emits when an attached motor or sensor is detached from the Hub. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | +| --- | --- | +| port | string | + ## PUPHub ⇐ LPF2Hub **Kind**: global class -**Extends**: LPF2Hub +**Extends**: LPF2Hub, Hub * [PUPHub](#PUPHub) ⇐ LPF2Hub * [new PUPHub()](#new_PUPHub_new) + * [.current](#LPF2Hub+current) + * [.name](#Hub+name) + * [.uuid](#Hub+uuid) + * [.rssi](#Hub+rssi) + * [.batteryLevel](#Hub+batteryLevel) * [.setLEDColor(color)](#PUPHub+setLEDColor) ⇒ Promise * [.setMotorSpeed(port, speed, [time])](#PUPHub+setMotorSpeed) ⇒ Promise + * [.connect()](#Hub+connect) ⇒ Promise + * [.disconnect()](#Hub+disconnect) ⇒ Promise + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise + * [.sleep(delay)](#Hub+sleep) ⇒ Promise + * [.wait(commands)](#Hub+wait) ⇒ Promise + * ["button" (button, state)](#LPF2Hub+event_button) + * ["distance" (port, distance)](#LPF2Hub+event_distance) + * ["color" (port, color)](#LPF2Hub+event_color) + * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) + * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) + * ["attach" (port, type)](#Hub+event_attach) + * ["detach" (port)](#Hub+event_detach) ### new PUPHub() The PUPHub is emitted if the discovered device is a Powered Up Hub. + + +### pupHub.current +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| current | number | Current usage of the hub (Amps) | + + + +### pupHub.name +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | string | Name of the hub | + + + +### pupHub.uuid +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| uuid | string | UUID of the hub | + + + +### pupHub.rssi +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rssi | number | Signal strength of the hub | + + + +### pupHub.batteryLevel +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| batteryLevel | number | Battery level of the hub (Percentage between 0-100) | + ### pupHub.setLEDColor(color) ⇒ Promise @@ -449,21 +747,246 @@ Set the motor speed on a given port. | speed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. | | [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. | + + +### pupHub.connect() ⇒ Promise +Connect to the Hub. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [connect](#Hub+connect) +**Returns**: Promise - Resolved upon successful connect. + + +### pupHub.disconnect() ⇒ Promise +Disconnect the Hub. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Returns**: Promise - Resolved upon successful disconnect. + + +### pupHub.subscribe(port, [mode]) ⇒ Promise +Subscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | + + + +### pupHub.unsubscribe(port) ⇒ Promise +Unsubscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | +| --- | --- | +| port | string | + + + +### pupHub.sleep(delay) ⇒ Promise +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 [PUPHub](#PUPHub) +**Returns**: Promise - Resolved after the delay is finished. + +| Param | Type | Description | +| --- | --- | --- | +| delay | number | How long to sleep (in milliseconds). | + + + +### pupHub.wait(commands) ⇒ Promise +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 [PUPHub](#PUPHub) +**Returns**: Promise - Resolved after the commands are finished. + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array.<Promise.<any>> | Array of executing commands. | + + + +### "button" (button, state) +Emits when a button is pressed. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| button | string | | +| state | number | A number representing one of the button state consts. | + + + +### "distance" (port, distance) +Emits when a distance sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| distance | number | Distance, in millimeters. | + + + +### "color" (port, color) +Emits when a color sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | + + + +### "tilt" (port, x, y) +Emits when a tilt sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| 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 | | + + + +### "rotate" (port, rotation) +Emits when a rotation sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | +| --- | --- | +| port | string | +| rotation | number | + + + +### "attach" (port, type) +Emits when a motor or sensor is attached to the Hub. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| type | number | A number representing one of the peripheral consts. | + + + +### "detach" (port) +Emits when an attached motor or sensor is detached from the Hub. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | +| --- | --- | +| port | string | + ## PUPRemote ⇐ LPF2Hub **Kind**: global class -**Extends**: LPF2Hub +**Extends**: LPF2Hub, Hub * [PUPRemote](#PUPRemote) ⇐ LPF2Hub * [new PUPRemote()](#new_PUPRemote_new) + * [.current](#LPF2Hub+current) + * [.name](#Hub+name) + * [.uuid](#Hub+uuid) + * [.rssi](#Hub+rssi) + * [.batteryLevel](#Hub+batteryLevel) * [.setLEDColor(color)](#PUPRemote+setLEDColor) ⇒ Promise + * [.connect()](#Hub+connect) ⇒ Promise + * [.disconnect()](#Hub+disconnect) ⇒ Promise + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise + * [.sleep(delay)](#Hub+sleep) ⇒ Promise + * [.wait(commands)](#Hub+wait) ⇒ Promise + * ["button" (button, state)](#LPF2Hub+event_button) + * ["distance" (port, distance)](#LPF2Hub+event_distance) + * ["color" (port, color)](#LPF2Hub+event_color) + * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) + * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) + * ["attach" (port, type)](#Hub+event_attach) + * ["detach" (port)](#Hub+event_detach) ### new PUPRemote() The PUPRemote is emitted if the discovered device is a Powered Up Remote. + + +### pupRemote.current +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| current | number | Current usage of the hub (Amps) | + + + +### pupRemote.name +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | string | Name of the hub | + + + +### pupRemote.uuid +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| uuid | string | UUID of the hub | + + + +### pupRemote.rssi +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rssi | number | Signal strength of the hub | + + + +### pupRemote.batteryLevel +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| batteryLevel | number | Battery level of the hub (Percentage between 0-100) | + ### pupRemote.setLEDColor(color) ⇒ Promise @@ -476,3 +999,155 @@ Set the color of the LED on the Remote via a color value. | --- | --- | --- | | color | number | A number representing one of the LED color consts. | + + +### pupRemote.connect() ⇒ Promise +Connect to the Hub. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [connect](#Hub+connect) +**Returns**: Promise - Resolved upon successful connect. + + +### pupRemote.disconnect() ⇒ Promise +Disconnect the Hub. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved upon successful disconnect. + + +### pupRemote.subscribe(port, [mode]) ⇒ Promise +Subscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | + + + +### pupRemote.unsubscribe(port) ⇒ Promise +Unsubscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | +| --- | --- | +| port | string | + + + +### pupRemote.sleep(delay) ⇒ Promise +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 [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved after the delay is finished. + +| Param | Type | Description | +| --- | --- | --- | +| delay | number | How long to sleep (in milliseconds). | + + + +### pupRemote.wait(commands) ⇒ Promise +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 [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved after the commands are finished. + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array.<Promise.<any>> | Array of executing commands. | + + + +### "button" (button, state) +Emits when a button is pressed. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| button | string | | +| state | number | A number representing one of the button state consts. | + + + +### "distance" (port, distance) +Emits when a distance sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| distance | number | Distance, in millimeters. | + + + +### "color" (port, color) +Emits when a color sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | + + + +### "tilt" (port, x, y) +Emits when a tilt sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| 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 | | + + + +### "rotate" (port, rotation) +Emits when a rotation sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | +| --- | --- | +| port | string | +| rotation | number | + + + +### "attach" (port, type) +Emits when a motor or sensor is attached to the Hub. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| type | number | A number representing one of the peripheral consts. | + + + +### "detach" (port) +Emits when an attached motor or sensor is detached from the Hub. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | +| --- | --- | +| port | string | + diff --git a/README.md b/README.md index 2efc7e7..6002b27 100644 --- a/README.md +++ b/README.md @@ -404,19 +404,92 @@ Emits when an attached motor or sensor is detached from the Hub. ## BoostMoveHub ⇐ LPF2Hub **Kind**: global class -**Extends**: LPF2Hub +**Extends**: LPF2Hub, Hub * [BoostMoveHub](#BoostMoveHub) ⇐ LPF2Hub * [new BoostMoveHub()](#new_BoostMoveHub_new) + * [.current](#LPF2Hub+current) + * [.name](#Hub+name) + * [.uuid](#Hub+uuid) + * [.rssi](#Hub+rssi) + * [.batteryLevel](#Hub+batteryLevel) * [.setLEDColor(color)](#BoostMoveHub+setLEDColor) ⇒ Promise * [.setMotorSpeed(port, speed, [time])](#BoostMoveHub+setMotorSpeed) ⇒ Promise * [.setMotorAngle(port, angle, [speed])](#BoostMoveHub+setMotorAngle) ⇒ Promise + * [.connect()](#Hub+connect) ⇒ Promise + * [.disconnect()](#Hub+disconnect) ⇒ Promise + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise + * [.sleep(delay)](#Hub+sleep) ⇒ Promise + * [.wait(commands)](#Hub+wait) ⇒ Promise + * ["button" (button, state)](#LPF2Hub+event_button) + * ["distance" (port, distance)](#LPF2Hub+event_distance) + * ["color" (port, color)](#LPF2Hub+event_color) + * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) + * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) + * ["attach" (port, type)](#Hub+event_attach) + * ["detach" (port)](#Hub+event_detach) ### new BoostMoveHub() The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. + + +### boostMoveHub.current +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| current | number | Current usage of the hub (Amps) | + + + +### boostMoveHub.name +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | string | Name of the hub | + + + +### boostMoveHub.uuid +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| uuid | string | UUID of the hub | + + + +### boostMoveHub.rssi +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rssi | number | Signal strength of the hub | + + + +### boostMoveHub.batteryLevel +**Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| batteryLevel | number | Battery level of the hub (Percentage between 0-100) | + ### boostMoveHub.setLEDColor(color) ⇒ Promise @@ -457,22 +530,247 @@ Rotate a motor by a given angle. | angle | number | | How much the motor should be rotated (in degrees). | | [speed] | number | 100 | How fast the motor should be rotated. | + + +### boostMoveHub.connect() ⇒ Promise +Connect to the Hub. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [connect](#Hub+connect) +**Returns**: Promise - Resolved upon successful connect. + + +### boostMoveHub.disconnect() ⇒ Promise +Disconnect the Hub. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved upon successful disconnect. + + +### boostMoveHub.subscribe(port, [mode]) ⇒ Promise +Subscribe to sensor notifications on a given port. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | + + + +### boostMoveHub.unsubscribe(port) ⇒ Promise +Unsubscribe to sensor notifications on a given port. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | +| --- | --- | +| port | string | + + + +### boostMoveHub.sleep(delay) ⇒ Promise +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 [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved after the delay is finished. + +| Param | Type | Description | +| --- | --- | --- | +| delay | number | How long to sleep (in milliseconds). | + + + +### boostMoveHub.wait(commands) ⇒ Promise +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 [BoostMoveHub](#BoostMoveHub) +**Returns**: Promise - Resolved after the commands are finished. + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array.<Promise.<any>> | Array of executing commands. | + + + +### "button" (button, state) +Emits when a button is pressed. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| button | string | | +| state | number | A number representing one of the button state consts. | + + + +### "distance" (port, distance) +Emits when a distance sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| distance | number | Distance, in millimeters. | + + + +### "color" (port, color) +Emits when a color sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | + + + +### "tilt" (port, x, y) +Emits when a tilt sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| 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 | | + + + +### "rotate" (port, rotation) +Emits when a rotation sensor is activated. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | +| --- | --- | +| port | string | +| rotation | number | + + + +### "attach" (port, type) +Emits when a motor or sensor is attached to the Hub. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| type | number | A number representing one of the peripheral consts. | + + + +### "detach" (port) +Emits when an attached motor or sensor is detached from the Hub. + +**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) + +| Param | Type | +| --- | --- | +| port | string | + ## PUPHub ⇐ LPF2Hub **Kind**: global class -**Extends**: LPF2Hub +**Extends**: LPF2Hub, Hub * [PUPHub](#PUPHub) ⇐ LPF2Hub * [new PUPHub()](#new_PUPHub_new) + * [.current](#LPF2Hub+current) + * [.name](#Hub+name) + * [.uuid](#Hub+uuid) + * [.rssi](#Hub+rssi) + * [.batteryLevel](#Hub+batteryLevel) * [.setLEDColor(color)](#PUPHub+setLEDColor) ⇒ Promise * [.setMotorSpeed(port, speed, [time])](#PUPHub+setMotorSpeed) ⇒ Promise + * [.connect()](#Hub+connect) ⇒ Promise + * [.disconnect()](#Hub+disconnect) ⇒ Promise + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise + * [.sleep(delay)](#Hub+sleep) ⇒ Promise + * [.wait(commands)](#Hub+wait) ⇒ Promise + * ["button" (button, state)](#LPF2Hub+event_button) + * ["distance" (port, distance)](#LPF2Hub+event_distance) + * ["color" (port, color)](#LPF2Hub+event_color) + * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) + * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) + * ["attach" (port, type)](#Hub+event_attach) + * ["detach" (port)](#Hub+event_detach) ### new PUPHub() The PUPHub is emitted if the discovered device is a Powered Up Hub. + + +### pupHub.current +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| current | number | Current usage of the hub (Amps) | + + + +### pupHub.name +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | string | Name of the hub | + + + +### pupHub.uuid +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| uuid | string | UUID of the hub | + + + +### pupHub.rssi +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rssi | number | Signal strength of the hub | + + + +### pupHub.batteryLevel +**Kind**: instance property of [PUPHub](#PUPHub) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| batteryLevel | number | Battery level of the hub (Percentage between 0-100) | + ### pupHub.setLEDColor(color) ⇒ Promise @@ -499,21 +797,246 @@ Set the motor speed on a given port. | speed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. | | [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. | + + +### pupHub.connect() ⇒ Promise +Connect to the Hub. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [connect](#Hub+connect) +**Returns**: Promise - Resolved upon successful connect. + + +### pupHub.disconnect() ⇒ Promise +Disconnect the Hub. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Returns**: Promise - Resolved upon successful disconnect. + + +### pupHub.subscribe(port, [mode]) ⇒ Promise +Subscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | + + + +### pupHub.unsubscribe(port) ⇒ Promise +Unsubscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | +| --- | --- | +| port | string | + + + +### pupHub.sleep(delay) ⇒ Promise +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 [PUPHub](#PUPHub) +**Returns**: Promise - Resolved after the delay is finished. + +| Param | Type | Description | +| --- | --- | --- | +| delay | number | How long to sleep (in milliseconds). | + + + +### pupHub.wait(commands) ⇒ Promise +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 [PUPHub](#PUPHub) +**Returns**: Promise - Resolved after the commands are finished. + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array.<Promise.<any>> | Array of executing commands. | + + + +### "button" (button, state) +Emits when a button is pressed. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| button | string | | +| state | number | A number representing one of the button state consts. | + + + +### "distance" (port, distance) +Emits when a distance sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| distance | number | Distance, in millimeters. | + + + +### "color" (port, color) +Emits when a color sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | + + + +### "tilt" (port, x, y) +Emits when a tilt sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| 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 | | + + + +### "rotate" (port, rotation) +Emits when a rotation sensor is activated. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | +| --- | --- | +| port | string | +| rotation | number | + + + +### "attach" (port, type) +Emits when a motor or sensor is attached to the Hub. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| type | number | A number representing one of the peripheral consts. | + + + +### "detach" (port) +Emits when an attached motor or sensor is detached from the Hub. + +**Kind**: event emitted by [PUPHub](#PUPHub) + +| Param | Type | +| --- | --- | +| port | string | + ## PUPRemote ⇐ LPF2Hub **Kind**: global class -**Extends**: LPF2Hub +**Extends**: LPF2Hub, Hub * [PUPRemote](#PUPRemote) ⇐ LPF2Hub * [new PUPRemote()](#new_PUPRemote_new) + * [.current](#LPF2Hub+current) + * [.name](#Hub+name) + * [.uuid](#Hub+uuid) + * [.rssi](#Hub+rssi) + * [.batteryLevel](#Hub+batteryLevel) * [.setLEDColor(color)](#PUPRemote+setLEDColor) ⇒ Promise + * [.connect()](#Hub+connect) ⇒ Promise + * [.disconnect()](#Hub+disconnect) ⇒ Promise + * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise + * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise + * [.sleep(delay)](#Hub+sleep) ⇒ Promise + * [.wait(commands)](#Hub+wait) ⇒ Promise + * ["button" (button, state)](#LPF2Hub+event_button) + * ["distance" (port, distance)](#LPF2Hub+event_distance) + * ["color" (port, color)](#LPF2Hub+event_color) + * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) + * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) + * ["attach" (port, type)](#Hub+event_attach) + * ["detach" (port)](#Hub+event_detach) ### new PUPRemote() The PUPRemote is emitted if the discovered device is a Powered Up Remote. + + +### pupRemote.current +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| current | number | Current usage of the hub (Amps) | + + + +### pupRemote.name +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | string | Name of the hub | + + + +### pupRemote.uuid +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| uuid | string | UUID of the hub | + + + +### pupRemote.rssi +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rssi | number | Signal strength of the hub | + + + +### pupRemote.batteryLevel +**Kind**: instance property of [PUPRemote](#PUPRemote) +**Read only**: true +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| batteryLevel | number | Battery level of the hub (Percentage between 0-100) | + ### pupRemote.setLEDColor(color) ⇒ Promise @@ -526,3 +1049,155 @@ Set the color of the LED on the Remote via a color value. | --- | --- | --- | | color | number | A number representing one of the LED color consts. | + + +### pupRemote.connect() ⇒ Promise +Connect to the Hub. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [connect](#Hub+connect) +**Returns**: Promise - Resolved upon successful connect. + + +### pupRemote.disconnect() ⇒ Promise +Disconnect the Hub. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved upon successful disconnect. + + +### pupRemote.subscribe(port, [mode]) ⇒ Promise +Subscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | + + + +### pupRemote.unsubscribe(port) ⇒ Promise +Unsubscribe to sensor notifications on a given port. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved upon successful issuance of command. + +| Param | Type | +| --- | --- | +| port | string | + + + +### pupRemote.sleep(delay) ⇒ Promise +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 [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved after the delay is finished. + +| Param | Type | Description | +| --- | --- | --- | +| delay | number | How long to sleep (in milliseconds). | + + + +### pupRemote.wait(commands) ⇒ Promise +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 [PUPRemote](#PUPRemote) +**Returns**: Promise - Resolved after the commands are finished. + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array.<Promise.<any>> | Array of executing commands. | + + + +### "button" (button, state) +Emits when a button is pressed. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| button | string | | +| state | number | A number representing one of the button state consts. | + + + +### "distance" (port, distance) +Emits when a distance sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| distance | number | Distance, in millimeters. | + + + +### "color" (port, color) +Emits when a color sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | + + + +### "tilt" (port, x, y) +Emits when a tilt sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| 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 | | + + + +### "rotate" (port, rotation) +Emits when a rotation sensor is activated. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | +| --- | --- | +| port | string | +| rotation | number | + + + +### "attach" (port, type) +Emits when a motor or sensor is attached to the Hub. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| type | number | A number representing one of the peripheral consts. | + + + +### "detach" (port) +Emits when an attached motor or sensor is detached from the Hub. + +**Kind**: event emitted by [PUPRemote](#PUPRemote) + +| Param | Type | +| --- | --- | +| port | string | + diff --git a/boostmovehub.ts b/boostmovehub.ts index 7612348..b1cffab 100644 --- a/boostmovehub.ts +++ b/boostmovehub.ts @@ -13,6 +13,7 @@ const debug = Debug("lpf2hub"); * The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. * @class BoostMoveHub * @extends LPF2Hub + * @extends Hub */ export class BoostMoveHub extends LPF2Hub { diff --git a/package.json b/package.json index a9fd01d..df3e446 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "types": "dist/lpf2.d.ts", "scripts": { "build": "tslint -c tslint.json \"*.ts\" && tsc", - "docs": "jsdoc2md dist/lpf2.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/wedo2hub.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", "all": "npm run build && npm run docs && npm run readme", "prepublishOnly": "tsc" diff --git a/puphub.ts b/puphub.ts index 35c9545..300708b 100644 --- a/puphub.ts +++ b/puphub.ts @@ -13,6 +13,7 @@ const debug = Debug("lpf2hub"); * The PUPHub is emitted if the discovered device is a Powered Up Hub. * @class PUPHub * @extends LPF2Hub + * @extends Hub */ export class PUPHub extends LPF2Hub { diff --git a/pupremote.ts b/pupremote.ts index eb7f6e8..d8722f7 100644 --- a/pupremote.ts +++ b/pupremote.ts @@ -13,6 +13,7 @@ const debug = Debug("lpf2hub"); * The PUPRemote is emitted if the discovered device is a Powered Up Remote. * @class PUPRemote * @extends LPF2Hub + * @extends Hub */ export class PUPRemote extends LPF2Hub {