mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-28 23:19:03 -04:00
Clearing ports on disconnect.
This commit is contained in:
parent
cf98e35564
commit
b9ea6005f8
1 changed files with 5 additions and 3 deletions
|
@ -164,6 +164,8 @@ class EV3 {
|
||||||
disconnectSession () {
|
disconnectSession () {
|
||||||
this._bt.disconnectSession();
|
this._bt.disconnectSession();
|
||||||
window.clearInterval(this._pollingIntervalID); // TODO: window?
|
window.clearInterval(this._pollingIntervalID); // TODO: window?
|
||||||
|
this._sensorPorts = [];
|
||||||
|
this._motorPorts = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -521,7 +523,7 @@ class EV3 {
|
||||||
compoundCommand[0] = compoundCommand.length - 2;
|
compoundCommand[0] = compoundCommand.length - 2;
|
||||||
// Calculate global var payload length needed
|
// Calculate global var payload length needed
|
||||||
compoundCommand[5] = (sensorCount + 1) * 4;
|
compoundCommand[5] = (sensorCount + 1) * 4;
|
||||||
console.log('compound command to send: ' + compoundCommand);
|
// console.log('compound command to send: ' + compoundCommand);
|
||||||
this._bt.sendMessage({
|
this._bt.sendMessage({
|
||||||
message: Base64Util.uint8ArrayToBase64(compoundCommand),
|
message: Base64Util.uint8ArrayToBase64(compoundCommand),
|
||||||
encoding: 'base64'
|
encoding: 'base64'
|
||||||
|
@ -538,6 +540,7 @@ class EV3 {
|
||||||
// SENSOR LIST
|
// SENSOR LIST
|
||||||
// JAABAAIefn5+fn5+fn5+fn5+fn5+Bwd+fn5+fn5+fn5+fn5+fgA=
|
// JAABAAIefn5+fn5+fn5+fn5+fn5+Bwd+fn5+fn5+fn5+fn5+fgA=
|
||||||
// [36, 0, 1, 0, 2, 30, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 7, 7, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 0]
|
// [36, 0, 1, 0, 2, 30, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 7, 7, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 0]
|
||||||
|
log.info(`device array: ${array}`);
|
||||||
this._sensorPorts[0] = EV_DEVICE_TYPES[array[5]];
|
this._sensorPorts[0] = EV_DEVICE_TYPES[array[5]];
|
||||||
this._sensorPorts[1] = EV_DEVICE_TYPES[array[6]];
|
this._sensorPorts[1] = EV_DEVICE_TYPES[array[6]];
|
||||||
this._sensorPorts[2] = EV_DEVICE_TYPES[array[7]];
|
this._sensorPorts[2] = EV_DEVICE_TYPES[array[7]];
|
||||||
|
@ -554,7 +557,7 @@ class EV3 {
|
||||||
// TODO: window?
|
// TODO: window?
|
||||||
this._pollingIntervalID = window.setInterval(this._getSessionData.bind(this), 100);
|
this._pollingIntervalID = window.setInterval(this._getSessionData.bind(this), 100);
|
||||||
} else {
|
} else {
|
||||||
log.info(`received compound command result: ${array}`);
|
//log.info(`received compound command result: ${array}`);
|
||||||
let offset = 5;
|
let offset = 5;
|
||||||
for (let i = 0; i < this._sensorPorts.length; i++) {
|
for (let i = 0; i < this._sensorPorts.length; i++) {
|
||||||
if (this._sensorPorts[i] !== 'none') {
|
if (this._sensorPorts[i] !== 'none') {
|
||||||
|
@ -600,7 +603,6 @@ class EV3 {
|
||||||
|
|
||||||
// TODO: put elsewhere
|
// TODO: put elsewhere
|
||||||
_array2float (list) {
|
_array2float (list) {
|
||||||
log.info(`list ${list}`);
|
|
||||||
const buffer = new Uint8Array(list).buffer;
|
const buffer = new Uint8Array(list).buffer;
|
||||||
const view = new DataView(buffer);
|
const view = new DataView(buffer);
|
||||||
return view.getFloat32(0, true);
|
return view.getFloat32(0, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue