diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index 21c3216..ec2e520 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -1257,7 +1257,7 @@ @@ -2088,6 +2088,168 @@ + + + + +
+
+

resetAbsolutePosition(port)

+ + +
+
+ + +
+

Reset the current motor position as absolute position zero

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -2922,7 +3084,7 @@ diff --git a/docs/ControlPlusHub.html b/docs/ControlPlusHub.html index 492e30e..e198bab 100644 --- a/docs/ControlPlusHub.html +++ b/docs/ControlPlusHub.html @@ -1257,7 +1257,7 @@ @@ -2088,6 +2088,168 @@ + + + + +
+
+

resetAbsolutePosition(port)

+ + +
+
+ + +
+

Reset the current motor position as absolute position zero

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -2922,7 +3084,7 @@ diff --git a/docs/PUPHub.html b/docs/PUPHub.html index 60505b5..b57861b 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -1257,7 +1257,7 @@ @@ -2088,6 +2088,168 @@ + + + + +
+
+

resetAbsolutePosition(port)

+ + +
+
+ + +
+

Reset the current motor position as absolute position zero

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
port + + +string + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

Resolved upon successful completion of command (ie. once the motor is finished).

+
+ + + +
+
+ Type +
+
+ +Promise + + + +
+
+ + + + +
@@ -2922,7 +3084,7 @@ diff --git a/docs/boostmovehub.js.html b/docs/boostmovehub.js.html index 997bdd5..ef7c858 100644 --- a/docs/boostmovehub.js.html +++ b/docs/boostmovehub.js.html @@ -298,13 +298,13 @@ class BoostMoveHub extends lpf2hub_1.LPF2Hub { let data = null; if (this._virtualPorts[portObj.id]) { data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); - data.writeUInt32LE(pos, 4); - data.writeUInt32LE(pos, 8); + data.writeInt32LE(pos, 4); + data.writeInt32LE(pos, 8); } else { // @ts-ignore: The type of speed is properly checked at the start data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); - data.writeUInt32LE(pos, 4); + data.writeInt32LE(pos, 4); } this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); portObj.finished = () => { @@ -312,6 +312,24 @@ class BoostMoveHub extends lpf2hub_1.LPF2Hub { }; }); } + /** + * Reset the current motor position as absolute position zero + * @method BoostMoveHub#resetAbsolutePosition + * @param {string} port + * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished). + */ + resetAbsolutePosition(port) { + const portObj = this._portLookup(port); + if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR || + portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) { + throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor"); + } + return new Promise((resolve) => { + const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); + return resolve(); + }); + } /** * Fully (hard) stop the motor on a given port. * @method BoostMoveHub#brakeMotor diff --git a/docs/controlplushub.js.html b/docs/controlplushub.js.html index 4242191..48c6958 100644 --- a/docs/controlplushub.js.html +++ b/docs/controlplushub.js.html @@ -293,13 +293,13 @@ class ControlPlusHub extends lpf2hub_1.LPF2Hub { let data = null; if (this._virtualPorts[portObj.id]) { data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); - data.writeUInt32LE(pos, 4); - data.writeUInt32LE(pos, 8); + data.writeInt32LE(pos, 4); + data.writeInt32LE(pos, 8); } else { // @ts-ignore: The type of speed is properly checked at the start data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); - data.writeUInt32LE(pos, 4); + data.writeInt32LE(pos, 4); } this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); portObj.finished = () => { @@ -307,6 +307,24 @@ class ControlPlusHub extends lpf2hub_1.LPF2Hub { }; }); } + /** + * Reset the current motor position as absolute position zero + * @method ControlPlusHub#resetAbsolutePosition + * @param {string} port + * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished). + */ + resetAbsolutePosition(port) { + const portObj = this._portLookup(port); + if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR || + portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) { + throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor"); + } + return new Promise((resolve) => { + const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); + return resolve(); + }); + } /** * Fully (hard) stop the motor on a given port. * @method ControlPlusHub#brakeMotor diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index 8361a14..ae9c9d8 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -534,7 +534,7 @@ class LPF2Hub extends hub_1.Hub { * @param {number} y * @param {number} z (Only available when using a Control+ Hub) */ - this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY, this._lastTiltY); + this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY, this._lastTiltZ); break; } case Consts.DeviceType.BOOST_TACHO_MOTOR: { diff --git a/docs/puphub.js.html b/docs/puphub.js.html index 95393b4..ed6d666 100644 --- a/docs/puphub.js.html +++ b/docs/puphub.js.html @@ -292,13 +292,13 @@ class PUPHub extends lpf2hub_1.LPF2Hub { let data = null; if (this._virtualPorts[portObj.id]) { data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); - data.writeUInt32LE(pos, 4); - data.writeUInt32LE(pos, 8); + data.writeInt32LE(pos, 4); + data.writeInt32LE(pos, 8); } else { // @ts-ignore: The type of speed is properly checked at the start data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]); - data.writeUInt32LE(pos, 4); + data.writeInt32LE(pos, 4); } this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); portObj.finished = () => { @@ -306,6 +306,24 @@ class PUPHub extends lpf2hub_1.LPF2Hub { }; }); } + /** + * Reset the current motor position as absolute position zero + * @method PUPHub#resetAbsolutePosition + * @param {string} port + * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished). + */ + resetAbsolutePosition(port) { + const portObj = this._portLookup(port); + if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR || + portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) { + throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor"); + } + return new Promise((resolve) => { + const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data); + return resolve(); + }); + } /** * Fully (hard) stop the motor on a given port. * @method PUPHub#brakeMotor diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 0cd78c2..7ad60d4 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@