Power to speed when rotating by angle
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
ffd3cceab8
commit
364089b703
@ -31,16 +31,16 @@ export class TachoMotor extends BasicMotor {
|
|||||||
* Rotate a motor by a given angle.
|
* Rotate a motor by a given angle.
|
||||||
* @method TachoMotor#rotateByAngle
|
* @method TachoMotor#rotateByAngle
|
||||||
* @param {number} angle How much the motor should be rotated (in degrees).
|
* @param {number} angle How much the motor should be rotated (in degrees).
|
||||||
* @param {number} [power=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
|
* @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
|
||||||
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
||||||
*/
|
*/
|
||||||
public rotateByAngle (angle: number, power: number = 100) {
|
public rotateByAngle (angle: number, speed: number = 100) {
|
||||||
if (this.isWeDo2SmartHub) {
|
if (this.isWeDo2SmartHub) {
|
||||||
throw new Error("Angle rotation is not available on the WeDo 2.0 Smart Hub");
|
throw new Error("Angle rotation is not available on the WeDo 2.0 Smart Hub");
|
||||||
}
|
}
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this._busy = true;
|
this._busy = true;
|
||||||
const message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, mapSpeed(power), 0x64, 0x7f, 0x03]);
|
const message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
||||||
message.writeUInt32LE(angle, 4);
|
message.writeUInt32LE(angle, 4);
|
||||||
this.send(message);
|
this.send(message);
|
||||||
this._finished = () => {
|
this._finished = () => {
|
||||||
|
@ -401,20 +401,6 @@ export class LPF2Hub extends Hub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const port = this._getPortForPortNumber(data[3]);
|
|
||||||
|
|
||||||
// if (!port) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (data[4] === 0x0a) {
|
|
||||||
// port.busy = false;
|
|
||||||
// if (port.finished) {
|
|
||||||
// port.finished();
|
|
||||||
// port.finished = null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user