Added docs

This commit is contained in:
Nathan Kellenicki 2020-05-23 18:37:19 -07:00
parent b219dcf60b
commit 0a9f200e97
2 changed files with 28 additions and 13 deletions

View File

@ -71,19 +71,6 @@ export class AbsoluteMotor extends TachoMotor {
});
}
/**
* Reset the current position as angle 0
* @method AbsoluteMotor#resetAngle
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
public resetAngle () {
return new Promise((resolve) => {
const data = Buffer.from([0x81, this.portId, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
this.send(data);
return resolve();
});
}
}

View File

@ -48,6 +48,13 @@ export class TachoMotor extends BasicMotor {
this._brakeStyle = style;
}
/**
* Set the global acceleration time
* @method TachoMotor#setAccelerationTime
* @param {number} time How long acceleration should last (in milliseconds).
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
public setAccelerationTime (time: number, profile: number = 0x00) {
const message = Buffer.from([0x81, this.portId, 0x11, 0x05, 0x00, 0x00, profile]);
message.writeUInt16LE(time, 4);
@ -55,6 +62,12 @@ export class TachoMotor extends BasicMotor {
}
/**
* Set the global deceleration time
* @method TachoMotor#setDecelerationTime
* @param {number} time How long deceleration should last (in milliseconds).
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
public setDecelerationTime (time: number, profile: number = 0x00) {
const message = Buffer.from([0x81, this.portId, 0x11, 0x06, 0x00, 0x00, profile]);
message.writeUInt16LE(time, 4);
@ -66,6 +79,7 @@ export class TachoMotor extends BasicMotor {
* Set the motor speed.
* @method TachoMotor#setSpeed
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
* @param {number} time How long the motor should run for (in milliseconds).
* @returns {Promise} Resolved upon successful issuance of the command.
*/
public setSpeed (speed: [number, number] | number, time: number | undefined) {
@ -138,6 +152,20 @@ export class TachoMotor extends BasicMotor {
}
/**
* Reset zero to current position
* @method TachoMotor#resetZero
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
public resetZero () {
return new Promise((resolve) => {
const data = Buffer.from([0x81, this.portId, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
this.send(data);
return resolve();
});
}
protected useProfile () {
let value = 0x00;
if (this.useAccelerationProfile) {