From 2212e5d31a5c129ef31738d9737bc9e5aa8d4a5e Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 11:27:04 -0800 Subject: [PATCH 01/33] Updated docs for PR#3 --- DOCS.md | 31 +++++++++++++++++++++++++++++++ README.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/DOCS.md b/DOCS.md index 2b5c01f..8a4121d 100644 --- a/DOCS.md +++ b/DOCS.md @@ -450,6 +450,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.name **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [name](#Hub+name) **Read only**: true **Properties** @@ -461,6 +462,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.uuid **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [uuid](#Hub+uuid) **Read only**: true **Properties** @@ -472,6 +474,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.rssi **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [rssi](#Hub+rssi) **Read only**: true **Properties** @@ -483,6 +486,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.batteryLevel **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [batteryLevel](#Hub+batteryLevel) **Read only**: true **Properties** @@ -599,6 +603,7 @@ Connect to the Hub. Disconnect the Hub. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [disconnect](#Hub+disconnect) **Returns**: Promise - Resolved upon successful disconnect. @@ -606,6 +611,7 @@ Disconnect the Hub. Subscribe to sensor notifications on a given port. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [subscribe](#Hub+subscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | @@ -619,6 +625,7 @@ Subscribe to sensor notifications on a given port. Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [unsubscribe](#Hub+unsubscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | @@ -633,6 +640,7 @@ 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) +**Overrides**: [sleep](#Hub+sleep) **Returns**: Promise - Resolved after the delay is finished. | Param | Type | Description | @@ -647,6 +655,7 @@ 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) +**Overrides**: [wait](#Hub+wait) **Returns**: Promise - Resolved after the commands are finished. | Param | Type | Description | @@ -720,6 +729,7 @@ Emits when a rotation sensor is activated. Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) +**Overrides**: [attach](#Hub+event_attach) | Param | Type | Description | | --- | --- | --- | @@ -732,6 +742,7 @@ Emits when a motor or sensor is attached to the Hub. Emits when an attached motor or sensor is detached from the Hub. **Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) +**Overrides**: [detach](#Hub+event_detach) | Param | Type | | --- | --- | @@ -789,6 +800,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.name **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [name](#Hub+name) **Read only**: true **Properties** @@ -800,6 +812,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.uuid **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [uuid](#Hub+uuid) **Read only**: true **Properties** @@ -811,6 +824,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.rssi **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [rssi](#Hub+rssi) **Read only**: true **Properties** @@ -822,6 +836,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.batteryLevel **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [batteryLevel](#Hub+batteryLevel) **Read only**: true **Properties** @@ -924,6 +939,7 @@ Connect to the Hub. Disconnect the Hub. **Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [disconnect](#Hub+disconnect) **Returns**: Promise - Resolved upon successful disconnect. @@ -931,6 +947,7 @@ Disconnect the Hub. Subscribe to sensor notifications on a given port. **Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [subscribe](#Hub+subscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | @@ -944,6 +961,7 @@ Subscribe to sensor notifications on a given port. Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [unsubscribe](#Hub+unsubscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | @@ -958,6 +976,7 @@ 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) +**Overrides**: [sleep](#Hub+sleep) **Returns**: Promise - Resolved after the delay is finished. | Param | Type | Description | @@ -972,6 +991,7 @@ 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) +**Overrides**: [wait](#Hub+wait) **Returns**: Promise - Resolved after the commands are finished. | Param | Type | Description | @@ -1033,6 +1053,7 @@ Emits when a tilt sensor is activated. Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [PUPHub](#PUPHub) +**Overrides**: [attach](#Hub+event_attach) | Param | Type | Description | | --- | --- | --- | @@ -1045,6 +1066,7 @@ Emits when a motor or sensor is attached to the Hub. Emits when an attached motor or sensor is detached from the Hub. **Kind**: event emitted by [PUPHub](#PUPHub) +**Overrides**: [detach](#Hub+event_detach) | Param | Type | | --- | --- | @@ -1094,6 +1116,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.name **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [name](#Hub+name) **Read only**: true **Properties** @@ -1105,6 +1128,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.uuid **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [uuid](#Hub+uuid) **Read only**: true **Properties** @@ -1116,6 +1140,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.rssi **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [rssi](#Hub+rssi) **Read only**: true **Properties** @@ -1127,6 +1152,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.batteryLevel **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [batteryLevel](#Hub+batteryLevel) **Read only**: true **Properties** @@ -1188,6 +1214,7 @@ Connect to the Hub. Disconnect the Hub. **Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [disconnect](#Hub+disconnect) **Returns**: Promise - Resolved upon successful disconnect. @@ -1195,6 +1222,7 @@ Disconnect the Hub. Subscribe to sensor notifications on a given port. **Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [subscribe](#Hub+subscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | @@ -1208,6 +1236,7 @@ Subscribe to sensor notifications on a given port. Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [unsubscribe](#Hub+unsubscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | @@ -1222,6 +1251,7 @@ 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) +**Overrides**: [sleep](#Hub+sleep) **Returns**: Promise - Resolved after the delay is finished. | Param | Type | Description | @@ -1236,6 +1266,7 @@ 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) +**Overrides**: [wait](#Hub+wait) **Returns**: Promise - Resolved after the commands are finished. | Param | Type | Description | diff --git a/README.md b/README.md index 4ddb31f..03576dc 100644 --- a/README.md +++ b/README.md @@ -529,6 +529,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.name **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [name](#Hub+name) **Read only**: true **Properties** @@ -540,6 +541,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.uuid **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [uuid](#Hub+uuid) **Read only**: true **Properties** @@ -551,6 +553,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.rssi **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [rssi](#Hub+rssi) **Read only**: true **Properties** @@ -562,6 +565,7 @@ The BoostMoveHub is emitted if the discovered device is a Boost Move Hub. ### boostMoveHub.batteryLevel **Kind**: instance property of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [batteryLevel](#Hub+batteryLevel) **Read only**: true **Properties** @@ -678,6 +682,7 @@ Connect to the Hub. Disconnect the Hub. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [disconnect](#Hub+disconnect) **Returns**: Promise - Resolved upon successful disconnect. @@ -685,6 +690,7 @@ Disconnect the Hub. Subscribe to sensor notifications on a given port. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [subscribe](#Hub+subscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | @@ -698,6 +704,7 @@ Subscribe to sensor notifications on a given port. Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [unsubscribe](#Hub+unsubscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | @@ -712,6 +719,7 @@ 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) +**Overrides**: [sleep](#Hub+sleep) **Returns**: Promise - Resolved after the delay is finished. | Param | Type | Description | @@ -726,6 +734,7 @@ 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) +**Overrides**: [wait](#Hub+wait) **Returns**: Promise - Resolved after the commands are finished. | Param | Type | Description | @@ -799,6 +808,7 @@ Emits when a rotation sensor is activated. Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) +**Overrides**: [attach](#Hub+event_attach) | Param | Type | Description | | --- | --- | --- | @@ -811,6 +821,7 @@ Emits when a motor or sensor is attached to the Hub. Emits when an attached motor or sensor is detached from the Hub. **Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) +**Overrides**: [detach](#Hub+event_detach) | Param | Type | | --- | --- | @@ -868,6 +879,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.name **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [name](#Hub+name) **Read only**: true **Properties** @@ -879,6 +891,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.uuid **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [uuid](#Hub+uuid) **Read only**: true **Properties** @@ -890,6 +903,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.rssi **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [rssi](#Hub+rssi) **Read only**: true **Properties** @@ -901,6 +915,7 @@ The PUPHub is emitted if the discovered device is a Powered UP Hub. ### pupHub.batteryLevel **Kind**: instance property of [PUPHub](#PUPHub) +**Overrides**: [batteryLevel](#Hub+batteryLevel) **Read only**: true **Properties** @@ -1003,6 +1018,7 @@ Connect to the Hub. Disconnect the Hub. **Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [disconnect](#Hub+disconnect) **Returns**: Promise - Resolved upon successful disconnect. @@ -1010,6 +1026,7 @@ Disconnect the Hub. Subscribe to sensor notifications on a given port. **Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [subscribe](#Hub+subscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | @@ -1023,6 +1040,7 @@ Subscribe to sensor notifications on a given port. Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [unsubscribe](#Hub+unsubscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | @@ -1037,6 +1055,7 @@ 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) +**Overrides**: [sleep](#Hub+sleep) **Returns**: Promise - Resolved after the delay is finished. | Param | Type | Description | @@ -1051,6 +1070,7 @@ 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) +**Overrides**: [wait](#Hub+wait) **Returns**: Promise - Resolved after the commands are finished. | Param | Type | Description | @@ -1112,6 +1132,7 @@ Emits when a tilt sensor is activated. Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [PUPHub](#PUPHub) +**Overrides**: [attach](#Hub+event_attach) | Param | Type | Description | | --- | --- | --- | @@ -1124,6 +1145,7 @@ Emits when a motor or sensor is attached to the Hub. Emits when an attached motor or sensor is detached from the Hub. **Kind**: event emitted by [PUPHub](#PUPHub) +**Overrides**: [detach](#Hub+event_detach) | Param | Type | | --- | --- | @@ -1173,6 +1195,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.name **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [name](#Hub+name) **Read only**: true **Properties** @@ -1184,6 +1207,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.uuid **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [uuid](#Hub+uuid) **Read only**: true **Properties** @@ -1195,6 +1219,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.rssi **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [rssi](#Hub+rssi) **Read only**: true **Properties** @@ -1206,6 +1231,7 @@ The PUPRemote is emitted if the discovered device is a Powered UP Remote. ### pupRemote.batteryLevel **Kind**: instance property of [PUPRemote](#PUPRemote) +**Overrides**: [batteryLevel](#Hub+batteryLevel) **Read only**: true **Properties** @@ -1267,6 +1293,7 @@ Connect to the Hub. Disconnect the Hub. **Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [disconnect](#Hub+disconnect) **Returns**: Promise - Resolved upon successful disconnect. @@ -1274,6 +1301,7 @@ Disconnect the Hub. Subscribe to sensor notifications on a given port. **Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [subscribe](#Hub+subscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | Description | @@ -1287,6 +1315,7 @@ Subscribe to sensor notifications on a given port. Unsubscribe to sensor notifications on a given port. **Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [unsubscribe](#Hub+unsubscribe) **Returns**: Promise - Resolved upon successful issuance of command. | Param | Type | @@ -1301,6 +1330,7 @@ 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) +**Overrides**: [sleep](#Hub+sleep) **Returns**: Promise - Resolved after the delay is finished. | Param | Type | Description | @@ -1315,6 +1345,7 @@ 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) +**Overrides**: [wait](#Hub+wait) **Returns**: Promise - Resolved after the commands are finished. | Param | Type | Description | From d7fb19c9262c19c6a2d72025bb90c48e419c847e Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:03:37 -0800 Subject: [PATCH 02/33] Initial CircleCI config --- .circleci/config.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..75ca634 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,29 @@ +# Javascript Node CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +# +version: 2 +jobs: + build: + docker: + - image: circleci/node:8.11.4 + working_directory: ~/repo + steps: + - checkout + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: npm install + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + - run: npm run all + + From 1f1380eb5d854eecb7b5f2c7bc1701add0716d4b Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:06:56 -0800 Subject: [PATCH 03/33] Updated noble-mac --- package-lock.json | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 57bf032..df5e662 100644 --- a/package-lock.json +++ b/package-lock.json @@ -370,7 +370,7 @@ }, "cross-spawn": { "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/c/cross-spawn/_attachments/cross-spawn-6.0.5.tgz", "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "requires": { "nice-try": "^1.0.4", @@ -602,7 +602,7 @@ }, "isexe": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/i/isexe/_attachments/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "js-tokens": { @@ -798,7 +798,7 @@ }, "napi-thread-safe-callback": { "version": "0.0.6", - "resolved": "https://registry.npmjs.org/napi-thread-safe-callback/-/napi-thread-safe-callback-0.0.6.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/n/napi-thread-safe-callback/_attachments/napi-thread-safe-callback-0.0.6.tgz", "integrity": "sha512-X7uHCOCdY4u0yamDxDrv3jF2NtYc8A1nvPzBQgvpoSX+WB3jAe2cVNsY448V1ucq7Whf9Wdy02HEUoLW5rJKWg==" }, "needle": { @@ -828,7 +828,7 @@ }, "nice-try": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/n/nice-try/_attachments/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, "noble": { @@ -858,8 +858,8 @@ } }, "noble-mac": { - "version": "git+https://github.com/Timeular/noble-mac.git#a776e9a5b66abeb45707559321e3007a0b397b48", - "from": "git+https://github.com/Timeular/noble-mac.git#a776e9a", + "version": "git+https://github.com/Timeular/noble-mac.git#af4418ef5fb1ec97a662687f6a11b7f7cc59b2b4", + "from": "git+https://github.com/Timeular/noble-mac.git#af4418e", "requires": { "cross-spawn": "^6.0.5", "napi-thread-safe-callback": "0.0.6", @@ -869,9 +869,9 @@ } }, "node-addon-api": { - "version": "1.4.0", - "resolved": "https://npm-registry.rancher.sie.sony.com/n/node-addon-api/_attachments/node-addon-api-1.4.0.tgz", - "integrity": "sha512-agquHPHnxYGox7Rjz2+TZQeOiH8IVbNFSTyTPA+peMUAP6klgrBH5dcwHsNNChQh7l/dtF0JNmZPbCqd5OXOIQ==" + "version": "1.6.1", + "resolved": "https://npm-registry.rancher.sie.sony.com/n/node-addon-api/_attachments/node-addon-api-1.6.1.tgz", + "integrity": "sha512-GcLOYrG5/enbqH4SMsqXt6GQUQGGnDnE3FLDZzXYkCgQHuZV5UDFR+EboeY8kpG0avroyOjpFQ2qLEBosFcRIA==" }, "node-pre-gyp": { "version": "0.10.3", @@ -990,7 +990,7 @@ }, "path-key": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/p/path-key/_attachments/path-key-2.0.1.tgz", "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" }, "path-parse": { @@ -1169,7 +1169,7 @@ }, "shebang-command": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/s/shebang-command/_attachments/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "requires": { "shebang-regex": "^1.0.0" @@ -1177,7 +1177,7 @@ }, "shebang-regex": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/s/shebang-regex/_attachments/shebang-regex-1.0.0.tgz", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" }, "signal-exit": { @@ -1435,7 +1435,7 @@ }, "which": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/w/which/_attachments/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "requires": { "isexe": "^2.0.0" diff --git a/package.json b/package.json index 9bb74c9..c0d54cf 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dependencies": { "debug": "^3.1.0", "noble": "1.9.1", - "noble-mac": "https://github.com/Timeular/noble-mac.git#a776e9a" + "noble-mac": "https://github.com/Timeular/noble-mac.git#af4418e" }, "devDependencies": { "jsdoc-to-markdown": "^4.0.1", From 5d23396945b4ea3127602b606f2495a0018d06e7 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:10:02 -0800 Subject: [PATCH 04/33] Updated circleci config --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75ca634..6e11f49 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,6 +17,7 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- + - run: apt-get install bluetooth bluez libbluetooth-dev libudev-dev - run: npm install - save_cache: From 24682e5431f6fe61639d89f0da3c34bcbd1a5ae2 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:11:00 -0800 Subject: [PATCH 05/33] Updated circleci config --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e11f49..efe45ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- - - run: apt-get install bluetooth bluez libbluetooth-dev libudev-dev + - run: sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev - run: npm install - save_cache: From 93b52dcae8422a34ea3294440420be99b1e7cf33 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:12:10 -0800 Subject: [PATCH 06/33] Updated circleci config --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index efe45ed..1ccb34b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- - - run: sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev + - run: sudo apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev - run: npm install - save_cache: From 436ff8ce3dc8b3a82f7e29639b80d15178b5af8e Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:19:07 -0800 Subject: [PATCH 07/33] Updated readme with ci badge --- ABOUT.md | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ABOUT.md b/ABOUT.md index 99cd6f6..358db79 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,5 +1,7 @@ # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. +CI: [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=svg)](https://circleci.com/gh/nathankellenicki/node-poweredup) + ### Introduction LEGO Powered UP is the successor to Power Functions, the system for adding electronics to LEGO models. Powered UP is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, and LEGO Powered UP released in 2018. It also includes the 2018 Duplo App-Controlled Train sets. diff --git a/README.md b/README.md index 03576dc..6aab338 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. +CI: [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=svg)](https://circleci.com/gh/nathankellenicki/node-poweredup) + ### Introduction LEGO Powered UP is the successor to Power Functions, the system for adding electronics to LEGO models. Powered UP is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, and LEGO Powered UP released in 2018. It also includes the 2018 Duplo App-Controlled Train sets. From a4837b0d385d5b35efe79a24f94ef26110a2a258 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:21:32 -0800 Subject: [PATCH 08/33] Updated readme with ci badge --- ABOUT.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index 358db79..fe1414b 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,6 +1,6 @@ -# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. +[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) -CI: [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=svg)](https://circleci.com/gh/nathankellenicki/node-poweredup) +# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. ### Introduction diff --git a/README.md b/README.md index 6aab338..a0ca166 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. +[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) -CI: [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=svg)](https://circleci.com/gh/nathankellenicki/node-poweredup) +# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. ### Introduction From 52acc2ce5a6e1a288b5751548bbe91492e304a2a Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:30:15 -0800 Subject: [PATCH 09/33] Added Gitter community --- ABOUT.md | 3 ++- README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index fe1414b..c6c97fe 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,4 +1,5 @@ -[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) +[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup)i +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective] # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. diff --git a/README.md b/README.md index a0ca166..3275586 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) +[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup)i +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective] # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. From 25937d2fbf48fe04070a60fd199adc89c2a9f04c Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:32:06 -0800 Subject: [PATCH 10/33] Added Gitter community --- ABOUT.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index c6c97fe..e0dc55a 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,5 +1,5 @@ -[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup)i -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective] +[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. diff --git a/README.md b/README.md index 3275586..a53a12e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup)i -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective] +[![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. From e7cb0daa31d1a98756f19511489e63e879707422 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:49:19 -0800 Subject: [PATCH 11/33] Added version and deps badges --- ABOUT.md | 2 ++ README.md | 2 ++ package-lock.json | 20 ++++++++++---------- package.json | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index e0dc55a..1a639a9 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,5 +1,7 @@ [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +![NPM Version](https://img.shields.io/npm/v/node-poweredup.svg?style=flat) +![Dependencies](https://img.shields.io/david/nathankellenicki/node-poweredup.svg) # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. diff --git a/README.md b/README.md index a53a12e..dfd1020 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +![NPM Version](https://img.shields.io/npm/v/node-poweredup.svg?style=flat) +![Dependencies](https://img.shields.io/david/nathankellenicki/node-poweredup.svg) # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. diff --git a/package-lock.json b/package-lock.json index df5e662..c831b8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@types/debug": { - "version": "0.0.30", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-0.0.30.tgz", - "integrity": "sha512-orGL5LXERPYsLov6CWs3Fh6203+dXzJkR7OnddIr2514Hsecwc8xRpzCapshBbKFImCsvS/mk6+FWiN5LyZJAQ==", + "version": "0.0.31", + "resolved": "https://npm-registry.rancher.sie.sony.com/@/@types/debug/_attachments/debug-0.0.31.tgz", + "integrity": "sha512-LS1MCPaQKqspg7FvexuhmDbWUhE2yIJ+4AgVIyObfc06/UKZ8REgxGNjZc82wPLWmbeOm7S+gSsLgo75TanG4A==", "dev": true }, "@types/events": { @@ -381,9 +381,9 @@ } }, "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "4.1.0", + "resolved": "https://npm-registry.rancher.sie.sony.com/d/debug/_attachments/debug-4.1.0.tgz", + "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", "requires": { "ms": "^2.1.1" } @@ -787,7 +787,7 @@ }, "ms": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "resolved": "https://npm-registry.rancher.sie.sony.com/m/ms/_attachments/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "nan": { @@ -1367,9 +1367,9 @@ } }, "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.1.6", + "resolved": "https://npm-registry.rancher.sie.sony.com/t/typescript/_attachments/typescript-3.1.6.tgz", + "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==", "dev": true }, "typical": { diff --git a/package.json b/package.json index c0d54cf..b6dde6d 100644 --- a/package.json +++ b/package.json @@ -15,15 +15,15 @@ "author": "Nathan Kellenicki ", "license": "MIT", "dependencies": { - "debug": "^3.1.0", + "debug": "^4.1.0", "noble": "1.9.1", "noble-mac": "https://github.com/Timeular/noble-mac.git#af4418e" }, "devDependencies": { "jsdoc-to-markdown": "^4.0.1", - "typescript": "^2.9.2", + "typescript": "^3.1.6", "tslint": "^5.10.0", - "@types/debug": "0.0.30", + "@types/debug": "0.0.31", "@types/noble": "0.0.37", "@types/node": "^10.3.4" }, From 54cb87974333f0edae2e5861a67eb4d34dcafb37 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:50:20 -0800 Subject: [PATCH 12/33] Added version and deps badges --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b6dde6d..0e8bd88 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,10 @@ "devDependencies": { "jsdoc-to-markdown": "^4.0.1", "typescript": "^3.1.6", - "tslint": "^5.10.0", + "tslint": "^5.11.0", "@types/debug": "0.0.31", "@types/noble": "0.0.37", - "@types/node": "^10.3.4" + "@types/node": "^10.12.9" }, "resolutions": { "xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head" From 25d5258b7693f11d79276c8914c81e43194d6590 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 12:52:01 -0800 Subject: [PATCH 13/33] Added version and deps badges --- ABOUT.md | 1 - README.md | 1 - 2 files changed, 2 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index 1a639a9..4362f64 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -1,7 +1,6 @@ [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![NPM Version](https://img.shields.io/npm/v/node-poweredup.svg?style=flat) -![Dependencies](https://img.shields.io/david/nathankellenicki/node-poweredup.svg) # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. diff --git a/README.md b/README.md index dfd1020..0226272 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ [![CircleCI](https://circleci.com/gh/nathankellenicki/node-poweredup.svg?style=shield)](https://circleci.com/gh/nathankellenicki/node-poweredup) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![NPM Version](https://img.shields.io/npm/v/node-poweredup.svg?style=flat) -![Dependencies](https://img.shields.io/david/nathankellenicki/node-poweredup.svg) # **node-poweredup** - A Node.js module to interface with LEGO Powered UP components. From cff6dbb918f634e6592ac011937677822fcf6376 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 13:33:16 -0800 Subject: [PATCH 14/33] CircleCI now publishes npm versions --- .circleci/config.yml | 47 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ccb34b..b1b064d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,30 +1,51 @@ -# Javascript Node CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-javascript/ for more details -# version: 2 + +defaults: &defaults + working_directory: ~/repo + docker: + - image: circleci/node:8.11.4 + jobs: build: - docker: - - image: circleci/node:8.11.4 - working_directory: ~/repo + <<: *defaults steps: - checkout - # Download and cache dependencies - restore_cache: keys: - v1-dependencies-{{ checksum "package.json" }} - # fallback to using the latest cache if no exact match is found - v1-dependencies- - - run: sudo apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev - run: npm install - - save_cache: paths: - node_modules key: v1-dependencies-{{ checksum "package.json" }} - - run: npm run all + deploy: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - run: + name: Authenticate with registry + command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc + - run: + name: Publish package + command: npm publish - +workflows: + version: 2 + test-deploy: + jobs: + - test: + filters: + tags: + only: /^v.*/ + - deploy: + requires: + - test + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ From b3c72770c25ad78615416bff84a371e55bd3810b Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 13:34:16 -0800 Subject: [PATCH 15/33] CircleCI now publishes npm versions --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b1b064d..a48bfe1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,13 +37,13 @@ workflows: version: 2 test-deploy: jobs: - - test: + - build: filters: tags: only: /^v.*/ - deploy: requires: - - test + - build filters: tags: only: /^v.*/ From d9a366b01c49021b996a7ee434ae928856ff8c56 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 13:34:53 -0800 Subject: [PATCH 16/33] CircleCI now publishes npm versions --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a48bfe1..30498c7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,7 +35,7 @@ jobs: workflows: version: 2 - test-deploy: + build-deploy: jobs: - build: filters: From 6209cb51e71423ed4ac41f6ff795e52203a75aac Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 15 Nov 2018 13:40:55 -0800 Subject: [PATCH 17/33] CircleCI now publishes npm versions --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30498c7..24f6e1c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,6 +21,9 @@ jobs: - node_modules key: v1-dependencies-{{ checksum "package.json" }} - run: npm run all + - persist_to_workspace: + root: ~/repo + paths: . deploy: <<: *defaults steps: From 3f48077c4f9291da5937b1d17d02c3a20426e8c1 Mon Sep 17 00:00:00 2001 From: tomaszni Date: Fri, 16 Nov 2018 12:33:53 +0100 Subject: [PATCH 18/33] Extend LPF2Hub events with "colorAndDistance" - emitting both color and distance from Boost sensor at the same time, just like the sensor information is delivered. --- DOCS.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lpf2hub.ts | 17 +++++++++++++++-- 3 files changed, 127 insertions(+), 2 deletions(-) diff --git a/DOCS.md b/DOCS.md index 8a4121d..4637f11 100644 --- a/DOCS.md +++ b/DOCS.md @@ -425,6 +425,7 @@ Emits when an attached motor or sensor is detached from the Hub. * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) * ["attach" (port, type)](#Hub+event_attach) @@ -698,6 +699,19 @@ Emits when a color sensor is activated. | port | string | | | color | number | A number representing one of the LED color consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the 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. | +| distance | number | Distance, in millimeters. | + ### "tilt" (port, x, y) @@ -776,6 +790,7 @@ Emits when an attached motor or sensor is detached from the Hub. * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) * ["attach" (port, type)](#Hub+event_attach) * ["detach" (port)](#Hub+event_detach) @@ -1034,6 +1049,19 @@ Emits when a color sensor is activated. | port | string | | | color | number | A number representing one of the LED color consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the 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. | +| distance | number | Distance, in millimeters. | + ### "tilt" (port, x, y) @@ -1095,6 +1123,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * ["button" (button, state)](#LPF2Hub+event_button) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) @@ -1285,6 +1314,19 @@ Emits when a button is pressed. | button | string | | | state | number | A number representing one of the button state consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the 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. | +| distance | number | Distance, in millimeters. | + ## DuploTrainBase ⇐ LPF2Hub @@ -1311,6 +1353,7 @@ Emits when a button is pressed. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * ["color" (port, color)](#LPF2Hub+event_color) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["speed" (port, speed)](#LPF2Hub+event_speed) @@ -1542,6 +1585,19 @@ Emits when a color sensor is activated. | port | string | | | color | number | A number representing one of the LED color consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the sensor is activated. + +**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | +| distance | number | Distance, in millimeters. | + ### "speed" (port, speed) diff --git a/README.md b/README.md index 0226272..fc1b123 100644 --- a/README.md +++ b/README.md @@ -508,6 +508,7 @@ Emits when an attached motor or sensor is detached from the Hub. * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) * ["rotate" (port, rotation)](#LPF2Hub+event_rotate) * ["attach" (port, type)](#Hub+event_attach) @@ -781,6 +782,19 @@ Emits when a color sensor is activated. | port | string | | | color | number | A number representing one of the LED color consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the 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. | +| distance | number | Distance, in millimeters. | + ### "tilt" (port, x, y) @@ -859,6 +873,7 @@ Emits when an attached motor or sensor is detached from the Hub. * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["tilt" (port, x, y)](#LPF2Hub+event_tilt) * ["attach" (port, type)](#Hub+event_attach) * ["detach" (port)](#Hub+event_detach) @@ -1117,6 +1132,19 @@ Emits when a color sensor is activated. | port | string | | | color | number | A number representing one of the LED color consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the 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. | +| distance | number | Distance, in millimeters. | + ### "tilt" (port, x, y) @@ -1178,6 +1206,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * ["button" (button, state)](#LPF2Hub+event_button) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) @@ -1368,6 +1397,19 @@ Emits when a button is pressed. | button | string | | | state | number | A number representing one of the button state consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the 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. | +| distance | number | Distance, in millimeters. | + ## DuploTrainBase ⇐ LPF2Hub @@ -1394,6 +1436,7 @@ Emits when a button is pressed. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * ["color" (port, color)](#LPF2Hub+event_color) + * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["speed" (port, speed)](#LPF2Hub+event_speed) @@ -1625,6 +1668,19 @@ Emits when a color sensor is activated. | port | string | | | color | number | A number representing one of the LED color consts. | + + +### "colorAndDistance" (port, color, distance) +A combined color and distance event, emits when the sensor is activated. + +**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase) + +| Param | Type | Description | +| --- | --- | --- | +| port | string | | +| color | number | A number representing one of the LED color consts. | +| distance | number | Distance, in millimeters. | + ### "speed" (port, speed) diff --git a/lpf2hub.ts b/lpf2hub.ts index c241e63..9b16044 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -299,10 +299,23 @@ export class LPF2Hub extends Hub { const partial = data[7]; if (partial > 0) { - distance += 1 / partial; + distance += 1.0 / partial; } - this.emit("distance", port.id, Math.floor(distance * 25.4) - 20); + distance = Math.floor(distance * 25.4) - 20; + + this.emit("distance", port.id, distance); + + /** + * A combined color and distance event, emits when the sensor is activated. + * @event LPF2Hub#colorAndDistance + * @param {string} port + * @param {number} color A number representing one of the LED color consts. + * @param {number} distance Distance, in millimeters. + */ + if (data[4] <= 10) { + this.emit("colorAndDistance", port.id, data[4], distance); + } break; } case Consts.Devices.WEDO2_TILT: From 2b0ff91438e72d7087a0be168e8737e6ebaee416 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Fri, 16 Nov 2018 15:15:20 -0800 Subject: [PATCH 19/33] Corrected package-lock.json --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c831b8d..9bc1c11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,9 +27,9 @@ } }, "@types/node": { - "version": "10.12.3", - "resolved": "https://npm-registry.rancher.sie.sony.com/@/@types/node/_attachments/node-10.12.3.tgz", - "integrity": "sha512-sfGmOtSMSbQ/AKG8V9xD1gmjquC9awIIZ/Kj309pHb2n3bcRAcGMQv5nJ6gCXZVsneGE4+ve8DXKRCsrg3TFzg==", + "version": "10.12.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.9.tgz", + "integrity": "sha512-eajkMXG812/w3w4a1OcBlaTwsFPO5F7fJ/amy+tieQxEMWBlbV1JGSjkFM+zkHNf81Cad+dfIRA+IBkvmvdAeA==", "dev": true }, "abbrev": { From 15f20724630e14a87778377e3f91d2b08c978d2f Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Fri, 16 Nov 2018 15:15:43 -0800 Subject: [PATCH 20/33] Corrected package-lock.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e8bd88..31efb6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.1.7", + "version": "1.1.8", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From c9033666be3fd080be317a5002dd50f6545336ab Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Fri, 16 Nov 2018 17:25:58 -0800 Subject: [PATCH 21/33] Version v1.1.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31efb6f..4ede279 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.1.8", + "version": "1.1.9", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From c3e5a26bdcbdbb221c21b9ccb900a7b95c0a6441 Mon Sep 17 00:00:00 2001 From: Michal Vrchota Date: Mon, 24 Dec 2018 19:31:11 +0100 Subject: [PATCH 22/33] DuploTrainBaseSounds BREAK & STEAM added --- consts.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/consts.ts b/consts.ts index f300b9b..1c29f54 100644 --- a/consts.ts +++ b/consts.ts @@ -54,9 +54,11 @@ export enum ButtonStates { export enum DuploTrainBaseSounds { + BREAK = 3, STATION_DEPARTURE = 5, WATER_REFILL = 7, - HORN = 9 + HORN = 9, + STEAM = 10 } From 1150e012af6476dc32cd68e0a04b93b54eeaeeed Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Wed, 26 Dec 2018 19:11:10 +0000 Subject: [PATCH 23/33] Bumped to 1.2.0 - fixed rotation sensor and new duplo train sounds --- lpf2hub.ts | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lpf2hub.ts b/lpf2hub.ts index 9b16044..89ec217 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -336,7 +336,7 @@ export class LPF2Hub extends Hub { } case Consts.Devices.BOOST_TACHO_MOTOR: { - const rotation = data.readInt32LE(2); + const rotation = data.readInt32LE(4); /** * Emits when a rotation sensor is activated. * @event LPF2Hub#rotate @@ -348,7 +348,7 @@ export class LPF2Hub extends Hub { } case Consts.Devices.BOOST_MOVE_HUB_MOTOR: { - const rotation = data.readInt32LE(2); + const rotation = data.readInt32LE(4); this.emit("rotate", port.id, rotation); break; } diff --git a/package.json b/package.json index 4ede279..7f34a33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.1.9", + "version": "1.2.0", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From 7bdbfbdceb837f8f9d1d92131113e76336a6fe82 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Sun, 30 Dec 2018 20:47:41 -0800 Subject: [PATCH 24/33] Documentation for the consts --- DOCS.md | 129 ++++++++++++++++++++++++++++++++++++++-------- README.md | 129 ++++++++++++++++++++++++++++++++++++++-------- consts.ts | 50 ++++++++++++++++++ duplotrainbase.ts | 4 +- hub.ts | 2 +- lpf2hub.ts | 8 +-- package.json | 2 +- pupremote.ts | 2 +- wedo2smarthub.ts | 6 +-- 9 files changed, 278 insertions(+), 54 deletions(-) diff --git a/DOCS.md b/DOCS.md index 4637f11..f426340 100644 --- a/DOCS.md +++ b/DOCS.md @@ -15,6 +15,19 @@
+## Typedefs + +
+
Devices
+
+
Colors
+
+
ButtonStates
+
+
DuploTrainBaseSounds
+
+
+ ## PoweredUP ⇐ EventEmitter @@ -172,7 +185,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -322,7 +335,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -346,7 +359,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -383,7 +396,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -574,7 +587,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -673,7 +686,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -697,7 +710,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -709,7 +722,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -748,7 +761,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -924,7 +937,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1023,7 +1036,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1047,7 +1060,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1059,7 +1072,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1086,7 +1099,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -1200,7 +1213,7 @@ Set the color of the LED on the Remote via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1312,7 +1325,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1324,7 +1337,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1431,7 +1444,7 @@ Set the color of the LED on the train via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1457,7 +1470,7 @@ Play a built-in train sound. | Param | Type | Description | | --- | --- | --- | -| sound | number | A number representing one of the Train Base sound consts. | +| sound | number | A number representing one of the DuploTrainBaseSounds. | @@ -1583,7 +1596,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1595,7 +1608,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1610,3 +1623,77 @@ Emits on a speed change. | port | string | | speed | number | + + +## Devices +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| UNKNOWN | number | 0 | +| BASIC_MOTOR | number | 1 | +| TRAIN_MOTOR | number | 2 | +| LED_LIGHTS | number | 8 | +| BOOST_LED | number | 22 | +| WEDO2_TILT | number | 34 | +| WEDO2_DISTANCE | number | 35 | +| BOOST_DISTANCE | number | 37 | +| BOOST_TACHO_MOTOR | number | 38 | +| BOOST_MOVE_HUB_MOTOR | number | 39 | +| BOOST_TILT | number | 40 | +| DUPLO_TRAIN_BASE_MOTOR | number | 41 | +| DUPLO_TRAIN_BASE_SPEAKER | number | 42 | +| DUPLO_TRAIN_BASE_COLOR | number | 43 | +| DUPLO_TRAIN_BASE_SPEEDOMETER | number | 44 | +| POWERED_UP_REMOTE_BUTTON | number | 55 | + + + +## Colors +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BLACK | number | 0 | +| PINK | number | 1 | +| PURPLE | number | 2 | +| BLUE | number | 3 | +| LIGHT_BLUE | number | 4 | +| CYAN | number | 5 | +| GREEN | number | 6 | +| YELLOW | number | 7 | +| ORANGE | number | 8 | +| RED | number | 9 | +| WHITE | number | 10 | +| NONE | number | 255 | + + + +## ButtonStates +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| PRESSED | number | 0 | +| RELEASED | number | 1 | +| UP | number | 2 | +| DOWN | number | 3 | +| STOP | number | 4 | + + + +## DuploTrainBaseSounds +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BREAK | number | 3 | +| STATION_DEPARTURE | number | 5 | +| WATER_REFILL | number | 7 | +| HORN | number | 9 | +| STEAM | number | 10 | + diff --git a/README.md b/README.md index fc1b123..56edb3b 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,19 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R
+## Typedefs + +
+
Devices
+
+
Colors
+
+
ButtonStates
+
+
DuploTrainBaseSounds
+
+
+ ## PoweredUP ⇐ EventEmitter @@ -255,7 +268,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -405,7 +418,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -429,7 +442,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -466,7 +479,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -657,7 +670,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -756,7 +769,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -780,7 +793,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -792,7 +805,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -831,7 +844,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -1007,7 +1020,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1106,7 +1119,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1130,7 +1143,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1142,7 +1155,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1169,7 +1182,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -1283,7 +1296,7 @@ Set the color of the LED on the Remote via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1395,7 +1408,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1407,7 +1420,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1514,7 +1527,7 @@ Set the color of the LED on the train via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1540,7 +1553,7 @@ Play a built-in train sound. | Param | Type | Description | | --- | --- | --- | -| sound | number | A number representing one of the Train Base sound consts. | +| sound | number | A number representing one of the DuploTrainBaseSounds. | @@ -1666,7 +1679,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1678,7 +1691,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1693,3 +1706,77 @@ Emits on a speed change. | port | string | | speed | number | + + +## Devices +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| UNKNOWN | number | 0 | +| BASIC_MOTOR | number | 1 | +| TRAIN_MOTOR | number | 2 | +| LED_LIGHTS | number | 8 | +| BOOST_LED | number | 22 | +| WEDO2_TILT | number | 34 | +| WEDO2_DISTANCE | number | 35 | +| BOOST_DISTANCE | number | 37 | +| BOOST_TACHO_MOTOR | number | 38 | +| BOOST_MOVE_HUB_MOTOR | number | 39 | +| BOOST_TILT | number | 40 | +| DUPLO_TRAIN_BASE_MOTOR | number | 41 | +| DUPLO_TRAIN_BASE_SPEAKER | number | 42 | +| DUPLO_TRAIN_BASE_COLOR | number | 43 | +| DUPLO_TRAIN_BASE_SPEEDOMETER | number | 44 | +| POWERED_UP_REMOTE_BUTTON | number | 55 | + + + +## Colors +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BLACK | number | 0 | +| PINK | number | 1 | +| PURPLE | number | 2 | +| BLUE | number | 3 | +| LIGHT_BLUE | number | 4 | +| CYAN | number | 5 | +| GREEN | number | 6 | +| YELLOW | number | 7 | +| ORANGE | number | 8 | +| RED | number | 9 | +| WHITE | number | 10 | +| NONE | number | 255 | + + + +## ButtonStates +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| PRESSED | number | 0 | +| RELEASED | number | 1 | +| UP | number | 2 | +| DOWN | number | 3 | +| STOP | number | 4 | + + + +## DuploTrainBaseSounds +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BREAK | number | 3 | +| STATION_DEPARTURE | number | 5 | +| WATER_REFILL | number | 7 | +| HORN | number | 9 | +| STEAM | number | 10 | + diff --git a/consts.ts b/consts.ts index 1c29f54..45391a6 100644 --- a/consts.ts +++ b/consts.ts @@ -8,6 +8,25 @@ export enum Hubs { } +/** + * @typedef Devices + * @property {number} UNKNOWN 0 + * @property {number} BASIC_MOTOR 1 + * @property {number} TRAIN_MOTOR 2 + * @property {number} LED_LIGHTS 8 + * @property {number} BOOST_LED 22 + * @property {number} WEDO2_TILT 34 + * @property {number} WEDO2_DISTANCE 35 + * @property {number} BOOST_DISTANCE 37 + * @property {number} BOOST_TACHO_MOTOR 38 + * @property {number} BOOST_MOVE_HUB_MOTOR 39 + * @property {number} BOOST_TILT 40 + * @property {number} DUPLO_TRAIN_BASE_MOTOR 41 + * @property {number} DUPLO_TRAIN_BASE_SPEAKER 42 + * @property {number} DUPLO_TRAIN_BASE_COLOR 43 + * @property {number} DUPLO_TRAIN_BASE_SPEEDOMETER 44 + * @property {number} POWERED_UP_REMOTE_BUTTON 55 + */ export enum Devices { UNKNOWN = 0, BASIC_MOTOR = 1, @@ -28,6 +47,21 @@ export enum Devices { } +/** + * @typedef Colors + * @property {number} BLACK 0 + * @property {number} PINK 1 + * @property {number} PURPLE 2 + * @property {number} BLUE 3 + * @property {number} LIGHT_BLUE 4 + * @property {number} CYAN 5 + * @property {number} GREEN 6 + * @property {number} YELLOW 7 + * @property {number} ORANGE 8 + * @property {number} RED 9 + * @property {number} WHITE 10 + * @property {number} NONE 255 + */ export enum Colors { BLACK = 0, PINK = 1, @@ -44,6 +78,14 @@ export enum Colors { } +/** + * @typedef ButtonStates + * @property {number} PRESSED 0 + * @property {number} RELEASED 1 + * @property {number} UP 2 + * @property {number} DOWN 3 + * @property {number} STOP 4 + */ export enum ButtonStates { PRESSED = 0, RELEASED = 1, @@ -53,6 +95,14 @@ export enum ButtonStates { } +/** + * @typedef DuploTrainBaseSounds + * @property {number} BREAK 3 + * @property {number} STATION_DEPARTURE 5 + * @property {number} WATER_REFILL 7 + * @property {number} HORN 9 + * @property {number} STEAM 10 + */ export enum DuploTrainBaseSounds { BREAK = 3, STATION_DEPARTURE = 5, diff --git a/duplotrainbase.ts b/duplotrainbase.ts index 79ede2b..21ae00f 100644 --- a/duplotrainbase.ts +++ b/duplotrainbase.ts @@ -81,7 +81,7 @@ export class DuploTrainBase extends LPF2Hub { /** * Set the color of the LED on the train via a color value. * @method DuploTrainBase#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -138,7 +138,7 @@ export class DuploTrainBase extends LPF2Hub { /** * Play a built-in train sound. * @method DuploTrainBase#playSound - * @param {number} sound A number representing one of the Train Base sound consts. + * @param {number} sound A number representing one of the DuploTrainBaseSounds. * @returns {Promise} Resolved upon successful issuance of command. */ public playSound (sound: number) { diff --git a/hub.ts b/hub.ts index c257a4f..e462875 100644 --- a/hub.ts +++ b/hub.ts @@ -257,7 +257,7 @@ export class Hub extends EventEmitter { * Emits when a motor or sensor is attached to the Hub. * @event Hub#attach * @param {string} port - * @param {number} type A number representing one of the peripheral consts. + * @param {number} type A number representing one of the Devices.. */ this.emit("attach", port.id, type); } diff --git a/lpf2hub.ts b/lpf2hub.ts index 89ec217..08d74b8 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -75,7 +75,7 @@ export class LPF2Hub extends Hub { /** * Set the color of the LED on the Hub via a color value. * @method LPF2Hub#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -186,7 +186,7 @@ export class LPF2Hub extends Hub { * Emits when a button is pressed. * @event LPF2Hub#button * @param {string} button - * @param {number} state A number representing one of the button state consts. + * @param {number} state A number representing one of the ButtonStates. */ this.emit("button", "GREEN", Consts.ButtonStates.PRESSED); return; @@ -289,7 +289,7 @@ export class LPF2Hub extends Hub { * Emits when a color sensor is activated. * @event LPF2Hub#color * @param {string} port - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors */ if (data[4] <= 10) { this.emit("color", port.id, data[4]); @@ -310,7 +310,7 @@ export class LPF2Hub extends Hub { * A combined color and distance event, emits when the sensor is activated. * @event LPF2Hub#colorAndDistance * @param {string} port - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors * @param {number} distance Distance, in millimeters. */ if (data[4] <= 10) { diff --git a/package.json b/package.json index 7f34a33..b59cf46 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "types": "dist/index.d.ts", "scripts": { "build": "tslint -c tslint.json \"*.ts\" && tsc", - "docs": "jsdoc2md dist/poweredup.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/duplotrainbase.js dist/hub.js dist/consts.js > DOCS.md", + "docs": "jsdoc2md dist/consts.js dist/poweredup.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/duplotrainbase.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": "npm run build" diff --git a/pupremote.ts b/pupremote.ts index a16b4b0..82e790f 100644 --- a/pupremote.ts +++ b/pupremote.ts @@ -85,7 +85,7 @@ export class PUPRemote extends LPF2Hub { /** * Set the color of the LED on the Remote via a color value. * @method PUPRemote#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { diff --git a/wedo2smarthub.ts b/wedo2smarthub.ts index 99b7923..ec6193a 100644 --- a/wedo2smarthub.ts +++ b/wedo2smarthub.ts @@ -87,7 +87,7 @@ export class WeDo2SmartHub extends Hub { /** * Set the color of the LED on the Hub via a color value. * @method WeDo2SmartHub#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -276,7 +276,7 @@ export class WeDo2SmartHub extends Hub { * Emits when a button is pressed. * @event WeDo2SmartHub#button * @param {string} button - * @param {number} state A number representing one of the button state consts. + * @param {number} state A number representing one of the ButtonStates. */ this.emit("button", "GREEN", Consts.ButtonStates.PRESSED); return; @@ -315,7 +315,7 @@ export class WeDo2SmartHub extends Hub { * Emits when a color sensor is activated. * @event WeDo2SmartHub#color * @param {string} port - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. */ this.emit("color", port.id, distance); break; From ad58052b7248062d197dbdaed7c5443ee3ba40f3 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Sun, 30 Dec 2018 20:49:41 -0800 Subject: [PATCH 25/33] Documentation for the consts --- DOCS.md | 2 +- README.md | 2 +- consts.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DOCS.md b/DOCS.md index f426340..8b443d5 100644 --- a/DOCS.md +++ b/DOCS.md @@ -1691,7 +1691,7 @@ Emits on a speed change. | Name | Type | Description | | --- | --- | --- | -| BREAK | number | 3 | +| BRAKE | number | 3 | | STATION_DEPARTURE | number | 5 | | WATER_REFILL | number | 7 | | HORN | number | 9 | diff --git a/README.md b/README.md index 56edb3b..70d8355 100644 --- a/README.md +++ b/README.md @@ -1774,7 +1774,7 @@ Emits on a speed change. | Name | Type | Description | | --- | --- | --- | -| BREAK | number | 3 | +| BRAKE | number | 3 | | STATION_DEPARTURE | number | 5 | | WATER_REFILL | number | 7 | | HORN | number | 9 | diff --git a/consts.ts b/consts.ts index 45391a6..478eade 100644 --- a/consts.ts +++ b/consts.ts @@ -97,7 +97,7 @@ export enum ButtonStates { /** * @typedef DuploTrainBaseSounds - * @property {number} BREAK 3 + * @property {number} BRAKE 3 * @property {number} STATION_DEPARTURE 5 * @property {number} WATER_REFILL 7 * @property {number} HORN 9 From fa6a3a3798ad0ca0fe71cfb2b855d5a21d8e07cc Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Sun, 30 Dec 2018 20:56:39 -0800 Subject: [PATCH 26/33] Documentation for the consts --- DOCS.md | 156 +++++++++++++++++++++++----------------------- README.md | 156 +++++++++++++++++++++++----------------------- boostmovehub.ts | 26 ++++---- consts.ts | 22 +++---- duplotrainbase.ts | 18 +++--- hub.ts | 22 +++---- lpf2hub.ts | 70 ++++++++++----------- port.ts | 4 +- poweredup.ts | 2 +- puphub.ts | 14 ++--- pupremote.ts | 14 ++--- wedo2smarthub.ts | 60 +++++++++--------- 12 files changed, 282 insertions(+), 282 deletions(-) diff --git a/DOCS.md b/DOCS.md index 8b443d5..f3f59f0 100644 --- a/DOCS.md +++ b/DOCS.md @@ -18,13 +18,13 @@ ## Typedefs
-
Devices
+
Device
-
Colors
+
Color
-
ButtonStates
+
ButtonState
-
DuploTrainBaseSounds
+
DuploTrainBaseSound
@@ -183,9 +183,9 @@ Set the color of the LED on the Hub via a color value. **Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -332,10 +332,10 @@ Emits when a button is pressed. **Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub) -| Param | Type | Description | -| --- | --- | --- | -| button | string | | -| state | number | A number representing one of the ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -356,10 +356,10 @@ Emits when a color sensor is activated. **Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -393,10 +393,10 @@ Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| type | number | A number representing one of the Devices.. | +| Param | Type | +| --- | --- | +| port | string | +| type | [Device](#Device) | @@ -585,9 +585,9 @@ Set the color of the LED on the Hub via a color value. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -683,10 +683,10 @@ 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 ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -707,10 +707,10 @@ 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 Colors | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -722,7 +722,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -758,10 +758,10 @@ Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) **Overrides**: [attach](#Hub+event_attach) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| type | number | A number representing one of the Devices.. | +| Param | Type | +| --- | --- | +| port | string | +| type | [Device](#Device) | @@ -935,9 +935,9 @@ Set the color of the LED on the Hub via a color value. **Kind**: instance method of [PUPHub](#PUPHub) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -1033,10 +1033,10 @@ 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 ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -1057,10 +1057,10 @@ 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 Colors | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -1072,7 +1072,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -1096,10 +1096,10 @@ Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [PUPHub](#PUPHub) **Overrides**: [attach](#Hub+event_attach) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| type | number | A number representing one of the Devices.. | +| Param | Type | +| --- | --- | +| port | string | +| type | [Device](#Device) | @@ -1211,9 +1211,9 @@ Set the color of the LED on the Remote via a color value. **Overrides**: [setLEDColor](#LPF2Hub+setLEDColor) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -1322,10 +1322,10 @@ 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 ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -1337,7 +1337,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -1442,9 +1442,9 @@ Set the color of the LED on the train via a color value. **Overrides**: [setLEDColor](#LPF2Hub+setLEDColor) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -1468,9 +1468,9 @@ Play a built-in train sound. **Kind**: instance method of [DuploTrainBase](#DuploTrainBase) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| sound | number | A number representing one of the DuploTrainBaseSounds. | +| Param | Type | +| --- | --- | +| sound | [DuploTrainBaseSound](#DuploTrainBaseSound) | @@ -1593,10 +1593,10 @@ Emits when a color sensor is activated. **Kind**: event emitted by [DuploTrainBase](#DuploTrainBase) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| color | number | A number representing one of the LED Colors | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -1608,7 +1608,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -1623,9 +1623,9 @@ Emits on a speed change. | port | string | | speed | number | - + -## Devices +## Device **Kind**: global typedef **Properties** @@ -1648,9 +1648,9 @@ Emits on a speed change. | DUPLO_TRAIN_BASE_SPEEDOMETER | number | 44 | | POWERED_UP_REMOTE_BUTTON | number | 55 | - + -## Colors +## Color **Kind**: global typedef **Properties** @@ -1669,9 +1669,9 @@ Emits on a speed change. | WHITE | number | 10 | | NONE | number | 255 | - + -## ButtonStates +## ButtonState **Kind**: global typedef **Properties** @@ -1683,9 +1683,9 @@ Emits on a speed change. | DOWN | number | 3 | | STOP | number | 4 | - + -## DuploTrainBaseSounds +## DuploTrainBaseSound **Kind**: global typedef **Properties** diff --git a/README.md b/README.md index 70d8355..d050856 100644 --- a/README.md +++ b/README.md @@ -101,13 +101,13 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R ## Typedefs
-
Devices
+
Device
-
Colors
+
Color
-
ButtonStates
+
ButtonState
-
DuploTrainBaseSounds
+
DuploTrainBaseSound
@@ -266,9 +266,9 @@ Set the color of the LED on the Hub via a color value. **Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -415,10 +415,10 @@ Emits when a button is pressed. **Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub) -| Param | Type | Description | -| --- | --- | --- | -| button | string | | -| state | number | A number representing one of the ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -439,10 +439,10 @@ Emits when a color sensor is activated. **Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -476,10 +476,10 @@ Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| type | number | A number representing one of the Devices.. | +| Param | Type | +| --- | --- | +| port | string | +| type | [Device](#Device) | @@ -668,9 +668,9 @@ Set the color of the LED on the Hub via a color value. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -766,10 +766,10 @@ 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 ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -790,10 +790,10 @@ 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 Colors | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -805,7 +805,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -841,10 +841,10 @@ Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [BoostMoveHub](#BoostMoveHub) **Overrides**: [attach](#Hub+event_attach) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| type | number | A number representing one of the Devices.. | +| Param | Type | +| --- | --- | +| port | string | +| type | [Device](#Device) | @@ -1018,9 +1018,9 @@ Set the color of the LED on the Hub via a color value. **Kind**: instance method of [PUPHub](#PUPHub) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -1116,10 +1116,10 @@ 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 ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -1140,10 +1140,10 @@ 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 Colors | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -1155,7 +1155,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -1179,10 +1179,10 @@ Emits when a motor or sensor is attached to the Hub. **Kind**: event emitted by [PUPHub](#PUPHub) **Overrides**: [attach](#Hub+event_attach) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| type | number | A number representing one of the Devices.. | +| Param | Type | +| --- | --- | +| port | string | +| type | [Device](#Device) | @@ -1294,9 +1294,9 @@ Set the color of the LED on the Remote via a color value. **Overrides**: [setLEDColor](#LPF2Hub+setLEDColor) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -1405,10 +1405,10 @@ 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 ButtonStates. | +| Param | Type | +| --- | --- | +| button | string | +| state | [ButtonState](#ButtonState) | @@ -1420,7 +1420,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -1525,9 +1525,9 @@ Set the color of the LED on the train via a color value. **Overrides**: [setLEDColor](#LPF2Hub+setLEDColor) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| color | number | A number representing one of the LED Colors. | +| Param | Type | +| --- | --- | +| color | [Color](#Color) | @@ -1551,9 +1551,9 @@ Play a built-in train sound. **Kind**: instance method of [DuploTrainBase](#DuploTrainBase) **Returns**: Promise - Resolved upon successful issuance of command. -| Param | Type | Description | -| --- | --- | --- | -| sound | number | A number representing one of the DuploTrainBaseSounds. | +| Param | Type | +| --- | --- | +| sound | [DuploTrainBaseSound](#DuploTrainBaseSound) | @@ -1676,10 +1676,10 @@ Emits when a color sensor is activated. **Kind**: event emitted by [DuploTrainBase](#DuploTrainBase) -| Param | Type | Description | -| --- | --- | --- | -| port | string | | -| color | number | A number representing one of the LED Colors | +| Param | Type | +| --- | --- | +| port | string | +| color | [Color](#Color) | @@ -1691,7 +1691,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED Colors | +| color | [Color](#Color) | | | distance | number | Distance, in millimeters. | @@ -1706,9 +1706,9 @@ Emits on a speed change. | port | string | | speed | number | - + -## Devices +## Device **Kind**: global typedef **Properties** @@ -1731,9 +1731,9 @@ Emits on a speed change. | DUPLO_TRAIN_BASE_SPEEDOMETER | number | 44 | | POWERED_UP_REMOTE_BUTTON | number | 55 | - + -## Colors +## Color **Kind**: global typedef **Properties** @@ -1752,9 +1752,9 @@ Emits on a speed change. | WHITE | number | 10 | | NONE | number | 255 | - + -## ButtonStates +## ButtonState **Kind**: global typedef **Properties** @@ -1766,9 +1766,9 @@ Emits on a speed change. | DOWN | number | 3 | | STOP | number | 4 | - + -## DuploTrainBaseSounds +## DuploTrainBaseSound **Kind**: global typedef **Properties** diff --git a/boostmovehub.ts b/boostmovehub.ts index 3a04fd8..8d0ad09 100644 --- a/boostmovehub.ts +++ b/boostmovehub.ts @@ -27,13 +27,13 @@ export class BoostMoveHub extends LPF2Hub { public static IsBoostMoveHub (peripheral: Peripheral) { - return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.BOOST_MOVE_HUB_ID); + return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.BOOST_MOVE_HUB_ID); } constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hubs.BOOST_MOVE_HUB; + this.type = Consts.Hub.BOOST_MOVE_HUB; this._ports = { "A": new Port("A", 55), "B": new Port("B", 56), @@ -82,7 +82,7 @@ export class BoostMoveHub extends LPF2Hub { return new Promise((resolve, reject) => { if (time && typeof time === "number") { - if (portObj.type === Consts.Devices.BOOST_TACHO_MOTOR || portObj.type === Consts.Devices.BOOST_MOVE_HUB_MOTOR) { + if (portObj.type === Consts.Device.BOOST_TACHO_MOTOR || portObj.type === Consts.Device.BOOST_MOVE_HUB_MOTOR) { portObj.busy = true; let data = null; if (portObj.id === "AB") { @@ -92,17 +92,17 @@ export class BoostMoveHub extends LPF2Hub { data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); } data.writeUInt16LE(time > 65535 ? 65535 : time, 4); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); portObj.finished = () => { return resolve(); }; } else { // @ts-ignore: The type of speed is properly checked at the start const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); const timeout = global.setTimeout(() => { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); // @ts-ignore: The type of time is properly checked at the start }, time); @@ -111,7 +111,7 @@ export class BoostMoveHub extends LPF2Hub { } else { - if (portObj.type === Consts.Devices.BOOST_TACHO_MOTOR || portObj.type === Consts.Devices.BOOST_MOVE_HUB_MOTOR) { + if (portObj.type === Consts.Device.BOOST_TACHO_MOTOR || portObj.type === Consts.Device.BOOST_MOVE_HUB_MOTOR) { portObj.busy = true; let data = null; if (portObj.id === "AB") { @@ -120,14 +120,14 @@ export class BoostMoveHub extends LPF2Hub { // @ts-ignore: The type of speed is properly checked at the start data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); } - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); portObj.finished = () => { return resolve(); }; } else { // @ts-ignore: The type of speed is properly checked at the start const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); } } @@ -167,7 +167,7 @@ export class BoostMoveHub extends LPF2Hub { */ public setMotorAngle (port: string, angle: number, speed: number | [number, number] = 100) { const portObj = this._portLookup(port); - if (!(portObj.type === Consts.Devices.BOOST_TACHO_MOTOR || portObj.type === Consts.Devices.BOOST_MOVE_HUB_MOTOR)) { + if (!(portObj.type === Consts.Device.BOOST_TACHO_MOTOR || portObj.type === Consts.Device.BOOST_MOVE_HUB_MOTOR)) { throw new Error("Angle rotation is only available when using a Boost Tacho Motor or Boost Move Hub Motor"); } if (portObj.id !== "AB" && speed instanceof Array) { @@ -184,7 +184,7 @@ export class BoostMoveHub extends LPF2Hub { data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); } data.writeUInt32LE(angle, 4); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); portObj.finished = () => { return resolve(); }; @@ -205,11 +205,11 @@ export class BoostMoveHub extends LPF2Hub { portObj.cancelEventTimer(); return new Promise((resolve, reject) => { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, brightness]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); if (time) { const timeout = global.setTimeout(() => { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }, time); portObj.setEventTimer(timeout); diff --git a/consts.ts b/consts.ts index 478eade..dc48c68 100644 --- a/consts.ts +++ b/consts.ts @@ -1,4 +1,4 @@ -export enum Hubs { +export enum Hub { UNKNOWN = 0, WEDO2_SMART_HUB = 1, BOOST_MOVE_HUB = 2, @@ -9,7 +9,7 @@ export enum Hubs { /** - * @typedef Devices + * @typedef Device * @property {number} UNKNOWN 0 * @property {number} BASIC_MOTOR 1 * @property {number} TRAIN_MOTOR 2 @@ -27,7 +27,7 @@ export enum Hubs { * @property {number} DUPLO_TRAIN_BASE_SPEEDOMETER 44 * @property {number} POWERED_UP_REMOTE_BUTTON 55 */ -export enum Devices { +export enum Device { UNKNOWN = 0, BASIC_MOTOR = 1, TRAIN_MOTOR = 2, @@ -48,7 +48,7 @@ export enum Devices { /** - * @typedef Colors + * @typedef Color * @property {number} BLACK 0 * @property {number} PINK 1 * @property {number} PURPLE 2 @@ -62,7 +62,7 @@ export enum Devices { * @property {number} WHITE 10 * @property {number} NONE 255 */ -export enum Colors { +export enum Color { BLACK = 0, PINK = 1, PURPLE = 2, @@ -79,14 +79,14 @@ export enum Colors { /** - * @typedef ButtonStates + * @typedef ButtonState * @property {number} PRESSED 0 * @property {number} RELEASED 1 * @property {number} UP 2 * @property {number} DOWN 3 * @property {number} STOP 4 */ -export enum ButtonStates { +export enum ButtonState { PRESSED = 0, RELEASED = 1, UP = 2, @@ -96,14 +96,14 @@ export enum ButtonStates { /** - * @typedef DuploTrainBaseSounds + * @typedef DuploTrainBaseSound * @property {number} BRAKE 3 * @property {number} STATION_DEPARTURE 5 * @property {number} WATER_REFILL 7 * @property {number} HORN 9 * @property {number} STEAM 10 */ -export enum DuploTrainBaseSounds { +export enum DuploTrainBaseSound { BREAK = 3, STATION_DEPARTURE = 5, WATER_REFILL = 7, @@ -120,13 +120,13 @@ export enum BLEManufacturerData { } -export enum BLEServices { +export enum BLEService { WEDO2_SMART_HUB = "00001523-1212-efde-1523-785feabcd123", LPF2_HUB = "00001623-1212-efde-1623-785feabcd123" } -export enum BLECharacteristics { +export enum BLECharacteristic { WEDO2_BATTERY = "2a19", WEDO2_BUTTON = "00001526-1212-efde-1523-785feabcd123", // "1526" WEDO2_PORT_TYPE = "00001527-1212-efde-1523-785feabcd123", // "1527" // Handles plugging and unplugging of devices on WeDo 2.0 Smart Hub diff --git a/duplotrainbase.ts b/duplotrainbase.ts index 21ae00f..8581b92 100644 --- a/duplotrainbase.ts +++ b/duplotrainbase.ts @@ -52,13 +52,13 @@ export class DuploTrainBase extends LPF2Hub { public static IsDuploTrainBase (peripheral: Peripheral) { - return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID); + return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID); } constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hubs.DUPLO_TRAIN_HUB; + this.type = Consts.Hub.DUPLO_TRAIN_HUB; this._ports = { "MOTOR": new Port("MOTOR", 0), "COLOR": new Port("COLOR", 18), @@ -81,7 +81,7 @@ export class DuploTrainBase extends LPF2Hub { /** * Set the color of the LED on the train via a color value. * @method DuploTrainBase#setLEDColor - * @param {number} color A number representing one of the LED Colors. + * @param {Color} color * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -90,7 +90,7 @@ export class DuploTrainBase extends LPF2Hub { color = 0; } const data = Buffer.from([0x81, 0x11, 0x11, 0x51, 0x00, color]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }); } @@ -119,16 +119,16 @@ export class DuploTrainBase extends LPF2Hub { return new Promise((resolve, reject) => { if (time && typeof time === "number") { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); const timeout = global.setTimeout(() => { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }, time); portObj.setEventTimer(timeout); } else { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); } }); @@ -138,13 +138,13 @@ export class DuploTrainBase extends LPF2Hub { /** * Play a built-in train sound. * @method DuploTrainBase#playSound - * @param {number} sound A number representing one of the DuploTrainBaseSounds. + * @param {DuploTrainBaseSound} sound * @returns {Promise} Resolved upon successful issuance of command. */ public playSound (sound: number) { return new Promise((resolve, reject) => { const data = Buffer.from([0x81, 0x01, 0x11, 0x51, 0x01, sound]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }); } diff --git a/hub.ts b/hub.ts index e462875..6763015 100644 --- a/hub.ts +++ b/hub.ts @@ -19,7 +19,7 @@ export class Hub extends EventEmitter { public autoSubscribe: boolean = true; public useSpeedMap: boolean = true; - public type: Consts.Hubs = Consts.Hubs.UNKNOWN; + public type: Consts.Hub = Consts.Hub.UNKNOWN; protected _ports: {[port: string]: Port} = {}; protected _characteristics: {[uuid: string]: Characteristic} = {}; @@ -257,12 +257,12 @@ export class Hub extends EventEmitter { * Emits when a motor or sensor is attached to the Hub. * @event Hub#attach * @param {string} port - * @param {number} type A number representing one of the Devices.. + * @param {Device} type */ this.emit("attach", port.id, type); } } else { - port.type = Consts.Devices.UNKNOWN; + port.type = Consts.Device.UNKNOWN; debug(`Port ${port.id} disconnected`); /** * Emits when an attached motor or sensor is detached from the Hub. @@ -349,19 +349,19 @@ export class Hub extends EventEmitter { } - private _getModeForDeviceType (type: Consts.Devices) { + private _getModeForDeviceType (type: Consts.Device) { switch (type) { - case Consts.Devices.BASIC_MOTOR: + case Consts.Device.BASIC_MOTOR: return 0x02; - case Consts.Devices.TRAIN_MOTOR: + case Consts.Device.TRAIN_MOTOR: return 0x02; - case Consts.Devices.BOOST_TACHO_MOTOR: + case Consts.Device.BOOST_TACHO_MOTOR: return 0x02; - case Consts.Devices.BOOST_MOVE_HUB_MOTOR: + case Consts.Device.BOOST_MOVE_HUB_MOTOR: return 0x02; - case Consts.Devices.BOOST_DISTANCE: - return (this.type === Consts.Hubs.WEDO2_SMART_HUB ? 0x00 : 0x08); - case Consts.Devices.BOOST_TILT: + case Consts.Device.BOOST_DISTANCE: + return (this.type === Consts.Hub.WEDO2_SMART_HUB ? 0x00 : 0x08); + case Consts.Device.BOOST_TILT: return 0x04; default: return 0x00; diff --git a/lpf2hub.ts b/lpf2hub.ts index 08d74b8..1d19681 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -37,13 +37,13 @@ export class LPF2Hub extends Hub { public connect () { return new Promise(async (resolve, reject) => { await super.connect(); - const characteristic = this._getCharacteristic(Consts.BLECharacteristics.LPF2_ALL); + const characteristic = this._getCharacteristic(Consts.BLECharacteristic.LPF2_ALL); this._subscribeToCharacteristic(characteristic, this._parseMessage.bind(this)); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, Buffer.from([0x01, 0x02, 0x02])); // Activate button reports - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, Buffer.from([0x41, 0x3b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate current reports - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, Buffer.from([0x41, 0x3c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate voltage reports - if (this.type === Consts.Hubs.DUPLO_TRAIN_HUB) { - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, Buffer.from([0x41, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01])); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x02, 0x02])); // Activate button reports + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate current reports + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate voltage reports + if (this.type === Consts.Hub.DUPLO_TRAIN_HUB) { + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01])); } return resolve(); }); @@ -64,8 +64,8 @@ export class LPF2Hub extends Hub { let data = Buffer.from([0x01, 0x01, 0x01]); data = Buffer.concat([data, Buffer.from(name, "ascii")]); // Send this twice, as sometimes the first time doesn't take - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); this._name = name; return resolve(); }); @@ -75,18 +75,18 @@ export class LPF2Hub extends Hub { /** * Set the color of the LED on the Hub via a color value. * @method LPF2Hub#setLEDColor - * @param {number} color A number representing one of the LED Colors. + * @param {Color} color * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { return new Promise((resolve, reject) => { let data = Buffer.from([0x41, 0x32, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); if (color === false) { color = 0; } data = Buffer.from([0x81, 0x32, 0x11, 0x51, 0x00, color]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }); } @@ -103,21 +103,21 @@ export class LPF2Hub extends Hub { public setLEDRGB (red: number, green: number, blue: number) { return new Promise((resolve, reject) => { let data = Buffer.from([0x41, 0x32, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); data = Buffer.from([0x81, 0x32, 0x11, 0x51, 0x01, red, green, blue]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }); } protected _activatePortDevice (port: number, type: number, mode: number, format: number, callback?: () => void) { - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, Buffer.from([0x41, port, mode, 0x01, 0x00, 0x00, 0x00, 0x01]), callback); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, port, mode, 0x01, 0x00, 0x00, 0x00, 0x01]), callback); } protected _deactivatePortDevice (port: number, type: number, mode: number, format: number, callback?: () => void) { - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, Buffer.from([0x41, port, mode, 0x01, 0x00, 0x00, 0x00, 0x00]), callback); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, port, mode, 0x01, 0x00, 0x00, 0x00, 0x00]), callback); } @@ -186,12 +186,12 @@ export class LPF2Hub extends Hub { * Emits when a button is pressed. * @event LPF2Hub#button * @param {string} button - * @param {number} state A number representing one of the ButtonStates. + * @param {ButtonState} state */ - this.emit("button", "GREEN", Consts.ButtonStates.PRESSED); + this.emit("button", "GREEN", Consts.ButtonState.PRESSED); return; } else if (data[5] === 0) { - this.emit("button", "GREEN", Consts.ButtonStates.RELEASED); + this.emit("button", "GREEN", Consts.ButtonState.RELEASED); return; } } @@ -242,12 +242,12 @@ export class LPF2Hub extends Hub { private _parseSensorMessage (data: Buffer) { - if ((data[3] === 0x3b && this.type === Consts.Hubs.POWERED_UP_REMOTE) || (data[3] === 0x3c && this.type !== Consts.Hubs.POWERED_UP_REMOTE)) { // Voltage + if ((data[3] === 0x3b && this.type === Consts.Hub.POWERED_UP_REMOTE) || (data[3] === 0x3c && this.type !== Consts.Hub.POWERED_UP_REMOTE)) { // Voltage data = this._padMessage(data, 6); const batteryLevel = (data.readUInt16LE(4) / 4096) * 100; this._batteryLevel = Math.floor(batteryLevel); return; - } else if (data[3] === 0x3b && this.type !== Consts.Hubs.POWERED_UP_REMOTE) { // Current (Non-PUP Remote) + } else if (data[3] === 0x3b && this.type !== Consts.Hub.POWERED_UP_REMOTE) { // Current (Non-PUP Remote) data = this._padMessage(data, 6); const current = data.readUInt16LE(4) / 4096; this._current = current * 100; @@ -267,7 +267,7 @@ export class LPF2Hub extends Hub { if (port && port.connected) { switch (port.type) { - case Consts.Devices.WEDO2_DISTANCE: + case Consts.Device.WEDO2_DISTANCE: { let distance = data[4]; if (data[5] === 1) { @@ -282,14 +282,14 @@ export class LPF2Hub extends Hub { this.emit("distance", port.id, distance * 10); break; } - case Consts.Devices.BOOST_DISTANCE: + case Consts.Device.BOOST_DISTANCE: { /** * Emits when a color sensor is activated. * @event LPF2Hub#color * @param {string} port - * @param {number} color A number representing one of the LED Colors + * @param {Color} color */ if (data[4] <= 10) { this.emit("color", port.id, data[4]); @@ -310,7 +310,7 @@ export class LPF2Hub extends Hub { * A combined color and distance event, emits when the sensor is activated. * @event LPF2Hub#colorAndDistance * @param {string} port - * @param {number} color A number representing one of the LED Colors + * @param {Color} color * @param {number} distance Distance, in millimeters. */ if (data[4] <= 10) { @@ -318,7 +318,7 @@ export class LPF2Hub extends Hub { } break; } - case Consts.Devices.WEDO2_TILT: + case Consts.Device.WEDO2_TILT: { const tiltX = data[4] > 160 ? data[4] - 255 : data[4] - (data[4] * 2); const tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2); @@ -334,7 +334,7 @@ export class LPF2Hub extends Hub { this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY); break; } - case Consts.Devices.BOOST_TACHO_MOTOR: + case Consts.Device.BOOST_TACHO_MOTOR: { const rotation = data.readInt32LE(4); /** @@ -346,53 +346,53 @@ export class LPF2Hub extends Hub { this.emit("rotate", port.id, rotation); break; } - case Consts.Devices.BOOST_MOVE_HUB_MOTOR: + case Consts.Device.BOOST_MOVE_HUB_MOTOR: { const rotation = data.readInt32LE(4); this.emit("rotate", port.id, rotation); break; } - case Consts.Devices.BOOST_TILT: + case Consts.Device.BOOST_TILT: { const tiltX = data[4] > 160 ? data[4] - 255 : data[4]; const tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2); this.emit("tilt", port.id, tiltX, tiltY); break; } - case Consts.Devices.POWERED_UP_REMOTE_BUTTON: + case Consts.Device.POWERED_UP_REMOTE_BUTTON: { switch (data[4]) { case 0x01: { - this.emit("button", port.id, Consts.ButtonStates.UP); + this.emit("button", port.id, Consts.ButtonState.UP); break; } case 0xff: { - this.emit("button", port.id, Consts.ButtonStates.DOWN); + this.emit("button", port.id, Consts.ButtonState.DOWN); break; } case 0x7f: { - this.emit("button", port.id, Consts.ButtonStates.STOP); + this.emit("button", port.id, Consts.ButtonState.STOP); break; } case 0x00: { - this.emit("button", port.id, Consts.ButtonStates.RELEASED); + this.emit("button", port.id, Consts.ButtonState.RELEASED); break; } } break; } - case Consts.Devices.DUPLO_TRAIN_BASE_COLOR: + case Consts.Device.DUPLO_TRAIN_BASE_COLOR: { if (data[4] <= 10) { this.emit("color", port.id, data[4]); } break; } - case Consts.Devices.DUPLO_TRAIN_BASE_SPEEDOMETER: + case Consts.Device.DUPLO_TRAIN_BASE_SPEEDOMETER: { /** * Emits on a speed change. diff --git a/port.ts b/port.ts index 508f703..20d1274 100644 --- a/port.ts +++ b/port.ts @@ -6,7 +6,7 @@ export class Port { public id: string; public value: number; - public type: Consts.Devices; + public type: Consts.Device; public connected: boolean = false; public busy: boolean = false; public finished: (() => void) | null = null; @@ -16,7 +16,7 @@ export class Port { constructor (id: string, value: number) { this.id = id; this.value = value; - this.type = Consts.Devices.UNKNOWN; + this.type = Consts.Device.UNKNOWN; } public cancelEventTimer () { diff --git a/poweredup.ts b/poweredup.ts index 16b2058..942d99b 100644 --- a/poweredup.ts +++ b/poweredup.ts @@ -22,7 +22,7 @@ let wantScan = false; const startScanning = () => { if (isBrowserContext) { - noble.startScanning([Consts.BLEServices.WEDO2_SMART_HUB, Consts.BLEServices.LPF2_HUB]); + noble.startScanning([Consts.BLEService.WEDO2_SMART_HUB, Consts.BLEService.LPF2_HUB]); } else { noble.startScanning(); } diff --git a/puphub.ts b/puphub.ts index 1b6c726..360b770 100644 --- a/puphub.ts +++ b/puphub.ts @@ -32,13 +32,13 @@ export class PUPHub extends LPF2Hub { public static IsPUPHub (peripheral: Peripheral) { - return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_HUB_ID); + return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_HUB_ID); } constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hubs.POWERED_UP_HUB; + this.type = Consts.Hub.POWERED_UP_HUB; this._ports = { "A": new Port("A", 0), "B": new Port("B", 1), @@ -97,7 +97,7 @@ export class PUPHub extends LPF2Hub { // @ts-ignore: The type of speed is properly checked at the start data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]); } - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); const timeout = global.setTimeout(() => { let data = null; if (portObj.id === "AB") { @@ -105,7 +105,7 @@ export class PUPHub extends LPF2Hub { } else { data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, 0x00, 0x00, 0x00]); } - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }, time); portObj.setEventTimer(timeout); @@ -117,7 +117,7 @@ export class PUPHub extends LPF2Hub { // @ts-ignore: The type of speed is properly checked at the start data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]); } - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); } }); @@ -159,11 +159,11 @@ export class PUPHub extends LPF2Hub { portObj.cancelEventTimer(); return new Promise((resolve, reject) => { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, brightness]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); if (time) { const timeout = global.setTimeout(() => { const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }, time); portObj.setEventTimer(timeout); diff --git a/pupremote.ts b/pupremote.ts index 82e790f..4659648 100644 --- a/pupremote.ts +++ b/pupremote.ts @@ -57,13 +57,13 @@ export class PUPRemote extends LPF2Hub { public static IsPUPRemote (peripheral: Peripheral) { - return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_REMOTE_ID); + return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_REMOTE_ID); } constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hubs.POWERED_UP_REMOTE; + this.type = Consts.Hub.POWERED_UP_REMOTE; this._ports = { "LEFT": new Port("LEFT", 0), "RIGHT": new Port("RIGHT", 1) @@ -85,18 +85,18 @@ export class PUPRemote extends LPF2Hub { /** * Set the color of the LED on the Remote via a color value. * @method PUPRemote#setLEDColor - * @param {number} color A number representing one of the LED Colors. + * @param {Color} color * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { return new Promise((resolve, reject) => { let data = Buffer.from([0x41, 0x34, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); if (color === false) { color = 0; } data = Buffer.from([0x81, 0x34, 0x11, 0x51, 0x00, color]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }); } @@ -113,9 +113,9 @@ export class PUPRemote extends LPF2Hub { public setLEDRGB (red: number, green: number, blue: number) { return new Promise((resolve, reject) => { let data = Buffer.from([0x41, 0x34, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); data = Buffer.from([0x81, 0x34, 0x11, 0x51, 0x01, red, green, blue]); - this._writeMessage(Consts.BLECharacteristics.LPF2_ALL, data); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); return resolve(); }); } diff --git a/wedo2smarthub.ts b/wedo2smarthub.ts index ec6193a..da4c262 100644 --- a/wedo2smarthub.ts +++ b/wedo2smarthub.ts @@ -26,7 +26,7 @@ export class WeDo2SmartHub extends Hub { public static IsWeDo2SmartHub (peripheral: Peripheral) { - return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEServices.WEDO2_SMART_HUB.replace(/-/g, "")) >= 0); + return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.WEDO2_SMART_HUB.replace(/-/g, "")) >= 0); } @@ -36,7 +36,7 @@ export class WeDo2SmartHub extends Hub { constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hubs.WEDO2_SMART_HUB; + this.type = Consts.Hub.WEDO2_SMART_HUB; this._ports = { "A": new Port("A", 1), "B": new Port("B", 2) @@ -49,12 +49,12 @@ export class WeDo2SmartHub extends Hub { return new Promise(async (resolve, reject) => { debug("Connecting to WeDo 2.0 Smart Hub"); await super.connect(); - this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristics.WEDO2_PORT_TYPE), this._parsePortMessage.bind(this)); - this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristics.WEDO2_SENSOR_VALUE), this._parseSensorMessage.bind(this)); - this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristics.WEDO2_BUTTON), this._parseSensorMessage.bind(this)); - this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristics.WEDO2_BATTERY), this._parseBatteryMessage.bind(this)); - this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristics.WEDO2_HIGH_CURRENT_ALERT), this._parseHighCurrentAlert.bind(this)); - this._getCharacteristic(Consts.BLECharacteristics.WEDO2_BATTERY).read((err, data) => { + this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE), this._parsePortMessage.bind(this)); + this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE), this._parseSensorMessage.bind(this)); + this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON), this._parseSensorMessage.bind(this)); + this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY), this._parseBatteryMessage.bind(this)); + this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT), this._parseHighCurrentAlert.bind(this)); + this._getCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY).read((err, data) => { this._parseBatteryMessage(data); }); debug("Connect completed"); @@ -76,8 +76,8 @@ export class WeDo2SmartHub extends Hub { return new Promise((resolve, reject) => { const data = Buffer.from(name, "ascii"); // Send this twice, as sometimes the first time doesn't take - this._writeMessage(Consts.BLECharacteristics.WEDO2_NAME_ID, data); - this._writeMessage(Consts.BLECharacteristics.WEDO2_NAME_ID, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_NAME_ID, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_NAME_ID, data); this._name = name; return resolve(); }); @@ -87,18 +87,18 @@ export class WeDo2SmartHub extends Hub { /** * Set the color of the LED on the Hub via a color value. * @method WeDo2SmartHub#setLEDColor - * @param {number} color A number representing one of the LED Colors. + * @param {Color} color * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { return new Promise((resolve, reject) => { let data = Buffer.from([0x06, 0x17, 0x01, 0x01]); - this._writeMessage(Consts.BLECharacteristics.WEDO2_PORT_TYPE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, data); if (color === false) { color = 0; } data = Buffer.from([0x06, 0x04, 0x01, color]); - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data); return resolve(); }); } @@ -115,9 +115,9 @@ export class WeDo2SmartHub extends Hub { public setLEDRGB (red: number, green: number, blue: number) { return new Promise((resolve, reject) => { let data = Buffer.from([0x06, 0x17, 0x01, 0x02]); - this._writeMessage(Consts.BLECharacteristics.WEDO2_PORT_TYPE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, data); data = Buffer.from([0x06, 0x04, 0x03, red, green, blue]); - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data); return resolve(); }); } @@ -144,10 +144,10 @@ export class WeDo2SmartHub extends Hub { portObj.cancelEventTimer(); } return new Promise((resolve, reject) => { - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, Buffer.from([portObj.value, 0x01, 0x02, this._mapSpeed(speed)])); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, Buffer.from([portObj.value, 0x01, 0x02, this._mapSpeed(speed)])); if (time && typeof time === "number") { const timeout = global.setTimeout(() => { - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, Buffer.from([portObj.value, 0x01, 0x02, 0x00])); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, Buffer.from([portObj.value, 0x01, 0x02, 0x00])); return resolve(); }, time); portObj.setEventTimer(timeout); @@ -192,7 +192,7 @@ export class WeDo2SmartHub extends Hub { const data = Buffer.from([0x05, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00]); data.writeUInt16LE(frequency, 3); data.writeUInt16LE(time, 5); - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data); global.setTimeout(resolve, time); }); } @@ -211,11 +211,11 @@ export class WeDo2SmartHub extends Hub { portObj.cancelEventTimer(); return new Promise((resolve, reject) => { const data = Buffer.from([portObj.value, 0x01, 0x02, brightness]); - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data); if (time) { const timeout = global.setTimeout(() => { const data = Buffer.from([portObj.value, 0x01, 0x02, 0x00]); - this._writeMessage(Consts.BLECharacteristics.WEDO2_MOTOR_VALUE_WRITE, data); + this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data); return resolve(); }, time); portObj.setEventTimer(timeout); @@ -227,12 +227,12 @@ export class WeDo2SmartHub extends Hub { protected _activatePortDevice (port: number, type: number, mode: number, format: number, callback?: () => void) { - this._writeMessage(Consts.BLECharacteristics.WEDO2_PORT_TYPE_WRITE, Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x01]), callback); + this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x01]), callback); } protected _deactivatePortDevice (port: number, type: number, mode: number, format: number, callback?: () => void) { - this._writeMessage(Consts.BLECharacteristics.WEDO2_PORT_TYPE_WRITE, Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x00]), callback); + this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x00]), callback); } @@ -276,12 +276,12 @@ export class WeDo2SmartHub extends Hub { * Emits when a button is pressed. * @event WeDo2SmartHub#button * @param {string} button - * @param {number} state A number representing one of the ButtonStates. + * @param {ButtonState} state */ - this.emit("button", "GREEN", Consts.ButtonStates.PRESSED); + this.emit("button", "GREEN", Consts.ButtonState.PRESSED); return; } else if (data[0] === 0x00) { - this.emit("button", "GREEN", Consts.ButtonStates.RELEASED); + this.emit("button", "GREEN", Consts.ButtonState.RELEASED); return; } @@ -293,7 +293,7 @@ export class WeDo2SmartHub extends Hub { if (port && port.connected) { switch (port.type) { - case Consts.Devices.WEDO2_DISTANCE: + case Consts.Device.WEDO2_DISTANCE: { let distance = data[2]; if (data[3] === 1) { @@ -308,19 +308,19 @@ export class WeDo2SmartHub extends Hub { this.emit("distance", port.id, distance * 10); break; } - case Consts.Devices.BOOST_DISTANCE: + case Consts.Device.BOOST_DISTANCE: { const distance = data[2]; /** * Emits when a color sensor is activated. * @event WeDo2SmartHub#color * @param {string} port - * @param {number} color A number representing one of the LED Colors. + * @param {Color} color */ this.emit("color", port.id, distance); break; } - case Consts.Devices.WEDO2_TILT: + case Consts.Device.WEDO2_TILT: { this._lastTiltX = data[2]; if (this._lastTiltX > 100) { @@ -340,7 +340,7 @@ export class WeDo2SmartHub extends Hub { this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY); break; } - case Consts.Devices.BOOST_TACHO_MOTOR: + case Consts.Device.BOOST_TACHO_MOTOR: { const rotation = data.readInt32LE(2); /** From 1e129ac77d939d292c7033b83f41c87348f1146a Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Sun, 30 Dec 2018 20:58:38 -0800 Subject: [PATCH 27/33] Bumped package.json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b59cf46..5e16a40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.2.0", + "version": "1.3.0", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From 7b192266fffee65fecf88106574e4e54aae0e07a Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 31 Dec 2018 13:24:57 -0800 Subject: [PATCH 28/33] Added methods for fetching hub and device types --- DOCS.md | 126 ++++++++++++++++++++++++++++++++++++++++++++-- README.md | 126 ++++++++++++++++++++++++++++++++++++++++++++-- boostmovehub.ts | 8 +-- consts.ts | 13 ++++- duplotrainbase.ts | 2 +- hub.ts | 43 ++++++++++++---- lpf2hub.ts | 24 ++++----- package.json | 2 +- port.ts | 4 +- puphub.ts | 2 +- pupremote.ts | 2 +- wedo2smarthub.ts | 10 ++-- 12 files changed, 316 insertions(+), 46 deletions(-) diff --git a/DOCS.md b/DOCS.md index f3f59f0..5c38cde 100644 --- a/DOCS.md +++ b/DOCS.md @@ -18,6 +18,8 @@ ## Typedefs
+
HubType
+
Device
Color
@@ -106,6 +108,8 @@ Emits when a Powered UP Hub device is found. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#WeDo2SmartHub+event_button) * ["distance" (port, distance)](#WeDo2SmartHub+event_distance) * ["color" (port, color)](#WeDo2SmartHub+event_color) @@ -325,6 +329,23 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### weDo2SmartHub.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) + + +### weDo2SmartHub.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -396,7 +417,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | [Device](#Device) | +| type | DeviceType | @@ -435,6 +456,8 @@ Emits when an attached motor or sensor is detached from the Hub. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -676,6 +699,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### boostMoveHub.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [getHubType](#Hub+getHubType) + + +### boostMoveHub.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -761,7 +803,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | [Device](#Device) | +| type | DeviceType | @@ -800,6 +842,8 @@ Emits when an attached motor or sensor is detached from the Hub. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -1026,6 +1070,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### pupHub.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [getHubType](#Hub+getHubType) + + +### pupHub.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -1099,7 +1162,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | [Device](#Device) | +| type | DeviceType | @@ -1135,6 +1198,8 @@ Emits when an attached motor or sensor is detached from the Hub. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#LPF2Hub+event_button) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) @@ -1315,6 +1380,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### pupRemote.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [getHubType](#Hub+getHubType) + + +### pupRemote.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -1365,6 +1449,8 @@ A combined color and distance event, emits when the sensor is activated. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["color" (port, color)](#LPF2Hub+event_color) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["speed" (port, speed)](#LPF2Hub+event_speed) @@ -1586,6 +1672,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### duploTrainBase.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [DuploTrainBase](#DuploTrainBase) +**Overrides**: [getHubType](#Hub+getHubType) + + +### duploTrainBase.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [DuploTrainBase](#DuploTrainBase) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "color" (port, color) @@ -1623,6 +1728,21 @@ Emits on a speed change. | port | string | | speed | number | + + +## HubType +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| UNKNOWN | number | 0 | +| WEDO2_SMART_HUB | number | 1 | +| BOOST_MOVE_HUB | number | 2 | +| POWERED_UP_HUB | number | 3 | +| POWERED_UP_REMOTE | number | 4 | +| DUPLO_TRAIN_HUB | number | 5 | + ## Device diff --git a/README.md b/README.md index d050856..a693fd5 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,8 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R ## Typedefs
+
HubType
+
Device
Color
@@ -189,6 +191,8 @@ Emits when a Powered UP Hub device is found. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#WeDo2SmartHub+event_button) * ["distance" (port, distance)](#WeDo2SmartHub+event_distance) * ["color" (port, color)](#WeDo2SmartHub+event_color) @@ -408,6 +412,23 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### weDo2SmartHub.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) + + +### weDo2SmartHub.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -479,7 +500,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | [Device](#Device) | +| type | DeviceType | @@ -518,6 +539,8 @@ Emits when an attached motor or sensor is detached from the Hub. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -759,6 +782,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### boostMoveHub.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [getHubType](#Hub+getHubType) + + +### boostMoveHub.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [BoostMoveHub](#BoostMoveHub) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -844,7 +886,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | [Device](#Device) | +| type | DeviceType | @@ -883,6 +925,8 @@ Emits when an attached motor or sensor is detached from the Hub. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -1109,6 +1153,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### pupHub.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [getHubType](#Hub+getHubType) + + +### pupHub.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [PUPHub](#PUPHub) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -1182,7 +1245,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | [Device](#Device) | +| type | DeviceType | @@ -1218,6 +1281,8 @@ Emits when an attached motor or sensor is detached from the Hub. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["button" (button, state)](#LPF2Hub+event_button) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) @@ -1398,6 +1463,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### pupRemote.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [getHubType](#Hub+getHubType) + + +### pupRemote.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [PUPRemote](#PUPRemote) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "button" (button, state) @@ -1448,6 +1532,8 @@ A combined color and distance event, emits when the sensor is activated. * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise + * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType * ["color" (port, color)](#LPF2Hub+event_color) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["speed" (port, speed)](#LPF2Hub+event_speed) @@ -1669,6 +1755,25 @@ This is a helper method to make it easier to wait for concurrent commands to com | --- | --- | --- | | commands | Array.<Promise.<any>> | Array of executing commands. | + + +### duploTrainBase.getHubType() ⇒ [HubType](#HubType) +Get the hub type. + +**Kind**: instance method of [DuploTrainBase](#DuploTrainBase) +**Overrides**: [getHubType](#Hub+getHubType) + + +### duploTrainBase.getPortDeviceType(port) ⇒ DeviceType +Get the device type for a given port. + +**Kind**: instance method of [DuploTrainBase](#DuploTrainBase) +**Overrides**: [getPortDeviceType](#Hub+getPortDeviceType) + +| Param | Type | +| --- | --- | +| port | string | + ### "color" (port, color) @@ -1706,6 +1811,21 @@ Emits on a speed change. | port | string | | speed | number | + + +## HubType +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| UNKNOWN | number | 0 | +| WEDO2_SMART_HUB | number | 1 | +| BOOST_MOVE_HUB | number | 2 | +| POWERED_UP_HUB | number | 3 | +| POWERED_UP_REMOTE | number | 4 | +| DUPLO_TRAIN_HUB | number | 5 | + ## Device diff --git a/boostmovehub.ts b/boostmovehub.ts index 8d0ad09..c013dd4 100644 --- a/boostmovehub.ts +++ b/boostmovehub.ts @@ -33,7 +33,7 @@ export class BoostMoveHub extends LPF2Hub { constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hub.BOOST_MOVE_HUB; + this.type = Consts.HubType.BOOST_MOVE_HUB; this._ports = { "A": new Port("A", 55), "B": new Port("B", 56), @@ -82,7 +82,7 @@ export class BoostMoveHub extends LPF2Hub { return new Promise((resolve, reject) => { if (time && typeof time === "number") { - if (portObj.type === Consts.Device.BOOST_TACHO_MOTOR || portObj.type === Consts.Device.BOOST_MOVE_HUB_MOTOR) { + if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR) { portObj.busy = true; let data = null; if (portObj.id === "AB") { @@ -111,7 +111,7 @@ export class BoostMoveHub extends LPF2Hub { } else { - if (portObj.type === Consts.Device.BOOST_TACHO_MOTOR || portObj.type === Consts.Device.BOOST_MOVE_HUB_MOTOR) { + if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR) { portObj.busy = true; let data = null; if (portObj.id === "AB") { @@ -167,7 +167,7 @@ export class BoostMoveHub extends LPF2Hub { */ public setMotorAngle (port: string, angle: number, speed: number | [number, number] = 100) { const portObj = this._portLookup(port); - if (!(portObj.type === Consts.Device.BOOST_TACHO_MOTOR || portObj.type === Consts.Device.BOOST_MOVE_HUB_MOTOR)) { + if (!(portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR)) { throw new Error("Angle rotation is only available when using a Boost Tacho Motor or Boost Move Hub Motor"); } if (portObj.id !== "AB" && speed instanceof Array) { diff --git a/consts.ts b/consts.ts index dc48c68..c57367b 100644 --- a/consts.ts +++ b/consts.ts @@ -1,4 +1,13 @@ -export enum Hub { +/** + * @typedef HubType + * @property {number} UNKNOWN 0 + * @property {number} WEDO2_SMART_HUB 1 + * @property {number} BOOST_MOVE_HUB 2 + * @property {number} POWERED_UP_HUB 3 + * @property {number} POWERED_UP_REMOTE 4 + * @property {number} DUPLO_TRAIN_HUB 5 + */ +export enum HubType { UNKNOWN = 0, WEDO2_SMART_HUB = 1, BOOST_MOVE_HUB = 2, @@ -27,7 +36,7 @@ export enum Hub { * @property {number} DUPLO_TRAIN_BASE_SPEEDOMETER 44 * @property {number} POWERED_UP_REMOTE_BUTTON 55 */ -export enum Device { +export enum DeviceType { UNKNOWN = 0, BASIC_MOTOR = 1, TRAIN_MOTOR = 2, diff --git a/duplotrainbase.ts b/duplotrainbase.ts index 8581b92..f8a6ab6 100644 --- a/duplotrainbase.ts +++ b/duplotrainbase.ts @@ -58,7 +58,7 @@ export class DuploTrainBase extends LPF2Hub { constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hub.DUPLO_TRAIN_HUB; + this.type = Consts.HubType.DUPLO_TRAIN_HUB; this._ports = { "MOTOR": new Port("MOTOR", 0), "COLOR": new Port("COLOR", 18), diff --git a/hub.ts b/hub.ts index 6763015..51beb19 100644 --- a/hub.ts +++ b/hub.ts @@ -19,7 +19,7 @@ export class Hub extends EventEmitter { public autoSubscribe: boolean = true; public useSpeedMap: boolean = true; - public type: Consts.Hub = Consts.Hub.UNKNOWN; + public type: Consts.HubType = Consts.HubType.UNKNOWN; protected _ports: {[port: string]: Port} = {}; protected _characteristics: {[uuid: string]: Characteristic} = {}; @@ -216,6 +216,27 @@ export class Hub extends EventEmitter { } + /** + * Get the hub type. + * @method Hub#getHubType + * @returns {HubType} + */ + public getHubType () { + return this.type; + } + + + /** + * Get the device type for a given port. + * @method Hub#getPortDeviceType + * @param {string} port + * @returns {DeviceType} + */ + public getPortDeviceType (port: string) { + return this._portLookup(port).type; + } + + protected _getCharacteristic (uuid: string) { return this._characteristics[uuid.replace(/-/g, "")]; } @@ -257,12 +278,12 @@ export class Hub extends EventEmitter { * Emits when a motor or sensor is attached to the Hub. * @event Hub#attach * @param {string} port - * @param {Device} type + * @param {DeviceType} type */ this.emit("attach", port.id, type); } } else { - port.type = Consts.Device.UNKNOWN; + port.type = Consts.DeviceType.UNKNOWN; debug(`Port ${port.id} disconnected`); /** * Emits when an attached motor or sensor is detached from the Hub. @@ -349,19 +370,19 @@ export class Hub extends EventEmitter { } - private _getModeForDeviceType (type: Consts.Device) { + private _getModeForDeviceType (type: Consts.DeviceType) { switch (type) { - case Consts.Device.BASIC_MOTOR: + case Consts.DeviceType.BASIC_MOTOR: return 0x02; - case Consts.Device.TRAIN_MOTOR: + case Consts.DeviceType.TRAIN_MOTOR: return 0x02; - case Consts.Device.BOOST_TACHO_MOTOR: + case Consts.DeviceType.BOOST_TACHO_MOTOR: return 0x02; - case Consts.Device.BOOST_MOVE_HUB_MOTOR: + case Consts.DeviceType.BOOST_MOVE_HUB_MOTOR: return 0x02; - case Consts.Device.BOOST_DISTANCE: - return (this.type === Consts.Hub.WEDO2_SMART_HUB ? 0x00 : 0x08); - case Consts.Device.BOOST_TILT: + case Consts.DeviceType.BOOST_DISTANCE: + return (this.type === Consts.HubType.WEDO2_SMART_HUB ? 0x00 : 0x08); + case Consts.DeviceType.BOOST_TILT: return 0x04; default: return 0x00; diff --git a/lpf2hub.ts b/lpf2hub.ts index 1d19681..9cf1ed1 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -42,7 +42,7 @@ export class LPF2Hub extends Hub { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x02, 0x02])); // Activate button reports this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate current reports this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate voltage reports - if (this.type === Consts.Hub.DUPLO_TRAIN_HUB) { + if (this.type === Consts.HubType.DUPLO_TRAIN_HUB) { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01])); } return resolve(); @@ -242,12 +242,12 @@ export class LPF2Hub extends Hub { private _parseSensorMessage (data: Buffer) { - if ((data[3] === 0x3b && this.type === Consts.Hub.POWERED_UP_REMOTE) || (data[3] === 0x3c && this.type !== Consts.Hub.POWERED_UP_REMOTE)) { // Voltage + if ((data[3] === 0x3b && this.type === Consts.HubType.POWERED_UP_REMOTE) || (data[3] === 0x3c && this.type !== Consts.HubType.POWERED_UP_REMOTE)) { // Voltage data = this._padMessage(data, 6); const batteryLevel = (data.readUInt16LE(4) / 4096) * 100; this._batteryLevel = Math.floor(batteryLevel); return; - } else if (data[3] === 0x3b && this.type !== Consts.Hub.POWERED_UP_REMOTE) { // Current (Non-PUP Remote) + } else if (data[3] === 0x3b && this.type !== Consts.HubType.POWERED_UP_REMOTE) { // Current (Non-PUP Remote) data = this._padMessage(data, 6); const current = data.readUInt16LE(4) / 4096; this._current = current * 100; @@ -267,7 +267,7 @@ export class LPF2Hub extends Hub { if (port && port.connected) { switch (port.type) { - case Consts.Device.WEDO2_DISTANCE: + case Consts.DeviceType.WEDO2_DISTANCE: { let distance = data[4]; if (data[5] === 1) { @@ -282,7 +282,7 @@ export class LPF2Hub extends Hub { this.emit("distance", port.id, distance * 10); break; } - case Consts.Device.BOOST_DISTANCE: + case Consts.DeviceType.BOOST_DISTANCE: { /** @@ -318,7 +318,7 @@ export class LPF2Hub extends Hub { } break; } - case Consts.Device.WEDO2_TILT: + case Consts.DeviceType.WEDO2_TILT: { const tiltX = data[4] > 160 ? data[4] - 255 : data[4] - (data[4] * 2); const tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2); @@ -334,7 +334,7 @@ export class LPF2Hub extends Hub { this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY); break; } - case Consts.Device.BOOST_TACHO_MOTOR: + case Consts.DeviceType.BOOST_TACHO_MOTOR: { const rotation = data.readInt32LE(4); /** @@ -346,20 +346,20 @@ export class LPF2Hub extends Hub { this.emit("rotate", port.id, rotation); break; } - case Consts.Device.BOOST_MOVE_HUB_MOTOR: + case Consts.DeviceType.BOOST_MOVE_HUB_MOTOR: { const rotation = data.readInt32LE(4); this.emit("rotate", port.id, rotation); break; } - case Consts.Device.BOOST_TILT: + case Consts.DeviceType.BOOST_TILT: { const tiltX = data[4] > 160 ? data[4] - 255 : data[4]; const tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2); this.emit("tilt", port.id, tiltX, tiltY); break; } - case Consts.Device.POWERED_UP_REMOTE_BUTTON: + case Consts.DeviceType.POWERED_UP_REMOTE_BUTTON: { switch (data[4]) { case 0x01: @@ -385,14 +385,14 @@ export class LPF2Hub extends Hub { } break; } - case Consts.Device.DUPLO_TRAIN_BASE_COLOR: + case Consts.DeviceType.DUPLO_TRAIN_BASE_COLOR: { if (data[4] <= 10) { this.emit("color", port.id, data[4]); } break; } - case Consts.Device.DUPLO_TRAIN_BASE_SPEEDOMETER: + case Consts.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER: { /** * Emits on a speed change. diff --git a/package.json b/package.json index 5e16a40..4a85221 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.3.0", + "version": "1.4.0", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", diff --git a/port.ts b/port.ts index 20d1274..0a279cb 100644 --- a/port.ts +++ b/port.ts @@ -6,7 +6,7 @@ export class Port { public id: string; public value: number; - public type: Consts.Device; + public type: Consts.DeviceType; public connected: boolean = false; public busy: boolean = false; public finished: (() => void) | null = null; @@ -16,7 +16,7 @@ export class Port { constructor (id: string, value: number) { this.id = id; this.value = value; - this.type = Consts.Device.UNKNOWN; + this.type = Consts.DeviceType.UNKNOWN; } public cancelEventTimer () { diff --git a/puphub.ts b/puphub.ts index 360b770..e0885ee 100644 --- a/puphub.ts +++ b/puphub.ts @@ -38,7 +38,7 @@ export class PUPHub extends LPF2Hub { constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hub.POWERED_UP_HUB; + this.type = Consts.HubType.POWERED_UP_HUB; this._ports = { "A": new Port("A", 0), "B": new Port("B", 1), diff --git a/pupremote.ts b/pupremote.ts index 4659648..b5adf1b 100644 --- a/pupremote.ts +++ b/pupremote.ts @@ -63,7 +63,7 @@ export class PUPRemote extends LPF2Hub { constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hub.POWERED_UP_REMOTE; + this.type = Consts.HubType.POWERED_UP_REMOTE; this._ports = { "LEFT": new Port("LEFT", 0), "RIGHT": new Port("RIGHT", 1) diff --git a/wedo2smarthub.ts b/wedo2smarthub.ts index da4c262..22d1b68 100644 --- a/wedo2smarthub.ts +++ b/wedo2smarthub.ts @@ -36,7 +36,7 @@ export class WeDo2SmartHub extends Hub { constructor (peripheral: Peripheral, autoSubscribe: boolean = true) { super(peripheral, autoSubscribe); - this.type = Consts.Hub.WEDO2_SMART_HUB; + this.type = Consts.HubType.WEDO2_SMART_HUB; this._ports = { "A": new Port("A", 1), "B": new Port("B", 2) @@ -293,7 +293,7 @@ export class WeDo2SmartHub extends Hub { if (port && port.connected) { switch (port.type) { - case Consts.Device.WEDO2_DISTANCE: + case Consts.DeviceType.WEDO2_DISTANCE: { let distance = data[2]; if (data[3] === 1) { @@ -308,7 +308,7 @@ export class WeDo2SmartHub extends Hub { this.emit("distance", port.id, distance * 10); break; } - case Consts.Device.BOOST_DISTANCE: + case Consts.DeviceType.BOOST_DISTANCE: { const distance = data[2]; /** @@ -320,7 +320,7 @@ export class WeDo2SmartHub extends Hub { this.emit("color", port.id, distance); break; } - case Consts.Device.WEDO2_TILT: + case Consts.DeviceType.WEDO2_TILT: { this._lastTiltX = data[2]; if (this._lastTiltX > 100) { @@ -340,7 +340,7 @@ export class WeDo2SmartHub extends Hub { this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY); break; } - case Consts.Device.BOOST_TACHO_MOTOR: + case Consts.DeviceType.BOOST_TACHO_MOTOR: { const rotation = data.readInt32LE(2); /** From d165fa18177242d2a252f7f06da1b73d6452e021 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 31 Dec 2018 13:28:56 -0800 Subject: [PATCH 29/33] Fixed DeviceType --- DOCS.md | 32 ++++++++++++++++---------------- README.md | 32 ++++++++++++++++---------------- consts.ts | 2 +- package.json | 2 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/DOCS.md b/DOCS.md index 5c38cde..ee1b98c 100644 --- a/DOCS.md +++ b/DOCS.md @@ -20,7 +20,7 @@
HubType
-
Device
+
DeviceType
Color
@@ -109,7 +109,7 @@ Emits when a Powered UP Hub device is found. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#WeDo2SmartHub+event_button) * ["distance" (port, distance)](#WeDo2SmartHub+event_distance) * ["color" (port, color)](#WeDo2SmartHub+event_color) @@ -337,7 +337,7 @@ Get the hub type. **Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) -### weDo2SmartHub.getPortDeviceType(port) ⇒ DeviceType +### weDo2SmartHub.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) @@ -417,7 +417,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | DeviceType | +| type | [DeviceType](#DeviceType) | @@ -457,7 +457,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -708,7 +708,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### boostMoveHub.getPortDeviceType(port) ⇒ DeviceType +### boostMoveHub.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) @@ -803,7 +803,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | DeviceType | +| type | [DeviceType](#DeviceType) | @@ -843,7 +843,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -1079,7 +1079,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### pupHub.getPortDeviceType(port) ⇒ DeviceType +### pupHub.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [PUPHub](#PUPHub) @@ -1162,7 +1162,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | DeviceType | +| type | [DeviceType](#DeviceType) | @@ -1199,7 +1199,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#LPF2Hub+event_button) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) @@ -1389,7 +1389,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### pupRemote.getPortDeviceType(port) ⇒ DeviceType +### pupRemote.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [PUPRemote](#PUPRemote) @@ -1450,7 +1450,7 @@ A combined color and distance event, emits when the sensor is activated. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["color" (port, color)](#LPF2Hub+event_color) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["speed" (port, speed)](#LPF2Hub+event_speed) @@ -1681,7 +1681,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### duploTrainBase.getPortDeviceType(port) ⇒ DeviceType +### duploTrainBase.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [DuploTrainBase](#DuploTrainBase) @@ -1743,9 +1743,9 @@ Emits on a speed change. | POWERED_UP_REMOTE | number | 4 | | DUPLO_TRAIN_HUB | number | 5 | - + -## Device +## DeviceType **Kind**: global typedef **Properties** diff --git a/README.md b/README.md index a693fd5..0db6bdc 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R
HubType
-
Device
+
DeviceType
Color
@@ -192,7 +192,7 @@ Emits when a Powered UP Hub device is found. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#WeDo2SmartHub+event_button) * ["distance" (port, distance)](#WeDo2SmartHub+event_distance) * ["color" (port, color)](#WeDo2SmartHub+event_color) @@ -420,7 +420,7 @@ Get the hub type. **Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) -### weDo2SmartHub.getPortDeviceType(port) ⇒ DeviceType +### weDo2SmartHub.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub) @@ -500,7 +500,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | DeviceType | +| type | [DeviceType](#DeviceType) | @@ -540,7 +540,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -791,7 +791,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### boostMoveHub.getPortDeviceType(port) ⇒ DeviceType +### boostMoveHub.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [BoostMoveHub](#BoostMoveHub) @@ -886,7 +886,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | DeviceType | +| type | [DeviceType](#DeviceType) | @@ -926,7 +926,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#LPF2Hub+event_button) * ["distance" (port, distance)](#LPF2Hub+event_distance) * ["color" (port, color)](#LPF2Hub+event_color) @@ -1162,7 +1162,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### pupHub.getPortDeviceType(port) ⇒ DeviceType +### pupHub.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [PUPHub](#PUPHub) @@ -1245,7 +1245,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | | --- | --- | | port | string | -| type | DeviceType | +| type | [DeviceType](#DeviceType) | @@ -1282,7 +1282,7 @@ Emits when an attached motor or sensor is detached from the Hub. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["button" (button, state)](#LPF2Hub+event_button) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) @@ -1472,7 +1472,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### pupRemote.getPortDeviceType(port) ⇒ DeviceType +### pupRemote.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [PUPRemote](#PUPRemote) @@ -1533,7 +1533,7 @@ A combined color and distance event, emits when the sensor is activated. * [.sleep(delay)](#Hub+sleep) ⇒ Promise * [.wait(commands)](#Hub+wait) ⇒ Promise * [.getHubType()](#Hub+getHubType) ⇒ [HubType](#HubType) - * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ DeviceType + * [.getPortDeviceType(port)](#Hub+getPortDeviceType) ⇒ [DeviceType](#DeviceType) * ["color" (port, color)](#LPF2Hub+event_color) * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance) * ["speed" (port, speed)](#LPF2Hub+event_speed) @@ -1764,7 +1764,7 @@ Get the hub type. **Overrides**: [getHubType](#Hub+getHubType) -### duploTrainBase.getPortDeviceType(port) ⇒ DeviceType +### duploTrainBase.getPortDeviceType(port) ⇒ [DeviceType](#DeviceType) Get the device type for a given port. **Kind**: instance method of [DuploTrainBase](#DuploTrainBase) @@ -1826,9 +1826,9 @@ Emits on a speed change. | POWERED_UP_REMOTE | number | 4 | | DUPLO_TRAIN_HUB | number | 5 | - + -## Device +## DeviceType **Kind**: global typedef **Properties** diff --git a/consts.ts b/consts.ts index c57367b..4798705 100644 --- a/consts.ts +++ b/consts.ts @@ -18,7 +18,7 @@ export enum HubType { /** - * @typedef Device + * @typedef DeviceType * @property {number} UNKNOWN 0 * @property {number} BASIC_MOTOR 1 * @property {number} TRAIN_MOTOR 2 diff --git a/package.json b/package.json index 4a85221..6edaafe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.4.0", + "version": "1.4.1", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From ff7dcb3b06fc4369722d7c136afc1d4d7a82e517 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 31 Dec 2018 13:50:03 -0800 Subject: [PATCH 30/33] Added new product codes to compatibility table --- ABOUT.md | 18 +++++++++--------- README.md | 18 +++++++++--------- package.json | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index 4362f64..a3247ed 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -32,15 +32,15 @@ Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the R 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 | -| ------------------------------- | ------------- | ------------------ | -------------- | -------------- | ------------ | -| WeDo 2.0 Tilt Sensor | Sensor | Yes | Yes | Yes | 45300 | -| 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 Tacho Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | -| Powered UP Train Motor | Motor | Yes | Yes | Yes | 60197
60198 | -| Powered UP LED Lights | Light | Yes | Yes | Yes | 88005 | +| Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability | +| ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ | +| WeDo 2.0 Tilt Sensor | 45305 | Sensor | Yes | Yes | Yes | 45300 | +| WeDo 2.0 Motion Sensor | 45304 | Sensor | Yes | Yes | Yes | 45300 | +| WeDo 2.0 Medium Motor | 45303 | Motor | Yes | Yes | Yes | 45300
76112 | +| Boost Color and Distance Sensor | 88007 | Sensor | *Partial* | Yes | Yes | 17101 | +| Boost Tacho Motor | 88008 | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | +| Powered UP Train Motor | 88011 | Motor | Yes | Yes | Yes | 60197
60198 | +| Powered UP LED Lights | 88005 | Light | Yes | Yes | Yes | 88005 | ### Known Issues and Limitations diff --git a/README.md b/README.md index 0db6bdc..b0b5dcb 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,15 @@ Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the R 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 | -| ------------------------------- | ------------- | ------------------ | -------------- | -------------- | ------------ | -| WeDo 2.0 Tilt Sensor | Sensor | Yes | Yes | Yes | 45300 | -| 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 Tacho Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | -| Powered UP Train Motor | Motor | Yes | Yes | Yes | 60197
60198 | -| Powered UP LED Lights | Light | Yes | Yes | Yes | 88005 | +| Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability | +| ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ | +| WeDo 2.0 Tilt Sensor | 45305 | Sensor | Yes | Yes | Yes | 45300 | +| WeDo 2.0 Motion Sensor | 45304 | Sensor | Yes | Yes | Yes | 45300 | +| WeDo 2.0 Medium Motor | 45303 | Motor | Yes | Yes | Yes | 45300
76112 | +| Boost Color and Distance Sensor | 88007 | Sensor | *Partial* | Yes | Yes | 17101 | +| Boost Tacho Motor | 88008 | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 | +| Powered UP Train Motor | 88011 | Motor | Yes | Yes | Yes | 60197
60198 | +| Powered UP LED Lights | 88005 | Light | Yes | Yes | Yes | 88005 | ### Known Issues and Limitations diff --git a/package.json b/package.json index 6edaafe..9e89a8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.4.1", + "version": "1.4.2", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From 384816b508bca0724bb117fb211a2028f6f39cdd Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 31 Dec 2018 14:33:39 -0800 Subject: [PATCH 31/33] Added hub compatibility table --- ABOUT.md | 12 +++++++++++- README.md | 12 +++++++++++- package.json | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index a3247ed..ee8ef59 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -32,7 +32,7 @@ Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the R 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 | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability | +| Device Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability | | ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ | | WeDo 2.0 Tilt Sensor | 45305 | Sensor | Yes | Yes | Yes | 45300 | | WeDo 2.0 Motion Sensor | 45304 | Sensor | Yes | Yes | Yes | 45300 | @@ -42,6 +42,16 @@ While most Powered UP components and Hubs are compatible with each other, there | Powered UP Train Motor | 88011 | Motor | Yes | Yes | Yes | 60197
60198 | | Powered UP LED Lights | 88005 | Light | Yes | Yes | Yes | 88005 | +In addition, the Hubs themselves have certain built-in features which this library exposes. + +| Hub Name | Product Code | Built-In Features | Availability | +| ------------------ | ------------ | ---------------------- | ------------ | +| WeDo 2.0 Smart hub | 45301 | RGB LED
Piezo Buzzer
Button | 45300 | +| Boost Move Hub | 88006 | RGB LED
Tilt Sensor
2x Tacho Motors
Button | 17101 | +| Powered UP Hub | 88009 | RGB LED
Button | 60197
60198
76112 | +| Powered UP Remote | 28739 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | +| Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Button | 10874
10875 | + ### Known Issues and Limitations diff --git a/README.md b/README.md index b0b5dcb..0b32632 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the R 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 | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability | +| Device Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability | | ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ | | WeDo 2.0 Tilt Sensor | 45305 | Sensor | Yes | Yes | Yes | 45300 | | WeDo 2.0 Motion Sensor | 45304 | Sensor | Yes | Yes | Yes | 45300 | @@ -42,6 +42,16 @@ While most Powered UP components and Hubs are compatible with each other, there | Powered UP Train Motor | 88011 | Motor | Yes | Yes | Yes | 60197
60198 | | Powered UP LED Lights | 88005 | Light | Yes | Yes | Yes | 88005 | +In addition, the Hubs themselves have certain built-in features which this library exposes. + +| Hub Name | Product Code | Built-In Features | Availability | +| ------------------ | ------------ | ---------------------- | ------------ | +| WeDo 2.0 Smart hub | 45301 | RGB LED
Piezo Buzzer
Button | 45300 | +| Boost Move Hub | 88006 | RGB LED
Tilt Sensor
2x Tacho Motors
Button | 17101 | +| Powered UP Hub | 88009 | RGB LED
Button | 60197
60198
76112 | +| Powered UP Remote | 28739 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | +| Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Button | 10874
10875 | + ### Known Issues and Limitations diff --git a/package.json b/package.json index 9e89a8b..471f879 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.4.2", + "version": "1.4.3", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From 60bfc460262d1cc93c09a3758bc12d3f486e70c4 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 31 Dec 2018 14:35:17 -0800 Subject: [PATCH 32/33] Added hub compatibility table --- ABOUT.md | 2 +- README.md | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index ee8ef59..48c469b 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -50,7 +50,7 @@ In addition, the Hubs themselves have certain built-in features which this libra | Boost Move Hub | 88006 | RGB LED
Tilt Sensor
2x Tacho Motors
Button | 17101 | | Powered UP Hub | 88009 | RGB LED
Button | 60197
60198
76112 | | Powered UP Remote | 28739 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | -| Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Button | 10874
10875 | +| Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Color and Distance Sensor
Button | 10874
10875 | ### Known Issues and Limitations diff --git a/README.md b/README.md index 0b32632..e5c76d5 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ In addition, the Hubs themselves have certain built-in features which this libra | Boost Move Hub | 88006 | RGB LED
Tilt Sensor
2x Tacho Motors
Button | 17101 | | Powered UP Hub | 88009 | RGB LED
Button | 60197
60198
76112 | | Powered UP Remote | 28739 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | -| Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Button | 10874
10875 | +| Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Color and Distance Sensor
Button | 10874
10875 | ### Known Issues and Limitations diff --git a/package.json b/package.json index 471f879..f3ee788 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.4.3", + "version": "1.4.4", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js", From 1df9d6b82d88a1e40058886e2a4b47c947074bfa Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 31 Dec 2018 14:51:07 -0800 Subject: [PATCH 33/33] Added hub compatibility table --- ABOUT.md | 2 +- README.md | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ABOUT.md b/ABOUT.md index 48c469b..cc45000 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -49,7 +49,7 @@ In addition, the Hubs themselves have certain built-in features which this libra | WeDo 2.0 Smart hub | 45301 | RGB LED
Piezo Buzzer
Button | 45300 | | Boost Move Hub | 88006 | RGB LED
Tilt Sensor
2x Tacho Motors
Button | 17101 | | Powered UP Hub | 88009 | RGB LED
Button | 60197
60198
76112 | -| Powered UP Remote | 28739 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | +| Powered UP Remote | 88010 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | | Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Color and Distance Sensor
Button | 10874
10875 | diff --git a/README.md b/README.md index e5c76d5..2dadfb8 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ In addition, the Hubs themselves have certain built-in features which this libra | WeDo 2.0 Smart hub | 45301 | RGB LED
Piezo Buzzer
Button | 45300 | | Boost Move Hub | 88006 | RGB LED
Tilt Sensor
2x Tacho Motors
Button | 17101 | | Powered UP Hub | 88009 | RGB LED
Button | 60197
60198
76112 | -| Powered UP Remote | 28739 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | +| Powered UP Remote | 88010 | RGB LED
Left and Right Control Buttons
Button | 60197
60198 | | Duplo Train Base | 28743 | RGB LED/Headlights
Speaker
Speedometer
Motor
Color and Distance Sensor
Button | 10874
10875 | diff --git a/package.json b/package.json index f3ee788..9c09741 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "1.4.4", + "version": "1.4.5", "description": "A Node.js module to interface with LEGO Powered UP components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/index.js",