From a68886cee99b5c438ce7c54a5bd96da0293e85d0 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Thu, 7 Feb 2019 14:51:59 -0500 Subject: [PATCH] Resolves #1977: Vernier gdxfor extension falling? reports true while hardware disconnected. --- src/extensions/scratch3_gdx_for/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/extensions/scratch3_gdx_for/index.js b/src/extensions/scratch3_gdx_for/index.js index 88e6cca63..2514e0786 100644 --- a/src/extensions/scratch3_gdx_for/index.js +++ b/src/extensions/scratch3_gdx_for/index.js @@ -822,6 +822,13 @@ class Scratch3GdxForBlocks { } isFreeFalling () { + // When the peripheral is not connected, the acceleration magnitude + // is 0 instead of ~9.8, which ends up calculating as a positive + // free fall; so we need to return 'false' here to prevent returning 'true'. + if (!this._peripheral.isConnected()) { + return false; + } + const accelMag = this.accelMagnitude(); const spinMag = this.spinMagnitude();