commit
138e1cc041
@ -71,10 +71,13 @@ export enum DeviceType {
|
|||||||
DUPLO_TRAIN_BASE_SPEEDOMETER = 44,
|
DUPLO_TRAIN_BASE_SPEEDOMETER = 44,
|
||||||
CONTROL_PLUS_LARGE_MOTOR = 46,
|
CONTROL_PLUS_LARGE_MOTOR = 46,
|
||||||
CONTROL_PLUS_XLARGE_MOTOR = 47,
|
CONTROL_PLUS_XLARGE_MOTOR = 47,
|
||||||
|
CONTROL_PLUS_GEST = 54,
|
||||||
POWERED_UP_REMOTE_BUTTON = 55,
|
POWERED_UP_REMOTE_BUTTON = 55,
|
||||||
RSSI = 56,
|
RSSI = 56,
|
||||||
CONTROL_PLUS_ACCELEROMETER = 58,
|
CONTROL_PLUS_ACCELEROMETER = 57,
|
||||||
CONTROL_PLUS_TILT = 59
|
CONTROL_PLUS_GYRO = 58,
|
||||||
|
CONTROL_PLUS_TILT = 59,
|
||||||
|
TEMPERATURE = 60,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +31,10 @@ export class ControlPlusHub extends LPF2Hub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected _currentPort = 0x3b;
|
protected _currentPort = 0x3b;
|
||||||
|
protected _currentMaxMA = 4175;
|
||||||
protected _voltagePort = 0x3c;
|
protected _voltagePort = 0x3c;
|
||||||
protected _voltageMaxRaw = 4095;
|
protected _voltageMaxRaw = 4095;
|
||||||
|
protected _voltageMaxV = 9.615;
|
||||||
|
|
||||||
constructor (device: IBLEDevice, autoSubscribe: boolean = true) {
|
constructor (device: IBLEDevice, autoSubscribe: boolean = true) {
|
||||||
super(device, autoSubscribe);
|
super(device, autoSubscribe);
|
||||||
@ -42,7 +44,8 @@ export class ControlPlusHub extends LPF2Hub {
|
|||||||
"B": new Port("B", 1),
|
"B": new Port("B", 1),
|
||||||
"C": new Port("C", 2),
|
"C": new Port("C", 2),
|
||||||
"D": new Port("D", 3),
|
"D": new Port("D", 3),
|
||||||
"ACCEL": new Port("ACCEL", 98),
|
"ACCEL": new Port("ACCEL", 97),
|
||||||
|
"GYRO": new Port("GYRO", 98),
|
||||||
"TILT": new Port("TILT", 99)
|
"TILT": new Port("TILT", 99)
|
||||||
};
|
};
|
||||||
this.on("attach", (port, type) => {
|
this.on("attach", (port, type) => {
|
||||||
|
@ -548,12 +548,27 @@ export class LPF2Hub extends Hub {
|
|||||||
this.emit("tilt", "TILT", this._lastTiltX, this._lastTiltY, this._lastTiltZ);
|
this.emit("tilt", "TILT", this._lastTiltX, this._lastTiltY, this._lastTiltZ);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Consts.DeviceType.CONTROL_PLUS_ACCELEROMETER: {
|
case Consts.DeviceType.CONTROL_PLUS_GYRO: {
|
||||||
const accelX = Math.round((data.readInt16LE(4) / 28571) * 2000);
|
const gyroX = Math.round(data.readInt16LE(4) * 7 / 400);
|
||||||
const accelY = Math.round((data.readInt16LE(6) / 28571) * 2000);
|
const gyroY = Math.round(data.readInt16LE(6) * 7 / 400);
|
||||||
const accelZ = Math.round((data.readInt16LE(8) / 28571) * 2000);
|
const gyroZ = Math.round(data.readInt16LE(8) * 7 / 400);
|
||||||
/**
|
/**
|
||||||
* Emits when accelerometer detects movement. Measured in DPS - degrees per second.
|
* Emits when gyroscope detects movement. Measured in DPS - degrees per second.
|
||||||
|
* @event LPF2Hub#gyro
|
||||||
|
* @param {string} port
|
||||||
|
* @param {number} x
|
||||||
|
* @param {number} y
|
||||||
|
* @param {number} z
|
||||||
|
*/
|
||||||
|
this.emit("gyro", "GYRO", gyroX, gyroY, gyroZ);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Consts.DeviceType.CONTROL_PLUS_ACCELEROMETER: {
|
||||||
|
const accelX = Math.round(data.readInt16LE(4) / 4.096);
|
||||||
|
const accelY = Math.round(data.readInt16LE(6) / 4.096);
|
||||||
|
const accelZ = Math.round(data.readInt16LE(8) / 4.096);
|
||||||
|
/**
|
||||||
|
* Emits when accelerometer detects movement. Measured in mG.
|
||||||
* @event LPF2Hub#accel
|
* @event LPF2Hub#accel
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number} x
|
* @param {number} x
|
||||||
|
Loading…
x
Reference in New Issue
Block a user