Merge pull request #1512 from evhan55/wedo2-fixes

WeDo2 Fixes
This commit is contained in:
Evelyn Eastmond 2018-08-22 16:31:31 -04:00 committed by GitHub
commit 25b516a406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -501,7 +501,14 @@ class WeDo2 {
*/ */
// TODO: rename disconnect? // TODO: rename disconnect?
disconnectSession () { disconnectSession () {
// window.clearInterval(this._timeoutID); this._ports = ['none', 'none'];
this._motors = [null, null];
this._sensors = {
tiltX: 0,
tiltY: 0,
distance: 0
};
this._ble.disconnectSession(); this._ble.disconnectSession();
} }
@ -691,6 +698,7 @@ class WeDo2 {
* Stop the tone playing and motors on the WeDo 2.0 hub. * Stop the tone playing and motors on the WeDo 2.0 hub.
*/ */
_stopAll () { _stopAll () {
if (!this.getPeripheralIsConnected()) return;
this.stopTone() this.stopTone()
.then(() => { .then(() => {
this.stopAllMotors(); this.stopAllMotors();