Color mode working for Boost distance+color sensor on WeDo hub
This commit is contained in:
parent
0b7fa9f9b8
commit
138d1a57d6
14
boosthub.js
14
boosthub.js
@ -190,7 +190,7 @@ class BoostHub extends Hub {
|
|||||||
{
|
{
|
||||||
port.type = Consts.Devices.BOOST_TILT;
|
port.type = Consts.Devices.BOOST_TILT;
|
||||||
debug(`Port ${port.id} connected, detected 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,14 +258,10 @@ class BoostHub extends Hub {
|
|||||||
}
|
}
|
||||||
case Consts.Devices.WEDO2_TILT:
|
case Consts.Devices.WEDO2_TILT:
|
||||||
{
|
{
|
||||||
this._lastTiltX = data[4];
|
let tiltX = data[4] > 160 ? data[4] - 255 : data[4] - (data[4] * 2);
|
||||||
if (this._lastTiltX > 100) {
|
let tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2);
|
||||||
this._lastTiltX = -(255 - this._lastTiltX);
|
this._lastTiltX = tiltX;
|
||||||
}
|
this._lastTiltY = tiltY;
|
||||||
this._lastTiltY = data[5];
|
|
||||||
if (this._lastTiltY > 100) {
|
|
||||||
this._lastTiltY = -(255 - this._lastTiltY);
|
|
||||||
}
|
|
||||||
this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY);
|
this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,8 @@ class WeDo2Hub extends Hub {
|
|||||||
{
|
{
|
||||||
port.type = Consts.Devices.BOOST_DISTANCE;
|
port.type = Consts.Devices.BOOST_DISTANCE;
|
||||||
debug(`Port ${port.id} connected, detected 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;
|
break;
|
||||||
}
|
}
|
||||||
case Consts.Devices.BOOST_INTERACTIVE_MOTOR:
|
case Consts.Devices.BOOST_INTERACTIVE_MOTOR:
|
||||||
@ -171,7 +172,7 @@ class WeDo2Hub extends Hub {
|
|||||||
case Consts.Devices.BOOST_DISTANCE:
|
case Consts.Devices.BOOST_DISTANCE:
|
||||||
{
|
{
|
||||||
let distance = data[2];
|
let distance = data[2];
|
||||||
this.emit("distance", port.id, distance);
|
this.emit("color", port.id, distance);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Consts.Devices.WEDO2_TILT:
|
case Consts.Devices.WEDO2_TILT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user