From e959230a22e1ebb5a32f226242fcd904575527b3 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 25 Apr 2019 21:48:10 -0700 Subject: [PATCH] Correct voltage and current readings --- docs/BoostMoveHub.html | 12 ++++++------ docs/DuploTrainBase.html | 6 +++--- docs/Hub.html | 2 +- docs/LPF2Hub.html | 14 +++++++------- docs/PUPHub.html | 10 +++++----- docs/PUPRemote.html | 4 ++-- docs/WeDo2SmartHub.html | 2 +- docs/classes.list.html | 36 ++++++++++++++++++------------------ docs/hub.js.html | 2 +- docs/lpf2hub.js.html | 35 +++++++++++++++++++---------------- docs/quicksearch.html | 2 +- src/hub.ts | 2 +- src/lpf2hub.ts | 30 ++++++++++++++++-------------- 13 files changed, 81 insertions(+), 76 deletions(-) diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index 31b4772..c121cd1 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -404,7 +404,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

@@ -4755,7 +4755,7 @@ @@ -4950,7 +4950,7 @@ @@ -5273,7 +5273,7 @@ @@ -5444,7 +5444,7 @@ @@ -5639,7 +5639,7 @@ diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 7bba2aa..ea74ee1 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -404,7 +404,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

@@ -4071,7 +4071,7 @@ @@ -4242,7 +4242,7 @@ diff --git a/docs/Hub.html b/docs/Hub.html index c2f750b..a422a8a 100644 --- a/docs/Hub.html +++ b/docs/Hub.html @@ -384,7 +384,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index 74b018b..23340e3 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -393,7 +393,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

@@ -3488,7 +3488,7 @@ @@ -3674,7 +3674,7 @@ @@ -3983,7 +3983,7 @@ @@ -4145,7 +4145,7 @@ @@ -4307,7 +4307,7 @@ @@ -4493,7 +4493,7 @@ diff --git a/docs/PUPHub.html b/docs/PUPHub.html index a9ee190..8cb801e 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -404,7 +404,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

@@ -4755,7 +4755,7 @@ @@ -4950,7 +4950,7 @@ @@ -5273,7 +5273,7 @@ @@ -5468,7 +5468,7 @@ diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index e251a21..92e89ac 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -404,7 +404,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

@@ -3463,7 +3463,7 @@ diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html index 51e7ebe..b053c10 100644 --- a/docs/WeDo2SmartHub.html +++ b/docs/WeDo2SmartHub.html @@ -397,7 +397,7 @@ -

Current usage of the hub (Amps)

+

Current usage of the hub (Milliamps)

diff --git a/docs/classes.list.html b/docs/classes.list.html index ee3e3c9..d8d05a6 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -677,7 +677,7 @@ @@ -872,7 +872,7 @@ @@ -1195,7 +1195,7 @@ @@ -1366,7 +1366,7 @@ @@ -1561,7 +1561,7 @@ @@ -1732,7 +1732,7 @@ @@ -1903,7 +1903,7 @@ @@ -2698,7 +2698,7 @@ @@ -2884,7 +2884,7 @@ @@ -3193,7 +3193,7 @@ @@ -3355,7 +3355,7 @@ @@ -3517,7 +3517,7 @@ @@ -3703,7 +3703,7 @@ @@ -4371,7 +4371,7 @@ @@ -4566,7 +4566,7 @@ @@ -4889,7 +4889,7 @@ @@ -5084,7 +5084,7 @@ @@ -5450,7 +5450,7 @@ diff --git a/docs/hub.js.html b/docs/hub.js.html index 52b6441..6e9f3d5 100644 --- a/docs/hub.js.html +++ b/docs/hub.js.html @@ -167,7 +167,7 @@ class Hub extends events_1.EventEmitter { } /** * @readonly - * @property {number} current Current usage of the hub (Amps) + * @property {number} current Current usage of the hub (Milliamps) */ get current() { return this._current; diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index ab6e48b..b0ab20b 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -350,26 +350,29 @@ class LPF2Hub extends hub_1.Hub { _parseSensorMessage(data) { if ((data[3] === 0x3b && this.type === Consts.HubType.POWERED_UP_REMOTE)) { // Voltage (PUP Remote) data = this._padMessage(data, 6); - const voltage = data.readUInt16LE(4) / 500; - this._voltage = voltage; + const voltage = data.readUInt16LE(4); + this._voltage = 6400.0 * voltage / 3200.0 / 1000.0; return; } - else if (data[3] === 0x3c && this.type === Consts.HubType.POWERED_UP_REMOTE) { // Current (PUP Remote) + else if ((data[3] === 0x3c && this.type === Consts.HubType.POWERED_UP_HUB)) { // Voltage (PUP Hub) + data = this._padMessage(data, 6); + const voltage = data.readUInt16LE(4); + this._voltage = 9620.0 * voltage / 3893.0 / 1000.0; + return; + } + else if (data[3] === 0x3c) { // Voltage (Others) + data = this._padMessage(data, 6); + const voltage = data.readUInt16LE(4); + this._voltage = 9600.0 * voltage / 3893.0 / 1000.0; + return; + } + else if (data[3] === 0x3c && this.type === Consts.HubType.POWERED_UP_REMOTE) { // RSSI (PUP Remote) + return; + } + else if (data[3] === 0x3b) { // Current (Others) data = this._padMessage(data, 6); const current = data.readUInt16LE(4); - this._current = current; - return; - } - else if (data[3] === 0x3c && this.type !== Consts.HubType.POWERED_UP_REMOTE) { // Voltage (Non-PUP Remote) - data = this._padMessage(data, 6); - const voltage = data.readUInt16LE(4) / 400; - this._voltage = voltage; - return; - } - 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) / 1000; - this._current = current; + this._current = 2444 * current / 4095.0; return; } const port = this._getPortForPortNumber(data[3]); diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 54d93b8..08f6424 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@