mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -05:00
Fix motor turn for ports C/D. Zero out sensors and motor values on disconnect.
This commit is contained in:
parent
a220829007
commit
f511730602
1 changed files with 34 additions and 4 deletions
|
@ -171,8 +171,16 @@ class EV3 {
|
|||
disconnectSession () {
|
||||
this._bt.disconnectSession();
|
||||
window.clearInterval(this._pollingIntervalID); // TODO: window?
|
||||
this.speed = 50;
|
||||
this._sensors = {
|
||||
distance: 0,
|
||||
brightness: 0,
|
||||
buttons: [0, 0, 0, 0]
|
||||
};
|
||||
this._motorPositions = [0, 0, 0, 0];
|
||||
this._sensorPorts = [];
|
||||
this._motorPorts = [];
|
||||
this._pollingIntervalID = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -885,17 +893,39 @@ class Scratch3Ev3Blocks {
|
|||
}
|
||||
|
||||
motorTurnClockwise (args) {
|
||||
const port = Cast.toNumber(args.PORT);
|
||||
const port = Cast.toNumber(args.PORT); // TODO: fix
|
||||
const time = Cast.toNumber(args.TIME) * 1000;
|
||||
|
||||
return this._device.motorTurnClockwise(port, time);
|
||||
let p = null;
|
||||
if (port === 1) {
|
||||
p = 1;
|
||||
} else if (port === 2) {
|
||||
p = 2;
|
||||
} else if (port === 3) {
|
||||
p = 4;
|
||||
} else if (port === 4) {
|
||||
p = 8;
|
||||
}
|
||||
|
||||
return this._device.motorTurnClockwise(p, time);
|
||||
}
|
||||
|
||||
motorTurnCounterClockwise (args) {
|
||||
const port = Cast.toNumber(args.PORT);
|
||||
const port = Cast.toNumber(args.PORT); // TODO: fix
|
||||
const time = Cast.toNumber(args.TIME) * 1000;
|
||||
|
||||
return this._device.motorTurnCounterClockwise(port, time);
|
||||
let p = null;
|
||||
if (port === 1) {
|
||||
p = 1;
|
||||
} else if (port === 2) {
|
||||
p = 2;
|
||||
} else if (port === 3) {
|
||||
p = 4;
|
||||
} else if (port === 4) {
|
||||
p = 8;
|
||||
}
|
||||
|
||||
return this._device.motorTurnCounterClockwise(p, time);
|
||||
}
|
||||
|
||||
motorRotate (args) {
|
||||
|
|
Loading…
Reference in a new issue