From fe288902fa1e915fee0bf95a1eabe02f0c1d70c8 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Mon, 10 Sep 2018 12:27:38 -0400 Subject: [PATCH] Fixing #1567: EV3 motor position reporter gets inverted. --- src/extensions/scratch3_ev3/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/extensions/scratch3_ev3/index.js b/src/extensions/scratch3_ev3/index.js index a0b490e27..618e276c4 100644 --- a/src/extensions/scratch3_ev3/index.js +++ b/src/extensions/scratch3_ev3/index.js @@ -231,14 +231,10 @@ class EV3Motor { } /** - * @return {int} - this motor's current position, in the range [0,360]. + * @return {int} - this motor's current position, in the range [-inf,inf]. */ get position () { - let value = this._position; - value = value % 360; - value = value < 0 ? value * -1 : value; - - return value; + return this._position; } /** @@ -1156,8 +1152,12 @@ class Scratch3Ev3Blocks { } const motor = this._peripheral.motor(port); + let position = 0; + if (motor) { + position = MathUtil.wrapClamp(motor.position, 0, 360); + } - return motor ? motor.position : 0; + return position; } whenButtonPressed (args) {