Resolves #1988: Vernier gdxfor tilt values should be 0 when disconnected.

This commit is contained in:
Evelyn Eastmond 2019-02-07 16:29:16 -05:00 committed by unknown
parent 7ab41d2bd9
commit 8bbdc4e691

View file

@ -775,6 +775,13 @@ class Scratch3GdxForBlocks {
} }
getTilt (args) { 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) { switch (args.TILT) {
case TiltAxisValues.FRONT: case TiltAxisValues.FRONT:
return Math.round(this._peripheral.getTiltFrontBack(false)); return Math.round(this._peripheral.getTiltFrontBack(false));