Merge pull request #1986 from evhan55/bug/gdxfor-falling

Vernier gdxfor "falling?" report false when not connected
This commit is contained in:
Evelyn Eastmond 2019-02-07 15:54:46 -05:00 committed by GitHub
commit 16ebcb82b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -827,6 +827,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();