Moving position reversal back to reporter to avoid conflicts.

This commit is contained in:
unknown 2019-04-24 22:42:54 -04:00
parent a61b01628e
commit a0f0a4092c

View file

@ -1016,10 +1016,7 @@ class Boost {
break; break;
case BoostIO.MOTOREXT: case BoostIO.MOTOREXT:
case BoostIO.MOTORINT: case BoostIO.MOTORINT:
// The motor position in port A is reversed by design, so we need this.motor(portID).position = int32ArrayToNumber(data.slice(4, 8));
// to reverse it here so that all motors match
this.motor(portID).position = ((portID === BoostPort.A) ? -1 : 1) *
int32ArrayToNumber(data.slice(4, 8));
break; break;
case BoostIO.CURRENT: case BoostIO.CURRENT:
case BoostIO.VOLTAGE: case BoostIO.VOLTAGE:
@ -1891,7 +1888,13 @@ class Scratch3BoostBlocks {
return false; return false;
} }
if (portID && this._peripheral.motor(portID)) { if (portID && this._peripheral.motor(portID)) {
return MathUtil.wrapClamp(this._peripheral.motor(portID).position, 0, 360); let val = this._peripheral.motor(portID).position;
// Boost motor A position direction is reversed by design
// so we have to reverse the position here
if (portID === BoostPort.A) {
val *= -1;
}
return MathUtil.wrapClamp(val, 0, 360);
} }
return 0; return 0;
} }