diff --git a/DOCS.md b/DOCS.md index d1f280f..54d35bd 100644 --- a/DOCS.md +++ b/DOCS.md @@ -3,7 +3,7 @@
EventEmitter
Hub
Hub
Hub
WeDo2Hub
](#WeDo2Hub) \| [BoostHub
](#BoostHub) |
+| hub | [WeDo2Hub
](#WeDo2Hub) \| [LPF2Hub
](#LPF2Hub) |
-
+
-## BoostHub ⇐ [Hub
](#Hub)
+## LPF2Hub ⇐ [Hub
](#Hub)
**Kind**: global class
**Extends**: [Hub
](#Hub)
-* [BoostHub](#BoostHub) ⇐ [Hub
](#Hub)
- * [.setLEDColor(color)](#BoostHub+setLEDColor) ⇒ Promise
- * [.setMotorSpeed(port, speed, [time])](#BoostHub+setMotorSpeed) ⇒ Promise
- * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) ⇒ Promise
+* [LPF2Hub](#LPF2Hub) ⇐ [Hub
](#Hub)
+ * [.setLEDColor(color)](#LPF2Hub+setLEDColor) ⇒ Promise
+ * [.setMotorSpeed(port, speed, [time])](#LPF2Hub+setMotorSpeed) ⇒ Promise
+ * [.setMotorAngle(port, angle, [speed])](#LPF2Hub+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)](#BoostHub+event_button)
- * ["distance" (port, distance)](#BoostHub+event_distance)
- * ["color" (port, color)](#BoostHub+event_color)
- * ["tilt" (port, x, y)](#BoostHub+event_tilt)
- * ["rotate" (port, rotation)](#BoostHub+event_rotate)
+ * ["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)
-
+
-### boostHub.setLEDColor(color) ⇒ Promise
+### lpF2Hub.setLEDColor(color) ⇒ Promise
Set the color of the LED on the Hub via a color value.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
| color | number
| A number representing one of the LED color consts. |
-
+
-### boostHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
+### lpF2Hub.setMotorSpeed(port, speed, [time]) ⇒ Promise
Set the motor speed on a given port.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
| Param | Type | Description |
@@ -112,12 +112,12 @@ 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. |
-
+
-### boostHub.setMotorAngle(port, angle, [speed]) ⇒ Promise
+### lpF2Hub.setMotorAngle(port, angle, [speed]) ⇒ Promise
Rotate a motor by a given angle.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful completion of command (ie. once the motor is finished).
| Param | Type | Default | Description |
@@ -128,25 +128,25 @@ Rotate a motor by a given angle.
-### boostHub.connect() ⇒ Promise
+### lpF2Hub.connect() ⇒ Promise
Connect to the Hub.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Overrides**: [connect
](#Hub+connect)
**Returns**: Promise
- Resolved upon successful connect.
-### boostHub.disconnect() ⇒ Promise
+### lpF2Hub.disconnect() ⇒ Promise
Disconnect the Hub.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful disconnect.
-### boostHub.subscribe(port, [mode]) ⇒ Promise
+### lpF2Hub.subscribe(port, [mode]) ⇒ Promise
Subscribe to sensor notifications on a given port.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
@@ -156,10 +156,10 @@ Subscribe to sensor notifications on a given port.
-### boostHub.unsubscribe(port) ⇒ Promise
+### lpF2Hub.unsubscribe(port) ⇒ Promise
Unsubscribe to sensor notifications on a given port.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type |
@@ -168,12 +168,12 @@ Unsubscribe to sensor notifications on a given port.
-### boostHub.sleep(delay) ⇒ Promise
+### lpF2Hub.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 [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved after the delay is finished.
| Param | Type | Description |
@@ -182,60 +182,60 @@ This is a helper method to make it easier to add delays into a chain of commands
-### boostHub.wait(commands) ⇒ Promise
+### lpF2Hub.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 [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**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 [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| 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 [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| Param | Type | Description |
| --- | --- | --- |
| port | string
| |
| distance | number
| Distance, in millimeters. |
-
+
### "color" (port, color)
Emits when a color sensor is activated.
-**Kind**: event emitted by [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| 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 [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| Param | Type | Description |
| --- | --- | --- |
@@ -243,12 +243,12 @@ Emits when a tilt sensor is activated.
| x | number
| |
| y | number
| |
-
+
### "rotate" (port, rotation)
Emits when a rotation sensor is activated.
-**Kind**: event emitted by [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| Param | Type |
| --- | --- |
diff --git a/README.md b/README.md
index c7f16ad..b1f4bd8 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ Examples are available in the "examples" directory.
EventEmitter
Hub
Hub
Hub
WeDo2Hub
](#WeDo2Hub) \| [BoostHub
](#BoostHub) |
+| hub | [WeDo2Hub
](#WeDo2Hub) \| [LPF2Hub
](#LPF2Hub) |
-
+
-## BoostHub ⇐ [Hub
](#Hub)
+## LPF2Hub ⇐ [Hub
](#Hub)
**Kind**: global class
**Extends**: [Hub
](#Hub)
-* [BoostHub](#BoostHub) ⇐ [Hub
](#Hub)
- * [.setLEDColor(color)](#BoostHub+setLEDColor) ⇒ Promise
- * [.setMotorSpeed(port, speed, [time])](#BoostHub+setMotorSpeed) ⇒ Promise
- * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) ⇒ Promise
+* [LPF2Hub](#LPF2Hub) ⇐ [Hub
](#Hub)
+ * [.setLEDColor(color)](#LPF2Hub+setLEDColor) ⇒ Promise
+ * [.setMotorSpeed(port, speed, [time])](#LPF2Hub+setMotorSpeed) ⇒ Promise
+ * [.setMotorAngle(port, angle, [speed])](#LPF2Hub+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)](#BoostHub+event_button)
- * ["distance" (port, distance)](#BoostHub+event_distance)
- * ["color" (port, color)](#BoostHub+event_color)
- * ["tilt" (port, x, y)](#BoostHub+event_tilt)
- * ["rotate" (port, rotation)](#BoostHub+event_rotate)
+ * ["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)
-
+
-### boostHub.setLEDColor(color) ⇒ Promise
+### lpF2Hub.setLEDColor(color) ⇒ Promise
Set the color of the LED on the Hub via a color value.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
| color | number
| A number representing one of the LED color consts. |
-
+
-### boostHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
+### lpF2Hub.setMotorSpeed(port, speed, [time]) ⇒ Promise
Set the motor speed on a given port.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
| Param | Type | Description |
@@ -153,12 +153,12 @@ 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. |
-
+
-### boostHub.setMotorAngle(port, angle, [speed]) ⇒ Promise
+### lpF2Hub.setMotorAngle(port, angle, [speed]) ⇒ Promise
Rotate a motor by a given angle.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful completion of command (ie. once the motor is finished).
| Param | Type | Default | Description |
@@ -169,25 +169,25 @@ Rotate a motor by a given angle.
-### boostHub.connect() ⇒ Promise
+### lpF2Hub.connect() ⇒ Promise
Connect to the Hub.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Overrides**: [connect
](#Hub+connect)
**Returns**: Promise
- Resolved upon successful connect.
-### boostHub.disconnect() ⇒ Promise
+### lpF2Hub.disconnect() ⇒ Promise
Disconnect the Hub.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful disconnect.
-### boostHub.subscribe(port, [mode]) ⇒ Promise
+### lpF2Hub.subscribe(port, [mode]) ⇒ Promise
Subscribe to sensor notifications on a given port.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
@@ -197,10 +197,10 @@ Subscribe to sensor notifications on a given port.
-### boostHub.unsubscribe(port) ⇒ Promise
+### lpF2Hub.unsubscribe(port) ⇒ Promise
Unsubscribe to sensor notifications on a given port.
-**Kind**: instance method of [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type |
@@ -209,12 +209,12 @@ Unsubscribe to sensor notifications on a given port.
-### boostHub.sleep(delay) ⇒ Promise
+### lpF2Hub.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 [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**Returns**: Promise
- Resolved after the delay is finished.
| Param | Type | Description |
@@ -223,60 +223,60 @@ This is a helper method to make it easier to add delays into a chain of commands
-### boostHub.wait(commands) ⇒ Promise
+### lpF2Hub.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 [BoostHub
](#BoostHub)
+**Kind**: instance method of [LPF2Hub
](#LPF2Hub)
**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 [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| 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 [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| Param | Type | Description |
| --- | --- | --- |
| port | string
| |
| distance | number
| Distance, in millimeters. |
-
+
### "color" (port, color)
Emits when a color sensor is activated.
-**Kind**: event emitted by [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| 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 [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| Param | Type | Description |
| --- | --- | --- |
@@ -284,12 +284,12 @@ Emits when a tilt sensor is activated.
| x | number
| |
| y | number
| |
-
+
### "rotate" (port, rotation)
Emits when a rotation sensor is activated.
-**Kind**: event emitted by [BoostHub
](#BoostHub)
+**Kind**: event emitted by [LPF2Hub
](#LPF2Hub)
| Param | Type |
| --- | --- |
diff --git a/hub.ts b/hub.ts
index 5afba6c..5f1f9bf 100644
--- a/hub.ts
+++ b/hub.ts
@@ -227,6 +227,19 @@ export class Hub extends EventEmitter {
}
+ protected _getPortForPortNumber (num: number) {
+
+ for (const key of Object.keys(this._ports)) {
+ if (this._ports[key].value === num) {
+ return this._ports[key];
+ }
+ }
+
+ return false;
+
+ }
+
+
protected _mapSpeed (speed: number) { // Speed range of -100 to 100 is supported unless speed mapping is turned off, in which case, you're on your own!
if (!this.useSpeedMap) {
return speed;
diff --git a/lpf2.ts b/lpf2.ts
index bfb72f3..a174661 100644
--- a/lpf2.ts
+++ b/lpf2.ts
@@ -1,7 +1,7 @@
import { Peripheral } from "noble";
-import { BoostHub } from "./boosthub";
import { Hub } from "./hub";
+import { LPF2Hub } from "./lpf2hub";
import { WeDo2Hub } from "./wedo2hub";
import { EventEmitter} from "events";
@@ -56,8 +56,8 @@ export class LPF2 extends EventEmitter {
if (WeDo2Hub.IsWeDo2Hub(peripheral)) {
hub = new WeDo2Hub(peripheral, this.autoSubscribe);
- } else if (BoostHub.IsBoostHub(peripheral)) {
- hub = new BoostHub(peripheral, this.autoSubscribe);
+ } else if (LPF2Hub.IsLPF2Hub(peripheral)) {
+ hub = new LPF2Hub(peripheral, this.autoSubscribe);
} else {
return;
}
@@ -86,7 +86,7 @@ export class LPF2 extends EventEmitter {
/**
* Emits when a LPF2 Hub device is found.
* @event LPF2#discover
- * @param {WeDo2Hub | BoostHub} hub
+ * @param {WeDo2Hub | LPF2Hub} hub
*/
this.emit("discover", hub);
@@ -135,4 +135,4 @@ export class LPF2 extends EventEmitter {
}
export default LPF2;
-export { Hub, WeDo2Hub, BoostHub };
+export { Hub, WeDo2Hub, LPF2Hub };
diff --git a/boosthub.ts b/lpf2hub.ts
similarity index 86%
rename from boosthub.ts
rename to lpf2hub.ts
index 2714b90..c1bb83b 100644
--- a/boosthub.ts
+++ b/lpf2hub.ts
@@ -6,18 +6,18 @@ import { Port } from "./port.js";
import * as Consts from "./consts";
import Debug = require("debug");
-const debug = Debug("boosthub");
+const debug = Debug("lpf2hub");
/**
- * @class BoostHub
+ * @class LPF2Hub
* @extends Hub
*/
-export class BoostHub extends Hub {
+export class LPF2Hub extends Hub {
- public static IsBoostHub (peripheral: Peripheral) {
- return (peripheral.advertisement.localName === Consts.BLENames.BOOST_MOVE_HUB_NAME && peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.BOOST_MOVE_HUB) >= 0);
+ public static IsLPF2Hub (peripheral: Peripheral) {
+ return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.BOOST_MOVE_HUB) >= 0);
}
@@ -27,16 +27,39 @@ export class BoostHub extends Hub {
constructor (peripheral: Peripheral, autoSubscribe: boolean = true) {
super(peripheral, autoSubscribe);
- this.type = Consts.Hubs.BOOST_MOVE_HUB;
- this._ports = {
- "A": new Port("A", 55),
- "B": new Port("B", 56),
- "AB": new Port("AB", 57),
- "TILT": new Port("TILT", 58),
- "C": new Port("C", 1),
- "D": new Port("D", 2)
- };
- debug("Discovered Boost Move Hub");
+ switch (peripheral.advertisement.localName) {
+ case Consts.BLENames.POWERED_UP_HUB_NAME:
+ {
+ this.type = Consts.Hubs.POWERED_UP_HUB;
+ this._ports = {
+ "A": new Port("A", 55),
+ "B": new Port("B", 56),
+ "AB": new Port("AB", 57)
+ };
+ debug("Discovered Powered Up Hub");
+ break;
+ }
+ case Consts.BLENames.POWERED_UP_REMOTE_NAME:
+ {
+ this.type = Consts.Hubs.POWERED_UP_REMOTE;
+ debug("Discovered Powered Up Remote");
+ break;
+ }
+ default:
+ {
+ this.type = Consts.Hubs.BOOST_MOVE_HUB;
+ this._ports = {
+ "A": new Port("A", 55),
+ "B": new Port("B", 56),
+ "AB": new Port("AB", 57),
+ "TILT": new Port("TILT", 58),
+ "C": new Port("C", 1),
+ "D": new Port("D", 2)
+ };
+ debug("Discovered Boost Move Hub");
+ break;
+ }
+ }
}
@@ -55,7 +78,7 @@ export class BoostHub extends Hub {
/**
* Set the color of the LED on the Hub via a color value.
- * @method BoostHub#setLEDColor
+ * @method LPF2Hub#setLEDColor
* @param {number} color A number representing one of the LED color consts.
* @returns {Promise} Resolved upon successful issuance of command.
*/
@@ -89,7 +112,7 @@ export class BoostHub extends Hub {
/**
* Set the motor speed on a given port.
- * @method BoostHub#setMotorSpeed
+ * @method LPF2Hub#setMotorSpeed
* @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} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
@@ -120,7 +143,7 @@ export class BoostHub extends Hub {
/**
* Rotate a motor by a given angle.
- * @method BoostHub#setMotorAngle
+ * @method LPF2Hub#setMotorAngle
* @param {string} port
* @param {number} angle How much the motor should be rotated (in degrees).
* @param {number} [speed=100] How fast the motor should be rotated.
@@ -160,31 +183,6 @@ export class BoostHub extends Hub {
}
- private _getPortForPortNumber (num: number) {
-
- let port = null;
-
- if (num === 1) {
- port = this._ports["C"];
- } else if (num === 2) {
- port = this._ports["D"];
- } else if (num === 55) {
- port = this._ports["A"];
- } else if (num === 56) {
- port = this._ports["B"];
- } else if (num === 57) {
- port = this._ports["AB"];
- } else if (num === 58) {
- port = this._ports["TILT"];
- } else {
- return false;
- }
-
- return port;
-
- }
-
-
private _parseMessage (data: Buffer) {
switch (data[2]) {
@@ -218,7 +216,7 @@ export class BoostHub extends Hub {
if (data[5] === 1) {
/**
* Emits when a button is pressed.
- * @event BoostHub#button
+ * @event LPF2Hub#button
* @param {string} button
* @param {number} state A number representing one of the button state consts.
*/
@@ -284,7 +282,7 @@ export class BoostHub extends Hub {
}
/**
* Emits when a distance sensor is activated.
- * @event BoostHub#distance
+ * @event LPF2Hub#distance
* @param {string} port
* @param {number} distance Distance, in millimeters.
*/
@@ -296,7 +294,7 @@ export class BoostHub extends Hub {
/**
* Emits when a color sensor is activated.
- * @event BoostHub#color
+ * @event LPF2Hub#color
* @param {string} port
* @param {number} color A number representing one of the LED color consts.
*/
@@ -322,7 +320,7 @@ export class BoostHub extends Hub {
this._lastTiltY = tiltY;
/**
* Emits when a tilt sensor is activated.
- * @event BoostHub#tilt
+ * @event LPF2Hub#tilt
* @param {string} port If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used.
* @param {number} x
* @param {number} y
@@ -335,7 +333,7 @@ export class BoostHub extends Hub {
const rotation = data.readInt32LE(2);
/**
* Emits when a rotation sensor is activated.
- * @event BoostHub#rotate
+ * @event LPF2Hub#rotate
* @param {string} port
* @param {number} rotation
*/
diff --git a/package.json b/package.json
index 17b98ab..3e752b6 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/boosthub.js dist/wedo2hub.js dist/hub.js dist/consts.js > DOCS.md",
+ "docs": "jsdoc2md dist/lpf2.js dist/lpf2hub.js dist/wedo2hub.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/wedo2hub.ts b/wedo2hub.ts
index 91c83e0..86f5f2c 100644
--- a/wedo2hub.ts
+++ b/wedo2hub.ts
@@ -130,23 +130,6 @@ export class WeDo2Hub extends Hub {
}
- private _getPortForPortNumber (num: number) {
-
- let port = null;
-
- if (num === 1) {
- port = this._ports["A"];
- } else if (num === 2) {
- port = this._ports["B"];
- } else {
- return;
- }
-
- return port;
-
- }
-
-
private _parsePortMessage (data: Buffer) {
const port = this._getPortForPortNumber(data[0]);