mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Changing some variable names regarding duration and rotation blocks for clarity.
This commit is contained in:
parent
f2301e0e4d
commit
eabff71461
1 changed files with 29 additions and 29 deletions
|
@ -332,28 +332,28 @@ class BoostMotor {
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._pendingTimeoutId = null;
|
this._pendingDurationTimeoutId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The starting time for the pending timeout.
|
* The starting time for the pending duration timeout.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._pendingTimeoutStartTime = null;
|
this._pendingDurationTimeoutStartTime = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The delay/duration of the pending timeout.
|
* The delay/duration of the pending duration timeout.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._pendingTimeoutDelay = null;
|
this._pendingDurationTimeoutDelay = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target position of a turn-based command.
|
* The target position of a turn-based command.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._pendingPositionDestination = null;
|
this._pendingRotationDestination = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the motor has been turned on run for a specific duration,
|
* If the motor has been turned on run for a specific duration,
|
||||||
|
@ -361,7 +361,7 @@ class BoostMotor {
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._pendingPromiseFunction = null;
|
this._pendingRotationPromise = null;
|
||||||
|
|
||||||
this.turnOff = this.turnOff.bind(this);
|
this.turnOff = this.turnOff.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -440,35 +440,35 @@ class BoostMotor {
|
||||||
* @return {number} - time, in milliseconds, of when the pending timeout began.
|
* @return {number} - time, in milliseconds, of when the pending timeout began.
|
||||||
*/
|
*/
|
||||||
get pendingTimeoutStartTime () {
|
get pendingTimeoutStartTime () {
|
||||||
return this._pendingTimeoutStartTime;
|
return this._pendingDurationTimeoutStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} - delay, in milliseconds, of the pending timeout.
|
* @return {number} - delay, in milliseconds, of the pending timeout.
|
||||||
*/
|
*/
|
||||||
get pendingTimeoutDelay () {
|
get pendingTimeoutDelay () {
|
||||||
return this._pendingTimeoutDelay;
|
return this._pendingDurationTimeoutDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} - delay, in milliseconds, of the pending timeout.
|
* @return {number} - delay, in milliseconds, of the pending timeout.
|
||||||
*/
|
*/
|
||||||
get pendingPositionDestination () {
|
get pendingPositionDestination () {
|
||||||
return this._pendingPositionDestination;
|
return this._pendingRotationDestination;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} - true if this motor is currently moving, false if this motor is off or braking.
|
* @return {boolean} - true if this motor is currently moving, false if this motor is off or braking.
|
||||||
*/
|
*/
|
||||||
get pendingPromiseFunction () {
|
get pendingPromiseFunction () {
|
||||||
return this._pendingPromiseFunction;
|
return this._pendingRotationPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {function} func - function to resolve promise
|
* @param {function} func - function to resolve promise
|
||||||
*/
|
*/
|
||||||
set pendingPromiseFunction (func) {
|
set pendingPromiseFunction (func) {
|
||||||
this._pendingPromiseFunction = func;
|
this._pendingRotationPromise = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -530,7 +530,7 @@ class BoostMotor {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.status = BoostMotorState.ON_FOR_ROTATION;
|
this.status = BoostMotorState.ON_FOR_ROTATION;
|
||||||
this._pendingPositionDestination = this.position + (degrees * this.direction * direction);
|
this._pendingRotationDestination = this.position + (degrees * this.direction * direction);
|
||||||
this._parent.send(BoostBLE.characteristic, cmd);
|
this._parent.send(BoostBLE.characteristic, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,11 +559,11 @@ class BoostMotor {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_clearTimeout () {
|
_clearTimeout () {
|
||||||
if (this._pendingTimeoutId !== null) {
|
if (this._pendingDurationTimeoutId !== null) {
|
||||||
clearTimeout(this._pendingTimeoutId);
|
clearTimeout(this._pendingDurationTimeoutId);
|
||||||
this._pendingTimeoutId = null;
|
this._pendingDurationTimeoutId = null;
|
||||||
this._pendingTimeoutStartTime = null;
|
this._pendingDurationTimeoutStartTime = null;
|
||||||
this._pendingTimeoutDelay = null;
|
this._pendingDurationTimeoutDelay = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,16 +576,16 @@ class BoostMotor {
|
||||||
_setNewTimeout (callback, delay) {
|
_setNewTimeout (callback, delay) {
|
||||||
this._clearTimeout();
|
this._clearTimeout();
|
||||||
const timeoutID = setTimeout(() => {
|
const timeoutID = setTimeout(() => {
|
||||||
if (this._pendingTimeoutId === timeoutID) {
|
if (this._pendingDurationTimeoutId === timeoutID) {
|
||||||
this._pendingTimeoutId = null;
|
this._pendingDurationTimeoutId = null;
|
||||||
this._pendingTimeoutStartTime = null;
|
this._pendingDurationTimeoutStartTime = null;
|
||||||
this._pendingTimeoutDelay = null;
|
this._pendingDurationTimeoutDelay = null;
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}, delay);
|
}, delay);
|
||||||
this._pendingTimeoutId = timeoutID;
|
this._pendingDurationTimeoutId = timeoutID;
|
||||||
this._pendingTimeoutStartTime = Date.now();
|
this._pendingDurationTimeoutStartTime = Date.now();
|
||||||
this._pendingTimeoutDelay = delay;
|
this._pendingDurationTimeoutDelay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -594,11 +594,11 @@ class BoostMotor {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_clearRotationState () {
|
_clearRotationState () {
|
||||||
if (this._pendingPromiseFunction !== null) {
|
if (this._pendingRotationPromise !== null) {
|
||||||
this._pendingPromiseFunction();
|
this._pendingRotationPromise();
|
||||||
this._pendingPromiseFunction = null;
|
this._pendingRotationPromise = null;
|
||||||
}
|
}
|
||||||
this._pendingPositionDestination = null;
|
this._pendingRotationDestination = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue