Better error handling
This commit is contained in:
parent
a509a9c0b2
commit
0d0d1a8d32
@ -114,6 +114,9 @@ export class BoostMoveHub extends LPF2Hub {
|
|||||||
*/
|
*/
|
||||||
public setMotorAngle (port: string, angle: number, speed: number = 100) {
|
public setMotorAngle (port: string, angle: number, speed: number = 100) {
|
||||||
const portObj = this._ports[port];
|
const portObj = this._ports[port];
|
||||||
|
if (!(portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR || portObj.type === Consts.Devices.BOOST_MOVE_HUB_MOTOR)) {
|
||||||
|
throw new Error("Angle rotation is only available when using a Boost Interactive Motor or Boost Move Hub Motor");
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
portObj.busy = true;
|
portObj.busy = true;
|
||||||
const data = Buffer.from([0x0e, 0x00, 0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);
|
const data = Buffer.from([0x0e, 0x00, 0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);
|
||||||
|
@ -36,8 +36,7 @@ export class PUPHub extends LPF2Hub {
|
|||||||
this.type = Consts.Hubs.POWERED_UP_HUB;
|
this.type = Consts.Hubs.POWERED_UP_HUB;
|
||||||
this._ports = {
|
this._ports = {
|
||||||
"A": new Port("A", 0),
|
"A": new Port("A", 0),
|
||||||
"B": new Port("B", 1),
|
"B": new Port("B", 1)
|
||||||
"AB": new Port("AB", 57)
|
|
||||||
};
|
};
|
||||||
debug("Discovered Powered Up Hub");
|
debug("Discovered Powered Up Hub");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user