From adaac287cc3822ad7f9df54fda8f0864b0c38965 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Fri, 18 Jan 2019 17:35:48 -0800 Subject: [PATCH] Initial pass at wedo2 voltage and current --- docs/BoostMoveHub.html | 70 +++++---- docs/DuploTrainBase.html | 56 ++++--- docs/Hub.html | 268 +++++++++++++++++++++++++++++-- docs/LPF2Hub.html | 76 +++++---- docs/PUPHub.html | 68 ++++---- docs/PUPRemote.html | 54 ++++--- docs/WeDo2SmartHub.html | 312 +++++++++++++++++++++++++++++++++---- docs/classes.list.html | 74 ++++----- docs/hub.js.html | 16 ++ docs/lpf2hub.js.html | 18 +-- docs/quicksearch.html | 2 +- docs/wedo2smarthub.js.html | 16 ++ src/hub.ts | 20 +++ src/lpf2hub.ts | 23 +-- src/wedo2smarthub.ts | 17 +- 15 files changed, 836 insertions(+), 254 deletions(-) diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index 096e302..6d097d1 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -327,7 +327,7 @@ @@ -423,12 +423,17 @@
+ +
Overrides:
+
@@ -454,8 +459,8 @@
@@ -588,7 +593,7 @@ @@ -721,7 +726,7 @@ @@ -854,7 +859,7 @@ @@ -987,7 +992,7 @@ @@ -1083,12 +1088,17 @@
+ +
Overrides:
+
@@ -1114,8 +1124,8 @@
@@ -1211,7 +1221,7 @@ @@ -1337,7 +1347,7 @@ @@ -1463,7 +1473,7 @@ @@ -1635,7 +1645,7 @@ @@ -2198,7 +2208,7 @@ @@ -2417,7 +2427,7 @@ @@ -3324,7 +3334,7 @@ @@ -3501,7 +3511,7 @@ @@ -3721,7 +3731,7 @@ @@ -3897,7 +3907,7 @@ @@ -4074,7 +4084,7 @@ @@ -4282,7 +4292,7 @@ @@ -4453,7 +4463,7 @@ @@ -4624,7 +4634,7 @@ @@ -4819,7 +4829,7 @@ @@ -4971,7 +4981,7 @@ @@ -5142,7 +5152,7 @@ @@ -5313,7 +5323,7 @@ @@ -5508,7 +5518,7 @@ diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 48dde12..c3fae59 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -327,7 +327,7 @@ @@ -423,12 +423,17 @@
+ +
Overrides:
+
@@ -454,8 +459,8 @@
@@ -588,7 +593,7 @@ @@ -721,7 +726,7 @@ @@ -854,7 +859,7 @@ @@ -987,7 +992,7 @@ @@ -1083,12 +1088,17 @@
+ +
Overrides:
+
@@ -1114,8 +1124,8 @@
@@ -1211,7 +1221,7 @@ @@ -1337,7 +1347,7 @@ @@ -1463,7 +1473,7 @@ @@ -1635,7 +1645,7 @@ @@ -2575,7 +2585,7 @@ @@ -2987,7 +2997,7 @@ @@ -3164,7 +3174,7 @@ @@ -3384,7 +3394,7 @@ @@ -3560,7 +3570,7 @@ @@ -3737,7 +3747,7 @@ @@ -3940,7 +3950,7 @@ @@ -4111,7 +4121,7 @@ diff --git a/docs/Hub.html b/docs/Hub.html index 5460ad3..803f806 100644 --- a/docs/Hub.html +++ b/docs/Hub.html @@ -307,7 +307,126 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> current

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
current + + +number + + + + +

Current usage of the hub (Amps)

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -426,7 +545,7 @@
@@ -545,7 +664,7 @@ @@ -664,7 +783,7 @@ @@ -783,7 +902,126 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> voltage

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
voltage + + +number + + + + +

Voltage of the hub (Volts)

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -865,7 +1103,7 @@
@@ -977,7 +1215,7 @@ @@ -1089,7 +1327,7 @@ @@ -1247,7 +1485,7 @@ @@ -1406,7 +1644,7 @@ @@ -1612,7 +1850,7 @@ @@ -1774,7 +2012,7 @@ @@ -1937,7 +2175,7 @@ @@ -2131,7 +2369,7 @@ @@ -2269,7 +2507,7 @@ diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index 66924a4..2a74e62 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -316,7 +316,7 @@ @@ -408,6 +408,15 @@ +
Inherited From:
+
+ +
+ @@ -434,8 +443,8 @@
@@ -563,7 +572,7 @@ @@ -691,7 +700,7 @@ @@ -819,7 +828,7 @@ @@ -947,7 +956,7 @@ @@ -1039,6 +1048,15 @@ +
Inherited From:
+
+ +
+ @@ -1065,8 +1083,8 @@
@@ -1162,7 +1180,7 @@ @@ -1283,7 +1301,7 @@ @@ -1404,7 +1422,7 @@ @@ -1571,7 +1589,7 @@ @@ -1729,7 +1747,7 @@ @@ -1939,7 +1957,7 @@ @@ -2101,7 +2119,7 @@ @@ -2273,7 +2291,7 @@ @@ -2488,7 +2506,7 @@ @@ -2659,7 +2677,7 @@ @@ -2831,7 +2849,7 @@ @@ -3034,7 +3052,7 @@ @@ -3196,7 +3214,7 @@ @@ -3358,7 +3376,7 @@ @@ -3544,7 +3562,7 @@ @@ -3691,7 +3709,7 @@ @@ -3853,7 +3871,7 @@ @@ -4015,7 +4033,7 @@ @@ -4177,7 +4195,7 @@ @@ -4363,7 +4381,7 @@ diff --git a/docs/PUPHub.html b/docs/PUPHub.html index 0b18841..d768611 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -327,7 +327,7 @@ @@ -423,12 +423,17 @@
+ +
Overrides:
+
@@ -454,8 +459,8 @@
@@ -588,7 +593,7 @@ @@ -721,7 +726,7 @@ @@ -854,7 +859,7 @@ @@ -987,7 +992,7 @@ @@ -1083,12 +1088,17 @@
+ +
Overrides:
+
@@ -1114,8 +1124,8 @@
@@ -1211,7 +1221,7 @@ @@ -1337,7 +1347,7 @@ @@ -1463,7 +1473,7 @@ @@ -1635,7 +1645,7 @@ @@ -2198,7 +2208,7 @@ @@ -2417,7 +2427,7 @@ @@ -3067,7 +3077,7 @@ @@ -3244,7 +3254,7 @@ @@ -3464,7 +3474,7 @@ @@ -3640,7 +3650,7 @@ @@ -3817,7 +3827,7 @@ @@ -4025,7 +4035,7 @@ @@ -4196,7 +4206,7 @@ @@ -4367,7 +4377,7 @@ @@ -4562,7 +4572,7 @@ @@ -4714,7 +4724,7 @@ @@ -4885,7 +4895,7 @@ @@ -5080,7 +5090,7 @@ diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index 5f89d4b..5587767 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -327,7 +327,7 @@ @@ -423,12 +423,17 @@
+ +
Overrides:
+
@@ -454,8 +459,8 @@
@@ -588,7 +593,7 @@ @@ -721,7 +726,7 @@ @@ -854,7 +859,7 @@ @@ -987,7 +992,7 @@ @@ -1083,12 +1088,17 @@
+ +
Overrides:
+
@@ -1114,8 +1124,8 @@
@@ -1211,7 +1221,7 @@ @@ -1337,7 +1347,7 @@ @@ -1463,7 +1473,7 @@ @@ -1635,7 +1645,7 @@ @@ -2184,7 +2194,7 @@ @@ -2361,7 +2371,7 @@ @@ -2581,7 +2591,7 @@ @@ -2757,7 +2767,7 @@ @@ -2934,7 +2944,7 @@ @@ -3137,7 +3147,7 @@ @@ -3332,7 +3342,7 @@ diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html index 7eb603d..bc88bed 100644 --- a/docs/WeDo2SmartHub.html +++ b/docs/WeDo2SmartHub.html @@ -320,7 +320,135 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> current

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
current + + +number + + + + +

Current usage of the hub (Amps)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -448,7 +576,7 @@
@@ -576,7 +704,7 @@ @@ -704,7 +832,7 @@ @@ -832,7 +960,135 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> voltage

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
voltage + + +number + + + + +

Voltage of the hub (Volts)

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -928,7 +1184,7 @@
@@ -1049,7 +1305,7 @@ @@ -1170,7 +1426,7 @@ @@ -1337,7 +1593,7 @@ @@ -1495,7 +1751,7 @@ @@ -1681,7 +1937,7 @@ @@ -1915,7 +2171,7 @@ @@ -2077,7 +2333,7 @@ @@ -2287,7 +2543,7 @@ @@ -2525,7 +2781,7 @@ @@ -2763,7 +3019,7 @@ @@ -2925,7 +3181,7 @@ @@ -3097,7 +3353,7 @@ @@ -3312,7 +3568,7 @@ @@ -3483,7 +3739,7 @@ @@ -3655,7 +3911,7 @@ @@ -3858,7 +4114,7 @@ @@ -4020,7 +4276,7 @@ @@ -4182,7 +4438,7 @@ @@ -4329,7 +4585,7 @@ @@ -4491,7 +4747,7 @@ @@ -4653,7 +4909,7 @@ @@ -4839,7 +5095,7 @@ diff --git a/docs/classes.list.html b/docs/classes.list.html index 93f682a..7f6f44b 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -335,7 +335,7 @@ @@ -506,7 +506,7 @@ @@ -677,7 +677,7 @@ @@ -872,7 +872,7 @@ @@ -1024,7 +1024,7 @@ @@ -1195,7 +1195,7 @@ @@ -1366,7 +1366,7 @@ @@ -1561,7 +1561,7 @@ @@ -1732,7 +1732,7 @@ @@ -1903,7 +1903,7 @@ @@ -2065,7 +2065,7 @@ @@ -2203,7 +2203,7 @@ @@ -2374,7 +2374,7 @@ @@ -2536,7 +2536,7 @@ @@ -2698,7 +2698,7 @@ @@ -2884,7 +2884,7 @@ @@ -3031,7 +3031,7 @@ @@ -3193,7 +3193,7 @@ @@ -3355,7 +3355,7 @@ @@ -3517,7 +3517,7 @@ @@ -3703,7 +3703,7 @@ @@ -4029,7 +4029,7 @@ @@ -4200,7 +4200,7 @@ @@ -4371,7 +4371,7 @@ @@ -4566,7 +4566,7 @@ @@ -4718,7 +4718,7 @@ @@ -4889,7 +4889,7 @@ @@ -5084,7 +5084,7 @@ @@ -5255,7 +5255,7 @@ @@ -5450,7 +5450,7 @@ @@ -5621,7 +5621,7 @@ @@ -5783,7 +5783,7 @@ @@ -5945,7 +5945,7 @@ @@ -6092,7 +6092,7 @@ @@ -6254,7 +6254,7 @@ @@ -6416,7 +6416,7 @@ @@ -6602,7 +6602,7 @@ diff --git a/docs/hub.js.html b/docs/hub.js.html index 1196d17..615afbc 100644 --- a/docs/hub.js.html +++ b/docs/hub.js.html @@ -111,6 +111,8 @@ class Hub extends events_1.EventEmitter { this._characteristics = {}; this._firmwareInfo = { major: 0, minor: 0, bugFix: 0, build: 0 }; this._batteryLevel = 100; + this._voltage = 0; + this._current = 0; this._rssi = -100; this.autoSubscribe = !!autoSubscribe; this._peripheral = peripheral; @@ -152,6 +154,20 @@ class Hub extends events_1.EventEmitter { get batteryLevel() { return this._batteryLevel; } + /** + * @readonly + * @property {number} voltage Voltage of the hub (Volts) + */ + get voltage() { + return this._voltage; + } + /** + * @readonly + * @property {number} current Current usage of the hub (Amps) + */ + get current() { + return this._current; + } /** * Connect to the Hub. * @method Hub#connect diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index b441b2b..591a293 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -104,26 +104,10 @@ const debug = Debug("lpf2hub"); class LPF2Hub extends hub_1.Hub { constructor() { super(...arguments); - this._voltage = 0; - this._current = 0; this._lastTiltX = 0; this._lastTiltY = 0; this._messageBuffer = Buffer.alloc(0); } - /** - * @readonly - * @property {number} voltage Voltage of the hub (Volts) - */ - get voltage() { - return this._voltage; - } - /** - * @readonly - * @property {number} current Current usage of the hub (Amps) - */ - get current() { - return this._current; - } connect() { return new Promise(async (resolve, reject) => { await super.connect(); @@ -133,8 +117,8 @@ class LPF2Hub extends hub_1.Hub { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x02, 0x02])); // Activate button reports this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x03, 0x05])); // Request firmware version this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x06, 0x02])); // Activate battery level 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 + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate current reports if (this.type === Consts.HubType.DUPLO_TRAIN_HUB) { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01])); } diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 7cbf738..d08b1c2 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@