From f0edd103469ed00e7c905cae4ea58d4a0fa0e7ee Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Tue, 23 Apr 2019 19:22:01 -0400 Subject: [PATCH 01/18] Change turnOnForever and turnOff behavior for power = 0 case. --- src/extensions/scratch3_boost/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index c10f7a7c3..86d512cea 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -496,7 +496,10 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnForever (resetState = true){ - if (this.power === 0) return; + if (this.power === 0) { + this.turnOff(false); + } + if (resetState) this.status = BoostMotorState.ON_FOREVER; this._turnOn(); } @@ -552,7 +555,7 @@ class BoostMotor { * @param {boolean} [useLimiter=true] - if true, use the rate limiter */ turnOff (useLimiter = true) { - if (this.power === 0) return; + // if (this.power === 0) return; const cmd = this._parent.generateOutputCommand( this._index, From 597bd68c0d68a898b2b0ec27339fb2de1765a48d Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Tue, 23 Apr 2019 19:28:04 -0400 Subject: [PATCH 02/18] Remove commented line. --- src/extensions/scratch3_boost/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 86d512cea..db8d8e4ab 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -555,8 +555,6 @@ class BoostMotor { * @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, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, From 270a445703c7c803f6314dabc89d276ccddb2aa5 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Fri, 26 Apr 2019 16:35:43 -0400 Subject: [PATCH 03/18] Playing with power states while we figure out the design. --- src/extensions/scratch3_boost/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index db8d8e4ab..4e3e4f5c8 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -510,7 +510,9 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnFor (milliseconds, resetState = true) { - if (this.power === 0) return; + if (this.power === 0) { + this.turnOff(false); + } milliseconds = Math.max(0, milliseconds); if (resetState) this.status = BoostMotorState.ON_FOR_TIME; @@ -525,10 +527,10 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnForDegrees (degrees, direction, resetState = true) { - if (this.power === 0) { + /* if (this.power === 0) { this._clearRotationState(); return; - } + }*/ degrees = Math.max(0, degrees); From 83bf1be06637fd736b17fa69ea7f5305977ea1b2 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Fri, 26 Apr 2019 16:42:07 -0400 Subject: [PATCH 04/18] Comment out all the power = 0 checks that came over from WeDo. --- src/extensions/scratch3_boost/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 4e3e4f5c8..c069dd079 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -477,7 +477,8 @@ class BoostMotor { * @private */ _turnOn () { - if (this.power === 0) return; + //if (this.power === 0) return; + const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY, @@ -496,9 +497,9 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnForever (resetState = true){ - if (this.power === 0) { + /* if (this.power === 0) { this.turnOff(false); - } + } */ if (resetState) this.status = BoostMotorState.ON_FOREVER; this._turnOn(); @@ -510,9 +511,9 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnFor (milliseconds, resetState = true) { - if (this.power === 0) { + /* if (this.power === 0) { this.turnOff(false); - } + } */ milliseconds = Math.max(0, milliseconds); if (resetState) this.status = BoostMotorState.ON_FOR_TIME; From 73fc5b87234679e0112393718a66156bb5d1fc85 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:14:15 -0400 Subject: [PATCH 05/18] Fixing lint. --- src/extensions/scratch3_boost/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index c069dd079..e6f60bda5 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -477,7 +477,7 @@ class BoostMotor { * @private */ _turnOn () { - //if (this.power === 0) return; + // if (this.power === 0) return; const cmd = this._parent.generateOutputCommand( this._index, From 12233b73dded09d64e0139df1b4ba4b7714c9f98 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:20:09 -0400 Subject: [PATCH 06/18] Fixing comments to reflect original code. --- src/extensions/scratch3_boost/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index e6f60bda5..f6b8871ae 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -497,9 +497,7 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnForever (resetState = true){ - /* if (this.power === 0) { - this.turnOff(false); - } */ + // if (this.power === 0) return; if (resetState) this.status = BoostMotorState.ON_FOREVER; this._turnOn(); @@ -511,9 +509,7 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnFor (milliseconds, resetState = true) { - /* if (this.power === 0) { - this.turnOff(false); - } */ + // if (this.power === 0) return; milliseconds = Math.max(0, milliseconds); if (resetState) this.status = BoostMotorState.ON_FOR_TIME; From 99c7528a1e20e13f00be179a0f1739a6cdee24d3 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:22:43 -0400 Subject: [PATCH 07/18] Removing some empty changed lines. --- src/extensions/scratch3_boost/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index f6b8871ae..9089bc1f1 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -478,7 +478,6 @@ class BoostMotor { */ _turnOn () { // if (this.power === 0) return; - const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY, @@ -498,7 +497,6 @@ class BoostMotor { */ turnOnForever (resetState = true){ // if (this.power === 0) return; - if (resetState) this.status = BoostMotorState.ON_FOREVER; this._turnOn(); } From 7ed8d376c5b3fbce6fa7edb290a821c2ff3870c6 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:23:28 -0400 Subject: [PATCH 08/18] Putting in a comment. --- src/extensions/scratch3_boost/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 9089bc1f1..1effbe285 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -552,6 +552,7 @@ class BoostMotor { * @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, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, From 14162b9920e6079dadda883c33734b02fcab1c61 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:24:01 -0400 Subject: [PATCH 09/18] Adding an empty line back in. --- src/extensions/scratch3_boost/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 1effbe285..2fa450991 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -553,6 +553,7 @@ class BoostMotor { */ turnOff (useLimiter = true) { // if (this.power === 0) return; + const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, From bb6514f1d6e4deb0f19b20695ee34d8ce22a07ee Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:24:41 -0400 Subject: [PATCH 10/18] Removing some tabs. --- src/extensions/scratch3_boost/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 2fa450991..33c1b2086 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -553,7 +553,7 @@ class BoostMotor { */ turnOff (useLimiter = true) { // if (this.power === 0) return; - + const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, From dd82079badfe9a933c8bede53614a21ac96bacd7 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 18:41:52 -0400 Subject: [PATCH 11/18] Fixing a comment style. --- src/extensions/scratch3_boost/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 33c1b2086..beec5506b 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -522,10 +522,10 @@ class BoostMotor { * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ turnOnForDegrees (degrees, direction, resetState = true) { - /* if (this.power === 0) { - this._clearRotationState(); - return; - }*/ + // if (this.power === 0) { + // this._clearRotationState(); + // return; + // } degrees = Math.max(0, degrees); From d0ed16d47c0742e826a51954a5e7ac040b59219c Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 19:10:25 -0400 Subject: [PATCH 12/18] Fixing Math.abs false arg? and moving it to turnOnForDegrees call. --- src/extensions/scratch3_boost/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index beec5506b..47b7cba73 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -499,6 +499,8 @@ class BoostMotor { // if (this.power === 0) return; if (resetState) this.status = BoostMotorState.ON_FOREVER; this._turnOn(); + + console.log('ON_FOREVER'); } /** @@ -513,6 +515,8 @@ class BoostMotor { if (resetState) this.status = BoostMotorState.ON_FOR_TIME; this._turnOn(); this._setNewTimeout(this.turnOff, milliseconds); + + console.log('ON_FOR_TIME'); } /** @@ -545,6 +549,8 @@ class BoostMotor { if (resetState) this.status = BoostMotorState.ON_FOR_ROTATION; this._pendingPositionDestination = this.position + (degrees * this.direction * direction); this._parent.send(BoostBLE.characteristic, cmd); + + console.log('ON_FOR_ROTATION'); } /** @@ -567,6 +573,8 @@ class BoostMotor { this.status = BoostMotorState.OFF; this._parent.send(BoostBLE.characteristic, cmd, useLimiter); + + console.log('OFF'); } /** @@ -1797,8 +1805,8 @@ class Scratch3BoostBlocks { motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false); break; case BoostMotorState.ON_FOR_ROTATION: { - const p = Math.abs(motor.pendingPositionDestination - motor.position, false); - motor.turnOnForDegrees(p, Math.sign(p)); + const p = Math.abs(motor.pendingPositionDestination - motor.position); + motor.turnOnForDegrees(p, Math.sign(p), false); break; } } From 410e13b4e3a0856b773b0d817362c38b5224f311 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 19:27:14 -0400 Subject: [PATCH 13/18] Remove resetState and all power===0 checks. --- src/extensions/scratch3_boost/index.js | 43 ++++++++++---------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 47b7cba73..51ecc8d4b 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -493,44 +493,33 @@ class BoostMotor { /** * Turn this motor on indefinitely - * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ - turnOnForever (resetState = true){ - // if (this.power === 0) return; - if (resetState) this.status = BoostMotorState.ON_FOREVER; + turnOnForever (){ + this.status = BoostMotorState.ON_FOREVER; this._turnOn(); - console.log('ON_FOREVER'); + console.log('this.status', this.status); } /** * Turn this motor on for a specific duration. * @param {number} milliseconds - run the motor for this long. - * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ - turnOnFor (milliseconds, resetState = true) { - // if (this.power === 0) return; - + turnOnFor (milliseconds) { milliseconds = Math.max(0, milliseconds); - if (resetState) this.status = BoostMotorState.ON_FOR_TIME; + this.status = BoostMotorState.ON_FOR_TIME; this._turnOn(); this._setNewTimeout(this.turnOff, milliseconds); - console.log('ON_FOR_TIME'); + console.log('this.status', this.status); } /** * Turn this motor on for a specific rotation in degrees. * @param {number} degrees - run the motor for this amount of degrees. * @param {number} direction - rotate in this direction - * @param {boolean} [resetState=true] - whether to reset the state of the motor when running this command. */ - turnOnForDegrees (degrees, direction, resetState = true) { - // if (this.power === 0) { - // this._clearRotationState(); - // return; - // } - + turnOnForDegrees (degrees, direction) { degrees = Math.max(0, degrees); const cmd = this._parent.generateOutputCommand( @@ -546,11 +535,11 @@ class BoostMotor { ] ); - if (resetState) this.status = BoostMotorState.ON_FOR_ROTATION; + this.status = BoostMotorState.ON_FOR_ROTATION; this._pendingPositionDestination = this.position + (degrees * this.direction * direction); this._parent.send(BoostBLE.characteristic, cmd); - console.log('ON_FOR_ROTATION'); + console.log('this.status', this.status); } /** @@ -574,7 +563,7 @@ class BoostMotor { this.status = BoostMotorState.OFF; this._parent.send(BoostBLE.characteristic, cmd, useLimiter); - console.log('OFF'); + console.log('this.status', this.status); } /** @@ -1799,14 +1788,14 @@ class Scratch3BoostBlocks { motor.power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100); switch (motor.status) { case BoostMotorState.ON_FOREVER: - motor.turnOnForever(false); + motor.turnOnForever(); break; case BoostMotorState.ON_FOR_TIME: - motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false); + motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now()); break; case BoostMotorState.ON_FOR_ROTATION: { const p = Math.abs(motor.pendingPositionDestination - motor.position); - motor.turnOnForDegrees(p, Math.sign(p), false); + motor.turnOnForDegrees(p, Math.sign(p)); break; } } @@ -1850,14 +1839,14 @@ class Scratch3BoostBlocks { if (motor) { switch (motor.status) { case BoostMotorState.ON_FOREVER: - motor.turnOnForever(false); + motor.turnOnForever(); break; case BoostMotorState.ON_FOR_TIME: - motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false); + motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now()); break; case BoostMotorState.ON_FOR_ROTATION: { const p = Math.abs(motor.pendingPositionDestination - motor.position); - motor.turnOnForDegrees(p, Math.sign(p), false); + motor.turnOnForDegrees(p, Math.sign(p)); break; } } From 5109cd474c6eb6e79d9d5b834bb9c68d682965a1 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sat, 27 Apr 2019 19:29:07 -0400 Subject: [PATCH 14/18] Remove more power===0 checks. --- src/extensions/scratch3_boost/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 51ecc8d4b..7544657a9 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -477,7 +477,6 @@ class BoostMotor { * @private */ _turnOn () { - // if (this.power === 0) return; const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY, @@ -547,8 +546,6 @@ class BoostMotor { * @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, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, From 75eae9a58aff46aedf483f12879ecd693bea5ae8 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sun, 28 Apr 2019 20:42:38 -0400 Subject: [PATCH 15/18] Fixing motor status setter to not clear rotation if already in rotation state. --- src/extensions/scratch3_boost/index.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 7544657a9..ec776a473 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -432,7 +432,10 @@ class BoostMotor { */ set status (value) { // Clear any time- or rotation-related state from motor and set new status. - this._clearRotationState(); + if (value !== BoostMotorState.ON_FOR_ROTATION) { + this._clearRotationState(); + console.log('clearing rotation state'); + } this._clearTimeout(); this._status = value; } @@ -493,7 +496,8 @@ class BoostMotor { /** * Turn this motor on indefinitely */ - turnOnForever (){ + turnOnForever() { + console.log('turnOnForever'); this.status = BoostMotorState.ON_FOREVER; this._turnOn(); @@ -504,7 +508,8 @@ class BoostMotor { * Turn this motor on for a specific duration. * @param {number} milliseconds - run the motor for this long. */ - turnOnFor (milliseconds) { + turnOnFor(milliseconds) { + console.log('turnOnFor'); milliseconds = Math.max(0, milliseconds); this.status = BoostMotorState.ON_FOR_TIME; this._turnOn(); @@ -519,6 +524,7 @@ class BoostMotor { * @param {number} direction - rotate in this direction */ turnOnForDegrees (degrees, direction) { + console.log('turnOnForDegrees'); degrees = Math.max(0, degrees); const cmd = this._parent.generateOutputCommand( @@ -545,7 +551,8 @@ class BoostMotor { * Turn this motor off. * @param {boolean} [useLimiter=true] - if true, use the rate limiter */ - turnOff (useLimiter = true) { + turnOff(useLimiter = true) { + console.log('turnOff'); const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, @@ -1727,7 +1734,9 @@ class Scratch3BoostBlocks { * Make sure all promises are resolved, i.e. all motor-commands have completed. * To prevent the block from returning a value, an empty function is added to the .then */ - return Promise.all(promises).then(() => {}); + return Promise.all(promises).then(() => { + console.log('motorOnForRotation resolved'); + }); } /** From c37a41c352ca7bfb83c7c2b25a02bab35629b9fd Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sun, 28 Apr 2019 20:47:29 -0400 Subject: [PATCH 16/18] Only clear pending duration timeout if not in _ON_FOR_TIME state. --- src/extensions/scratch3_boost/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index ec776a473..9b95434e1 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -436,7 +436,10 @@ class BoostMotor { this._clearRotationState(); console.log('clearing rotation state'); } - this._clearTimeout(); + if (value !== BoostMotorState.ON_FOR_TIME) { + this._clearTimeout(); + console.log('clearing for_time state'); + } this._status = value; } From a67b303294fa80672b5347a2819a782c0e4f85c2 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Mon, 29 Apr 2019 11:42:09 -0400 Subject: [PATCH 17/18] Remove console logs and change a comment. --- src/extensions/scratch3_boost/index.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 9b95434e1..3dd297725 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -431,14 +431,13 @@ class BoostMotor { * @param {BoostMotorState} value - set this motor's state. */ set status (value) { - // Clear any time- or rotation-related state from motor and set new status. if (value !== BoostMotorState.ON_FOR_ROTATION) { + // clear rotation pending promise only if not already in rotation state this._clearRotationState(); - console.log('clearing rotation state'); } if (value !== BoostMotorState.ON_FOR_TIME) { + // clear duration pending promise only if not already in duration state this._clearTimeout(); - console.log('clearing for_time state'); } this._status = value; } @@ -500,11 +499,8 @@ class BoostMotor { * Turn this motor on indefinitely */ turnOnForever() { - console.log('turnOnForever'); this.status = BoostMotorState.ON_FOREVER; this._turnOn(); - - console.log('this.status', this.status); } /** @@ -512,13 +508,10 @@ class BoostMotor { * @param {number} milliseconds - run the motor for this long. */ turnOnFor(milliseconds) { - console.log('turnOnFor'); milliseconds = Math.max(0, milliseconds); this.status = BoostMotorState.ON_FOR_TIME; this._turnOn(); this._setNewTimeout(this.turnOff, milliseconds); - - console.log('this.status', this.status); } /** @@ -527,7 +520,6 @@ class BoostMotor { * @param {number} direction - rotate in this direction */ turnOnForDegrees (degrees, direction) { - console.log('turnOnForDegrees'); degrees = Math.max(0, degrees); const cmd = this._parent.generateOutputCommand( @@ -546,8 +538,6 @@ class BoostMotor { this.status = BoostMotorState.ON_FOR_ROTATION; this._pendingPositionDestination = this.position + (degrees * this.direction * direction); this._parent.send(BoostBLE.characteristic, cmd); - - console.log('this.status', this.status); } /** @@ -555,7 +545,6 @@ class BoostMotor { * @param {boolean} [useLimiter=true] - if true, use the rate limiter */ turnOff(useLimiter = true) { - console.log('turnOff'); const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, @@ -569,8 +558,6 @@ class BoostMotor { this.status = BoostMotorState.OFF; this._parent.send(BoostBLE.characteristic, cmd, useLimiter); - - console.log('this.status', this.status); } /** @@ -1737,9 +1724,7 @@ class Scratch3BoostBlocks { * Make sure all promises are resolved, i.e. all motor-commands have completed. * To prevent the block from returning a value, an empty function is added to the .then */ - return Promise.all(promises).then(() => { - console.log('motorOnForRotation resolved'); - }); + return Promise.all(promises).then(() => {}); } /** From 7e01326d717abbf5665dcd79e578a71907d181a9 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Mon, 29 Apr 2019 11:45:15 -0400 Subject: [PATCH 18/18] Fixing linting. --- src/extensions/scratch3_boost/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 3dd297725..5b95c78a0 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -498,7 +498,7 @@ class BoostMotor { /** * Turn this motor on indefinitely */ - turnOnForever() { + turnOnForever () { this.status = BoostMotorState.ON_FOREVER; this._turnOn(); } @@ -507,7 +507,7 @@ class BoostMotor { * Turn this motor on for a specific duration. * @param {number} milliseconds - run the motor for this long. */ - turnOnFor(milliseconds) { + turnOnFor (milliseconds) { milliseconds = Math.max(0, milliseconds); this.status = BoostMotorState.ON_FOR_TIME; this._turnOn(); @@ -544,7 +544,7 @@ class BoostMotor { * Turn this motor off. * @param {boolean} [useLimiter=true] - if true, use the rate limiter */ - turnOff(useLimiter = true) { + turnOff (useLimiter = true) { const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK,