WeDo 2.0 motor now works with PU hub
This commit is contained in:
parent
4988da178b
commit
9ddafe4e04
2
ABOUT.md
2
ABOUT.md
@ -23,7 +23,7 @@ While most LPF2 components and Hubs are compatible with each other, there are ex
|
|||||||
| WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a><br /> <a href="https://brickset.com/sets/76112-1/">76112</a> |
|
| WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a><br /> <a href="https://brickset.com/sets/76112-1/">76112</a> |
|
||||||
| Boost Color and Distance Sensor | Sensor | *Partial (<a href="#compatibility-note-1">1</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
| Boost Color and Distance Sensor | Sensor | *Partial (<a href="#compatibility-note-1">1</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
| Boost Interactive Motor | Motor/Sensor | *Partial (<a href="#compatibility-note-2">2</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
| Boost Interactive Motor | Motor/Sensor | *Partial (<a href="#compatibility-note-2">2</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
| Powered Up Train Motor | Motor | No | Yes | Yes | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
| Powered Up Train Motor | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
||||||
| Powered Up LED Lights | Light | Unknown | Unknown | Unknown | <a href="https://brickset.com/sets/88005-1/">88005</a> |
|
| Powered Up LED Lights | Light | Unknown | Unknown | Unknown | <a href="https://brickset.com/sets/88005-1/">88005</a> |
|
||||||
|
|
||||||
<a name="compatibility-note-1"></a><sub>(1) Only color mode is supported on the WeDo 2.0 Smart Hub at this point.</sub>
|
<a name="compatibility-note-1"></a><sub>(1) Only color mode is supported on the WeDo 2.0 Smart Hub at this point.</sub>
|
||||||
|
@ -23,7 +23,7 @@ While most LPF2 components and Hubs are compatible with each other, there are ex
|
|||||||
| WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a><br /> <a href="https://brickset.com/sets/76112-1/">76112</a> |
|
| WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/45300-1/">45300</a><br /> <a href="https://brickset.com/sets/76112-1/">76112</a> |
|
||||||
| Boost Color and Distance Sensor | Sensor | *Partial (<a href="#compatibility-note-1">1</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
| Boost Color and Distance Sensor | Sensor | *Partial (<a href="#compatibility-note-1">1</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
| Boost Interactive Motor | Motor/Sensor | *Partial (<a href="#compatibility-note-2">2</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
| Boost Interactive Motor | Motor/Sensor | *Partial (<a href="#compatibility-note-2">2</a>)* | Yes | Yes | <a href="https://brickset.com/sets/17101-1/">17101</a> |
|
||||||
| Powered Up Train Motor | Motor | No | Yes | Yes | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
| Powered Up Train Motor | Motor | Yes | Yes | Yes | <a href="https://brickset.com/sets/60197-1/">60197</a><br /><a href="https://brickset.com/sets/60198-1/">60198</a> |
|
||||||
| Powered Up LED Lights | Light | Unknown | Unknown | Unknown | <a href="https://brickset.com/sets/88005-1/">88005</a> |
|
| Powered Up LED Lights | Light | Unknown | Unknown | Unknown | <a href="https://brickset.com/sets/88005-1/">88005</a> |
|
||||||
|
|
||||||
<a name="compatibility-note-1"></a><sub>(1) Only color mode is supported on the WeDo 2.0 Smart Hub at this point.</sub>
|
<a name="compatibility-note-1"></a><sub>(1) Only color mode is supported on the WeDo 2.0 Smart Hub at this point.</sub>
|
||||||
|
@ -115,11 +115,7 @@ export class LPF2Hub extends Hub {
|
|||||||
public setMotorSpeed (port: string, speed: number, time: number) {
|
public setMotorSpeed (port: string, speed: number, time: number) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const portObj = this._ports[port];
|
const portObj = this._ports[port];
|
||||||
if (portObj.type === Consts.Devices.TRAIN_MOTOR) {
|
if (time) {
|
||||||
const data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
|
|
||||||
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
|
|
||||||
return resolve();
|
|
||||||
} else if (time) {
|
|
||||||
portObj.busy = true;
|
portObj.busy = true;
|
||||||
const data = Buffer.from([0x0c, 0x00, 0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
const data = Buffer.from([0x0c, 0x00, 0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
||||||
data.writeUInt16LE(time > 65535 ? 65535 : time, 6);
|
data.writeUInt16LE(time > 65535 ? 65535 : time, 6);
|
||||||
@ -128,7 +124,7 @@ export class LPF2Hub extends Hub {
|
|||||||
return resolve();
|
return resolve();
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
|
const data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
|
||||||
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
|
this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data);
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user