Resolves #1977: Vernier gdxfor extension falling? reports true while hardware disconnected.

This commit is contained in:
Evelyn Eastmond 2019-02-07 14:51:59 -05:00
parent 9dd8e9398a
commit a68886cee9

View file

@ -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();