From f838acfe8bcfd16d014ec412c832615c6372a92c Mon Sep 17 00:00:00 2001 From: Nathan Kunicki Date: Tue, 7 Aug 2018 10:59:43 +0100 Subject: [PATCH] Renamed module to node-poweredup --- ABOUT.md | 16 +++---- DOCS.md | 56 +++++++++++------------ README.md | 72 +++++++++++++++--------------- examples/automated_train_layout.js | 8 ++-- examples/batmobile_remote.js | 28 ++++++------ examples/leds.js | 10 ++--- examples/test.js | 35 ++++++++++++--- examples/train_reverse.js | 12 ++--- examples/vernie_remote.js | 26 +++++------ package-lock.json | 2 +- package.json | 10 ++--- lpf2.ts => poweredup.ts | 28 ++++++------ 12 files changed, 162 insertions(+), 141 deletions(-) rename lpf2.ts => poweredup.ts (84%) diff --git a/ABOUT.md b/ABOUT.md index 271a6e0..f339b32 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,20 +1,20 @@ -# **node-lpf2** - A Node.js module to interface with LEGO Power Functions 2.0 components. +# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. ### Installation Node.js v8.0+ required. ```javascript -npm install node-lpf2 --save +npm install node-poweredup --save ``` -node-lpf2 uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/noble/noble#prerequisites). +node-poweredup uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/noble/noble#prerequisites). -Note: node-lpf2 has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B. +Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B. ### Compatibility -While most LPF2 components and Hubs are compatible with each other, there are exceptions. There is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs. +While most Powered UP components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs. | Name | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered Up Hub | Availability | | ------------------------------- | ------------- | ------------------ | -------------- | -------------- | ------------ | @@ -22,7 +22,7 @@ While most LPF2 components and Hubs are compatible with each other, there are ex | WeDo 2.0 Motion Sensor | Sensor | Yes | Yes | Yes | 45300 | | WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | 45300
76112 | | Boost Color and Distance Sensor | Sensor | *Partial* | Yes | Yes | 17101 | -| Boost Interactive Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | +| Boost Tacho Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | | Powered Up Train Motor | Motor | Yes | Yes | Yes | 60197
60198 | | Powered Up LED Lights | Light | Unknown | Unknown | Unknown | 88005 | @@ -40,8 +40,8 @@ While most LPF2 components and Hubs are compatible with each other, there are ex ### Usage ```javascript -const LPF2 = require("node-lpf2").LPF2; -const lpf2 = new LPF2(); +const PoweredUP = require("node-poweredup"); +const pup = new PoweredUP.PoweredUP(); ``` Examples are available in the "examples" directory. diff --git a/DOCS.md b/DOCS.md index d2eb9cb..91520ad 100644 --- a/DOCS.md +++ b/DOCS.md @@ -1,7 +1,7 @@ ## Classes
-
LPF2EventEmitter
+
PoweredUPEventEmitter
WeDo2SmartHubHub
@@ -13,54 +13,54 @@
- + -## LPF2 ⇐ EventEmitter +## PoweredUP ⇐ EventEmitter **Kind**: global class **Extends**: EventEmitter -* [LPF2](#LPF2) ⇐ EventEmitter - * [.scan()](#LPF2+scan) - * [.stop()](#LPF2+stop) - * [.getConnectedHubByUUID(uuid)](#LPF2+getConnectedHubByUUID) ⇒ Hub \| null - * [.getConnectedHubs()](#LPF2+getConnectedHubs) ⇒ Array.<Hub> - * ["discover" (hub)](#LPF2+event_discover) +* [PoweredUP](#PoweredUP) ⇐ EventEmitter + * [.scan()](#PoweredUP+scan) + * [.stop()](#PoweredUP+stop) + * [.getConnectedHubByUUID(uuid)](#PoweredUP+getConnectedHubByUUID) ⇒ Hub \| null + * [.getConnectedHubs()](#PoweredUP+getConnectedHubs) ⇒ Array.<Hub> + * ["discover" (hub)](#PoweredUP+event_discover) - + -### lpF2.scan() -Begin scanning for LPF2 Hub devices. +### poweredUP.scan() +Begin scanning for Powered UP Hub devices. -**Kind**: instance method of [LPF2](#LPF2) - +**Kind**: instance method of [PoweredUP](#PoweredUP) + -### lpF2.stop() -Stop scanning for LPF2 Hub devices. +### poweredUP.stop() +Stop scanning for Powered UP Hub devices. -**Kind**: instance method of [LPF2](#LPF2) - +**Kind**: instance method of [PoweredUP](#PoweredUP) + -### lpF2.getConnectedHubByUUID(uuid) ⇒ Hub \| null -Retrieve a LPF2 Hub by UUID. +### poweredUP.getConnectedHubByUUID(uuid) ⇒ Hub \| null +Retrieve a Powered UP Hub by UUID. -**Kind**: instance method of [LPF2](#LPF2) +**Kind**: instance method of [PoweredUP](#PoweredUP) | Param | Type | | --- | --- | | uuid | string | - + -### lpF2.getConnectedHubs() ⇒ Array.<Hub> -Retrieve a list of LPF2 Hubs. +### poweredUP.getConnectedHubs() ⇒ Array.<Hub> +Retrieve a list of Powered UP Hubs. -**Kind**: instance method of [LPF2](#LPF2) - +**Kind**: instance method of [PoweredUP](#PoweredUP) + ### "discover" (hub) -Emits when a LPF2 Hub device is found. +Emits when a Powered UP Hub device is found. -**Kind**: event emitted by [LPF2](#LPF2) +**Kind**: event emitted by [PoweredUP](#PoweredUP) | Param | Type | | --- | --- | diff --git a/README.md b/README.md index d860bcf..02fbb9b 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ -# **node-lpf2** - A Node.js module to interface with LEGO Power Functions 2.0 components. +# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. ### Installation Node.js v8.0+ required. ```javascript -npm install node-lpf2 --save +npm install node-poweredup --save ``` -node-lpf2 uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/noble/noble#prerequisites). +node-poweredup uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/noble/noble#prerequisites). -Note: node-lpf2 has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B. +Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B. ### Compatibility -While most LPF2 components and Hubs are compatible with each other, there are exceptions. There is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs. +While most Powered UP components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs. | Name | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered Up Hub | Availability | | ------------------------------- | ------------- | ------------------ | -------------- | -------------- | ------------ | @@ -22,7 +22,7 @@ While most LPF2 components and Hubs are compatible with each other, there are ex | WeDo 2.0 Motion Sensor | Sensor | Yes | Yes | Yes | 45300 | | WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | 45300
76112 | | Boost Color and Distance Sensor | Sensor | *Partial* | Yes | Yes | 17101 | -| Boost Interactive Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | +| Boost Tacho Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | | Powered Up Train Motor | Motor | Yes | Yes | Yes | 60197
60198 | | Powered Up LED Lights | Light | Unknown | Unknown | Unknown | 88005 | @@ -40,8 +40,8 @@ While most LPF2 components and Hubs are compatible with each other, there are ex ### Usage ```javascript -const LPF2 = require("node-lpf2").LPF2; -const lpf2 = new LPF2(); +const PoweredUP = require("node-poweredup"); +const pup = new PoweredUP.PoweredUP(); ``` Examples are available in the "examples" directory. @@ -53,7 +53,7 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R ## Classes
-
LPF2EventEmitter
+
PoweredUPEventEmitter
WeDo2SmartHubHub
@@ -65,54 +65,54 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R
- + -## LPF2 ⇐ EventEmitter +## PoweredUP ⇐ EventEmitter **Kind**: global class **Extends**: EventEmitter -* [LPF2](#LPF2) ⇐ EventEmitter - * [.scan()](#LPF2+scan) - * [.stop()](#LPF2+stop) - * [.getConnectedHubByUUID(uuid)](#LPF2+getConnectedHubByUUID) ⇒ Hub \| null - * [.getConnectedHubs()](#LPF2+getConnectedHubs) ⇒ Array.<Hub> - * ["discover" (hub)](#LPF2+event_discover) +* [PoweredUP](#PoweredUP) ⇐ EventEmitter + * [.scan()](#PoweredUP+scan) + * [.stop()](#PoweredUP+stop) + * [.getConnectedHubByUUID(uuid)](#PoweredUP+getConnectedHubByUUID) ⇒ Hub \| null + * [.getConnectedHubs()](#PoweredUP+getConnectedHubs) ⇒ Array.<Hub> + * ["discover" (hub)](#PoweredUP+event_discover) - + -### lpF2.scan() -Begin scanning for LPF2 Hub devices. +### poweredUP.scan() +Begin scanning for Powered UP Hub devices. -**Kind**: instance method of [LPF2](#LPF2) - +**Kind**: instance method of [PoweredUP](#PoweredUP) + -### lpF2.stop() -Stop scanning for LPF2 Hub devices. +### poweredUP.stop() +Stop scanning for Powered UP Hub devices. -**Kind**: instance method of [LPF2](#LPF2) - +**Kind**: instance method of [PoweredUP](#PoweredUP) + -### lpF2.getConnectedHubByUUID(uuid) ⇒ Hub \| null -Retrieve a LPF2 Hub by UUID. +### poweredUP.getConnectedHubByUUID(uuid) ⇒ Hub \| null +Retrieve a Powered UP Hub by UUID. -**Kind**: instance method of [LPF2](#LPF2) +**Kind**: instance method of [PoweredUP](#PoweredUP) | Param | Type | | --- | --- | | uuid | string | - + -### lpF2.getConnectedHubs() ⇒ Array.<Hub> -Retrieve a list of LPF2 Hubs. +### poweredUP.getConnectedHubs() ⇒ Array.<Hub> +Retrieve a list of Powered UP Hubs. -**Kind**: instance method of [LPF2](#LPF2) - +**Kind**: instance method of [PoweredUP](#PoweredUP) + ### "discover" (hub) -Emits when a LPF2 Hub device is found. +Emits when a Powered UP Hub device is found. -**Kind**: event emitted by [LPF2](#LPF2) +**Kind**: event emitted by [PoweredUP](#PoweredUP) | Param | Type | | --- | --- | diff --git a/examples/automated_train_layout.js b/examples/automated_train_layout.js index bdb94b7..ab13fd2 100644 --- a/examples/automated_train_layout.js +++ b/examples/automated_train_layout.js @@ -1,10 +1,10 @@ // This example won't work by itself, this is the code used to automate this train layout: https://www.youtube.com/watch?v=Tyzo_hHFiUc // It is included here as an example. -const LPF2 = require(".").LPF2; +const PoweredUP = require("..").PoweredUP; -const lpf2 = new LPF2(); -lpf2.scan(); // Start scanning for hubs +const pup = new PoweredUP(); +pup.scan(); // Start scanning for hubs console.log("Looking for Hubs..."); @@ -24,7 +24,7 @@ let state = 0; let moving = true; -lpf2.on("discover", async (hub) => { // Wait to discover hubs +pup.on("discover", async (hub) => { // Wait to discover hubs console.log(hub.uuid); diff --git a/examples/batmobile_remote.js b/examples/batmobile_remote.js index 5706ca5..e0c56d0 100644 --- a/examples/batmobile_remote.js +++ b/examples/batmobile_remote.js @@ -4,10 +4,10 @@ * */ -const LPF2 = require(".."); +const PoweredUP = require(".."); -const lpf2 = new LPF2.LPF2(); -lpf2.scan(); // Start scanning +const pup = new PoweredUP.PoweredUP(); +pup.scan(); // Start scanning console.log("Looking for Batmobile and Remote..."); @@ -16,40 +16,40 @@ let remote = null; let lastButton = null; -lpf2.on("discover", async (hub) => { // Wait to Batmobile and Remote +pup.on("discover", async (hub) => { // Wait to Batmobile and Remote - if (hub instanceof LPF2.PUPHub) { + if (hub instanceof PoweredUP.PUPHub) { batmobile = hub; await batmobile.connect(); console.log("Connected to Batmobile!"); - } else if (hub instanceof LPF2.PUPRemote) { + } else if (hub instanceof PoweredUP.PUPRemote) { remote = hub; remote.on("button", async (button, state) => { if (batmobile) { switch (state) { - case LPF2.Consts.ButtonStates.UP: // If up is pressed, move the wheels forward + case PoweredUP.Consts.ButtonStates.UP: // If up is pressed, move the wheels forward { lastButton = state; batmobile.setMotorSpeed(button === "LEFT" ? "B" : "A", button === "LEFT" ? -100 : 100); break; } - case LPF2.Consts.ButtonStates.DOWN: // If down is pressed, move the wheels backwards + case PoweredUP.Consts.ButtonStates.DOWN: // If down is pressed, move the wheels backwards { lastButton = state; batmobile.setMotorSpeed(button === "LEFT" ? "B" : "A", button === "LEFT" ? 100 : -100); break; } - case LPF2.Consts.ButtonStates.RELEASED: // Stop the wheels when the button is released + case PoweredUP.Consts.ButtonStates.RELEASED: // Stop the wheels when the button is released { - if (lastButton === LPF2.Consts.ButtonStates.UP || lastButton === LPF2.Consts.ButtonStates.DOWN) { + if (lastButton === PoweredUP.Consts.ButtonStates.UP || lastButton === PoweredUP.Consts.ButtonStates.DOWN) { batmobile.setMotorSpeed(button === "LEFT" ? "B" : "A", 0); } break; } - case LPF2.Consts.ButtonStates.STOP: // When left red button is pressed, do a retreat. When right red button is pressed, scan the area. + case PoweredUP.Consts.ButtonStates.STOP: // When left red button is pressed, do a retreat. When right red button is pressed, scan the area. { lastButton = state; if (button === "LEFT") { @@ -66,7 +66,7 @@ lpf2.on("discover", async (hub) => { // Wait to Batmobile and Remote } break; } - case LPF2.Consts.ButtonStates.PRESSED: // Do a wheelie when the green button is pressed + case PoweredUP.Consts.ButtonStates.PRESSED: // Do a wheelie when the green button is pressed { lastButton = state; if (button === "GREEN") { @@ -85,8 +85,8 @@ lpf2.on("discover", async (hub) => { // Wait to Batmobile and Remote } if (batmobile && remote) { - batmobile.setLEDColor(LPF2.Consts.Colors.WHITE); - remote.setLEDColor(LPF2.Consts.Colors.RED); + batmobile.setLEDColor(PoweredUP.Consts.Colors.WHITE); + remote.setLEDColor(PoweredUP.Consts.Colors.RED); console.log("You're now ready to go!"); } diff --git a/examples/leds.js b/examples/leds.js index 4600f38..c2c5d9f 100644 --- a/examples/leds.js +++ b/examples/leds.js @@ -4,14 +4,14 @@ * */ -const LPF2 = require("..").LPF2; +const PoweredUP = require("..").PoweredUP; -const lpf2 = new LPF2(); -lpf2.scan(); // Start scanning for hubs +const pup = new PoweredUP(); +pup.scan(); // Start scanning for hubs console.log("Looking for Hubs..."); -lpf2.on("discover", async (hub) => { // Wait to discover hubs +pup.on("discover", async (hub) => { // Wait to discover hubs await hub.connect(); // Connect to hub console.log(`Connected to ${hub.name}!`); @@ -25,7 +25,7 @@ lpf2.on("discover", async (hub) => { // Wait to discover hubs let color = 1; setInterval(() => { - const hubs = lpf2.getConnectedHubs(); // Get an array of all connected hubs + const hubs = pup.getConnectedHubs(); // Get an array of all connected hubs hubs.forEach((hub) => { hub.setLEDColor(color); // Set the color }) diff --git a/examples/test.js b/examples/test.js index 5d0ff4e..d2c257a 100644 --- a/examples/test.js +++ b/examples/test.js @@ -1,6 +1,6 @@ -const LPF2 = require("..").LPF2; +const LPF2 = require(".."); -const lpf2 = new LPF2(); +const lpf2 = new LPF2.LPF2(); lpf2.scan(); // Start scanning for hubs console.log("Looking for Hubs..."); @@ -8,11 +8,32 @@ console.log("Looking for Hubs..."); lpf2.on("discover", async (hub) => { // Wait to discover hubs await hub.connect(); // Connect to hub - console.log("Connected to Hub!"); + console.log(`Connected to ${hub.name}!`); - setTimeout(() => { - hub.setMotorSpeed("A", 50, 500); - //hub.setMotorSpeed("B", 50); - }, 3000); + await hub.sleep(4000); + + hub.setMotorAngle("A", 90); + console.log("Done"); + + // while (true) { + + // await hub.wait([ + // hub.setMotorSpeed("A", 10, 1000), + // hub.setMotorSpeed("B", 10, 1000) + // ]); + + // await hub.wait([ + // hub.setMotorSpeed("A", -10, 2000), + // hub.setMotorSpeed("B", -10, 2000) + // ]); + + // await hub.wait([ + // hub.setMotorSpeed("A", 10, 1000), + // hub.setMotorSpeed("B", 10, 1000) + // ]); + + // await hub.sleep(4000); + + // } }); \ No newline at end of file diff --git a/examples/train_reverse.js b/examples/train_reverse.js index 95d17dd..9269e6a 100644 --- a/examples/train_reverse.js +++ b/examples/train_reverse.js @@ -1,18 +1,18 @@ -const LPF2 = require(".."); +const PoweredUP = require(".."); -const lpf2 = new LPF2.LPF2(); -lpf2.scan(); // Start scanning for trains +const pup = new PoweredUP.PoweredUP(); +pup.scan(); // Start scanning for trains // Change these to make the train behave as you want -const FORWARD_DIRECTION_COLOR = LPF2.Consts.Colors.YELLOW; -const BACKWARDS_DIRECTION_COLOR = LPF2.Consts.Colors.RED; +const FORWARD_DIRECTION_COLOR = PoweredUP.Consts.Colors.YELLOW; +const BACKWARDS_DIRECTION_COLOR = PoweredUP.Consts.Colors.RED; const TRAIN_SPEED = 40; const STOP_DELAY = 2000; const TRAIN_MOTOR_PORT = "A"; console.log("Looking for trains..."); -lpf2.on("discover", async (hub) => { // Wait to discover a train +pup.on("discover", async (hub) => { // Wait to discover a train let moving = true; diff --git a/examples/vernie_remote.js b/examples/vernie_remote.js index 1038a92..81dec8f 100644 --- a/examples/vernie_remote.js +++ b/examples/vernie_remote.js @@ -4,53 +4,53 @@ * */ -const LPF2 = require(".."); +const PoweredUP = require(".."); -const lpf2 = new LPF2.LPF2(); -lpf2.scan(); // Start scanning +const pup = new PoweredUP.PoweredUP(); +pup.scan(); // Start scanning console.log("Looking for Vernie and Remote..."); let vernie = null; let remote = null; -lpf2.on("discover", async (hub) => { // Wait to discover Vernie and Remote +pup.on("discover", async (hub) => { // Wait to discover Vernie and Remote - if (hub instanceof LPF2.BoostMoveHub) { + if (hub instanceof PoweredUP.BoostMoveHub) { vernie = hub; await vernie.connect(); console.log("Connected to Vernie!"); - } else if (hub instanceof LPF2.PUPRemote) { + } else if (hub instanceof PoweredUP.PUPRemote) { remote = hub; remote.on("button", async (button, state) => { if (vernie) { switch (state) { - case LPF2.Consts.ButtonStates.UP: // If up is pressed, move the track forward + case PoweredUP.Consts.ButtonStates.UP: // If up is pressed, move the track forward { vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 50); break; } - case LPF2.Consts.ButtonStates.DOWN: // If down is pressed, move the track backwards + case PoweredUP.Consts.ButtonStates.DOWN: // If down is pressed, move the track backwards { vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", -50); break; } - case LPF2.Consts.ButtonStates.RELEASED: // Stop the track when the button is released + case PoweredUP.Consts.ButtonStates.RELEASED: // Stop the track when the button is released { if (button !== "GREEN") { vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 0); } break; } - case LPF2.Consts.ButtonStates.STOP: // Move the head left or right when a red button is pressed + case PoweredUP.Consts.ButtonStates.STOP: // Move the head left or right when a red button is pressed { await vernie.setMotorAngle("D", 35, button === "LEFT" ? -20 : 20); break; } - case LPF2.Consts.ButtonStates.PRESSED: // Fire when the green button is pressed + case PoweredUP.Consts.ButtonStates.PRESSED: // Fire when the green button is pressed { if (button === "GREEN") { await vernie.setMotorAngle("D", 80, 20); @@ -67,8 +67,8 @@ lpf2.on("discover", async (hub) => { // Wait to discover Vernie and Remote } if (vernie && remote) { - vernie.setLEDColor(LPF2.Consts.Colors.BLUE); - remote.setLEDColor(LPF2.Consts.Colors.BLUE); + vernie.setLEDColor(PoweredUP.Consts.Colors.BLUE); + remote.setLEDColor(PoweredUP.Consts.Colors.BLUE); console.log("You're now ready to go!"); } diff --git a/package-lock.json b/package-lock.json index d19023e..c661b03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "node-lpf2", + "name": "node-poweredup", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index e1c72f0..2dc6635 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "node-lpf2", + "name": "node-poweredup", "version": "1.0.0", - "description": "A Node.js module to interface with Lego Power Functions 2.0 components.", - "main": "dist/lpf2.js", - "types": "dist/lpf2.d.ts", + "description": "A Node.js module to interface with LEGO Powered UP components.", + "main": "dist/poweredup.js", + "types": "dist/poweredup.d.ts", "scripts": { "build": "tslint -c tslint.json \"*.ts\" && tsc", - "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", + "docs": "jsdoc2md dist/poweredup.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", "all": "npm run build && npm run docs && npm run readme", "prepublishOnly": "tsc" diff --git a/lpf2.ts b/poweredup.ts similarity index 84% rename from lpf2.ts rename to poweredup.ts index c3a059e..d7f07e5 100644 --- a/lpf2.ts +++ b/poweredup.ts @@ -11,7 +11,7 @@ import * as Consts from "./consts"; import { EventEmitter} from "events"; import Debug = require("debug"); -const debug = Debug("lpf2"); +const debug = Debug("PoweredUP"); import noble = require("noble"); let ready = false; @@ -30,10 +30,10 @@ noble.on("stateChange", (state: string) => { }); /** - * @class LPF2 + * @class PoweredUP * @extends EventEmitter */ -export class LPF2 extends EventEmitter { +export class PoweredUP extends EventEmitter { public autoSubscribe: boolean = true; @@ -48,8 +48,8 @@ export class LPF2 extends EventEmitter { /** - * Begin scanning for LPF2 Hub devices. - * @method LPF2#scan + * Begin scanning for Powered UP Hub devices. + * @method PoweredUP#scan */ public scan () { wantScan = true; @@ -90,8 +90,8 @@ export class LPF2 extends EventEmitter { debug(`Hub ${hub.uuid} discovered`); /** - * Emits when a LPF2 Hub device is found. - * @event LPF2#discover + * Emits when a Powered UP Hub device is found. + * @event PoweredUP#discover * @param {WeDo2SmartHub | BoostMoveHub | PUPHub | PUPRemote} hub */ this.emit("discover", hub); @@ -106,8 +106,8 @@ export class LPF2 extends EventEmitter { /** - * Stop scanning for LPF2 Hub devices. - * @method LPF2#stop + * Stop scanning for Powered UP Hub devices. + * @method PoweredUP#stop */ public stop () { wantScan = false; @@ -116,8 +116,8 @@ export class LPF2 extends EventEmitter { /** - * Retrieve a LPF2 Hub by UUID. - * @method LPF2#getConnectedHubByUUID + * Retrieve a Powered UP Hub by UUID. + * @method PoweredUP#getConnectedHubByUUID * @param {string} uuid * @returns {Hub | null} */ @@ -127,8 +127,8 @@ export class LPF2 extends EventEmitter { /** - * Retrieve a list of LPF2 Hubs. - * @method LPF2#getConnectedHubs + * Retrieve a list of Powered UP Hubs. + * @method PoweredUP#getConnectedHubs * @returns {Hub[]} */ public getConnectedHubs () { @@ -140,5 +140,5 @@ export class LPF2 extends EventEmitter { } -export default LPF2; +export default PoweredUP; export { Hub, WeDo2SmartHub, BoostMoveHub, PUPHub, PUPRemote, Consts };