Simplified speed tuples
This commit is contained in:
parent
24037d537c
commit
8311773143
@ -86,11 +86,7 @@ export class BoostMoveHub extends LPF2Hub {
|
|||||||
portObj.busy = true;
|
portObj.busy = true;
|
||||||
let data = null;
|
let data = null;
|
||||||
if (portObj.id === "AB") {
|
if (portObj.id === "AB") {
|
||||||
if (speed instanceof Array) {
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed[0]), this._mapSpeed(speed[1]), 0x64, 0x7f, 0x03]);
|
|
||||||
} else {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed), this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
// @ts-ignore: The type of speed is properly checked at the start
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
||||||
@ -117,11 +113,7 @@ export class BoostMoveHub extends LPF2Hub {
|
|||||||
portObj.busy = true;
|
portObj.busy = true;
|
||||||
let data = null;
|
let data = null;
|
||||||
if (portObj.id === "AB") {
|
if (portObj.id === "AB") {
|
||||||
if (speed instanceof Array) {
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed[0]), this._mapSpeed(speed[1]), 0x64, 0x7f, 0x03]);
|
|
||||||
} else {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed), this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
// @ts-ignore: The type of speed is properly checked at the start
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
||||||
@ -161,11 +153,7 @@ export class BoostMoveHub extends LPF2Hub {
|
|||||||
portObj.busy = true;
|
portObj.busy = true;
|
||||||
let data = null;
|
let data = null;
|
||||||
if (portObj.id === "AB") {
|
if (portObj.id === "AB") {
|
||||||
if (speed instanceof Array) {
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed[0]), this._mapSpeed(speed[1]), 0x64, 0x7f, 0x03]);
|
|
||||||
} else {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
// @ts-ignore: The type of speed is properly checked at the start
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
||||||
|
@ -22,7 +22,7 @@ export enum Devices {
|
|||||||
|
|
||||||
|
|
||||||
export enum Colors {
|
export enum Colors {
|
||||||
NONE = 0,
|
BLACK = 0,
|
||||||
PINK = 1,
|
PINK = 1,
|
||||||
PURPLE = 2,
|
PURPLE = 2,
|
||||||
BLUE = 3,
|
BLUE = 3,
|
||||||
@ -32,7 +32,8 @@ export enum Colors {
|
|||||||
YELLOW = 7,
|
YELLOW = 7,
|
||||||
ORANGE = 8,
|
ORANGE = 8,
|
||||||
RED = 9,
|
RED = 9,
|
||||||
WHITE = 10
|
WHITE = 10,
|
||||||
|
NONE = 255
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ButtonStates {
|
export enum ButtonStates {
|
||||||
|
12
puphub.ts
12
puphub.ts
@ -95,11 +95,7 @@ export class PUPHub extends LPF2Hub {
|
|||||||
if (time) {
|
if (time) {
|
||||||
let data = null;
|
let data = null;
|
||||||
if (portObj.id === "AB") {
|
if (portObj.id === "AB") {
|
||||||
if (speed instanceof Array) {
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed)]);
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed[0]), this._mapSpeed(speed[1])]);
|
|
||||||
} else {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed), this._mapSpeed(speed)]);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
// @ts-ignore: The type of speed is properly checked at the start
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]);
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]);
|
||||||
@ -118,11 +114,7 @@ export class PUPHub extends LPF2Hub {
|
|||||||
} else {
|
} else {
|
||||||
let data = null;
|
let data = null;
|
||||||
if (portObj.id === "AB") {
|
if (portObj.id === "AB") {
|
||||||
if (speed instanceof Array) {
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed)]);
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed[0]), this._mapSpeed(speed[1])]);
|
|
||||||
} else {
|
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed), this._mapSpeed(speed)]);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore: The type of speed is properly checked at the start
|
// @ts-ignore: The type of speed is properly checked at the start
|
||||||
data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]);
|
data = Buffer.from([0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user