From 8bbdc4e691933dd1b4ef93e1c18d1fcccaf29634 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Thu, 7 Feb 2019 16:29:16 -0500 Subject: [PATCH] Resolves #1988: Vernier gdxfor tilt values should be 0 when 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 f0a1b5882..51917241e 100644 --- a/src/extensions/scratch3_gdx_for/index.js +++ b/src/extensions/scratch3_gdx_for/index.js @@ -775,6 +775,13 @@ class Scratch3GdxForBlocks { } getTilt (args) { + // When the peripheral is not connected, the acceleration magnitude + // is 0 instead of ~9.8, which ends up registering a tilt value; so + // we need to return 0 here to prevent returning a tilt value. + if (!this._peripheral.isConnected()) { + return 0; + } + switch (args.TILT) { case TiltAxisValues.FRONT: return Math.round(this._peripheral.getTiltFrontBack(false));