Color mode working for Boost distance+color sensor on WeDo hub

This commit is contained in:
Nathan Kunicki 2018-06-14 15:03:13 +01:00
parent 0b7fa9f9b8
commit 138d1a57d6
2 changed files with 8 additions and 11 deletions

View File

@ -190,7 +190,7 @@ class BoostHub extends Hub {
{
port.type = Consts.Devices.BOOST_TILT;
debug(`Port ${port.id} connected, detected BOOST_TILT`);
this._activatePortDevice(port.value, port.type, 0x00, 0x00);
this._activatePortDevice(port.value, port.type, 0x04, 0x00);
break;
}
}
@ -258,14 +258,10 @@ class BoostHub extends Hub {
}
case Consts.Devices.WEDO2_TILT:
{
this._lastTiltX = data[4];
if (this._lastTiltX > 100) {
this._lastTiltX = -(255 - this._lastTiltX);
}
this._lastTiltY = data[5];
if (this._lastTiltY > 100) {
this._lastTiltY = -(255 - this._lastTiltY);
}
let tiltX = data[4] > 160 ? data[4] - 255 : data[4] - (data[4] * 2);
let tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2);
this._lastTiltX = tiltX;
this._lastTiltY = tiltY;
this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY);
break;
}

View File

@ -102,7 +102,8 @@ class WeDo2Hub extends Hub {
{
port.type = Consts.Devices.BOOST_DISTANCE;
debug(`Port ${port.id} connected, detected BOOST_DISTANCE`);
this._activatePortDevice(data[0], port.type, 0x02, 0x00);
// NK: BOOST_DISTANCE only supports color when connected to WeDo 2.0 Smart Hub
this._activatePortDevice(data[0], port.type, 0x00, 0x00);
break;
}
case Consts.Devices.BOOST_INTERACTIVE_MOTOR:
@ -171,7 +172,7 @@ class WeDo2Hub extends Hub {
case Consts.Devices.BOOST_DISTANCE:
{
let distance = data[2];
this.emit("distance", port.id, distance);
this.emit("color", port.id, distance);
break;
}
case Consts.Devices.WEDO2_TILT: