More reliable motor command for PUP hub

This commit is contained in:
Nathan Kunicki 2018-07-31 22:10:18 +01:00
parent e89e729a8c
commit 4f3f121319

View File

@ -133,25 +133,16 @@ export class LPF2Hub extends Hub {
return resolve();
};
} else {
let data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
if (this.type === Consts.Hubs.POWERED_UP_HUB && portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR) {
data = Buffer.from([0x07, 0x00, 0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed)]);
}
const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]);
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
setTimeout(() => {
let data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
if (this.type === Consts.Hubs.POWERED_UP_HUB && portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR) {
data = Buffer.from([0x07, 0x00, 0x81, portObj.value, 0x11, 0x02, 0x00]);
}
const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x60, 0x00, 0x00, 0x00, 0x00]);
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
return resolve();
}, time);
}
} else {
let data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
if (this.type === Consts.Hubs.POWERED_UP_HUB && portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR) {
data = Buffer.from([0x07, 0x00, 0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed)]);
}
const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]);
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
return resolve();
}