diff --git a/src/extensions/scratch3_ev3/index.js b/src/extensions/scratch3_ev3/index.js index d2dd6bbf..b24dac57 100644 --- a/src/extensions/scratch3_ev3/index.js +++ b/src/extensions/scratch3_ev3/index.js @@ -266,6 +266,8 @@ class EV3Motor { * @param {number} milliseconds - run the motor for this long. */ turnOnFor (milliseconds) { + if (this._power === 0) return; + const port = this._portMask(this._index); let n = milliseconds; let speed = this._power * this._direction; @@ -323,6 +325,8 @@ class EV3Motor { * @param {number} time - the time in milliseconds. */ coastAfter (time) { + if (this._power === 0) return; + // Set the motor command id to check before starting coast const commandId = uid(); this._commandID = commandId; @@ -341,6 +345,8 @@ class EV3Motor { * Set the motor to coast. */ coast () { + if (this._power === 0) return; + const cmd = this._parent.generateCommand( Ev3Command.DIRECT_COMMAND_NO_REPLY, [ diff --git a/src/extensions/scratch3_wedo2/index.js b/src/extensions/scratch3_wedo2/index.js index 95ff5102..d0a118cb 100644 --- a/src/extensions/scratch3_wedo2/index.js +++ b/src/extensions/scratch3_wedo2/index.js @@ -254,6 +254,8 @@ class WeDo2Motor { * Turn this motor on indefinitely. */ turnOn () { + if (this._power === 0) return; + const cmd = this._parent.generateOutputCommand( this._index + 1, WeDo2Command.MOTOR_POWER, @@ -271,6 +273,8 @@ class WeDo2Motor { * @param {number} milliseconds - run the motor for this long. */ turnOnFor (milliseconds) { + if (this._power === 0) return; + milliseconds = Math.max(0, milliseconds); this.turnOn(); this._setNewTimeout(this.startBraking, milliseconds); @@ -281,6 +285,8 @@ class WeDo2Motor { * // TODO: rename this to coastAfter? */ startBraking () { + if (this._power === 0) return; + const cmd = this._parent.generateOutputCommand( this._index + 1, WeDo2Command.MOTOR_POWER, @@ -298,6 +304,8 @@ class WeDo2Motor { * @param {boolean} [useLimiter=true] - if true, use the rate limiter */ turnOff (useLimiter = true) { + if (this._power === 0) return; + const cmd = this._parent.generateOutputCommand( this._index + 1, WeDo2Command.MOTOR_POWER,