diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 61af3e418..c10f7a7c3 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -1016,10 +1016,7 @@ class Boost { break; case BoostIO.MOTOREXT: case BoostIO.MOTORINT: - // The motor position in port A is reversed by design, so we need - // to reverse it here so that all motors match - this.motor(portID).position = ((portID === BoostPort.A) ? -1 : 1) * - int32ArrayToNumber(data.slice(4, 8)); + this.motor(portID).position = int32ArrayToNumber(data.slice(4, 8)); break; case BoostIO.CURRENT: case BoostIO.VOLTAGE: @@ -1891,7 +1888,13 @@ class Scratch3BoostBlocks { return false; } 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; }