mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Testing some new variable names.
This commit is contained in:
parent
471a22dbdc
commit
c5a954fb56
1 changed files with 22 additions and 23 deletions
|
@ -29,7 +29,7 @@ const Ev3PairingPin = '1234';
|
||||||
const BTSendRateMax = 40;
|
const BTSendRateMax = 40;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for Ev3 byte specs used as parameter encodings to various argument values.
|
* Enum for Ev3 parameter encodings of various argument and return values.
|
||||||
* Found in the 'EV3 Firmware Developer Kit', section4, page 9, at
|
* Found in the 'EV3 Firmware Developer Kit', section4, page 9, at
|
||||||
* https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
|
* https://education.lego.com/en-us/support/mindstorms-ev3/developer-kits.
|
||||||
*
|
*
|
||||||
|
@ -40,14 +40,13 @@ const BTSendRateMax = 40;
|
||||||
* @readonly
|
* @readonly
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
const Ev3ParamEncoding = {
|
const Ev3Encoding = {
|
||||||
GLOBAL_CONSTANT_INDEX_0: 0x20, // = 0b00100000 = global constant value > index "0"
|
LOCAL_CONSTANT_ONE_BYTE: 0x81, // = 0b1000-001
|
||||||
GLOBAL_CONSTANT_INDEX_1: 0x21, // = 0b00100001 = global constant value > index "1"
|
LOCAL_CONSTANT_TWO_BYTES: 0x82, // = 0b1000-010
|
||||||
GLOBAL_VARIABLE_INDEX_0: 0x60, // = 0b00110000 = global variable value > index "0"
|
LOCAL_CONSTANT_FOUR_BYTES: 0x83, // = 0b1000-011
|
||||||
ONE_BYTE: 0x81, // = 0b1000-001 = constant value > 1 byte to follow
|
GLOBAL_VARIABLE_ONE_BYTE: 0xE1, // = 0b1110-001
|
||||||
TWO_BYTES: 0x82, // = 0b1000-010 = constant value > 2 bytes to follow
|
GLOBAL_CONSTANT_INDEX_0: 0x20, // = 0b00100000
|
||||||
FOUR_BYTES: 0x83, // = 0b1000-011 = constant value > 4 bytes to follow
|
GLOBAL_VARIABLE_INDEX_0: 0x60 // = 0b00110000
|
||||||
GLOBAL_ONE_BYTE: 0xE1 // = 0b1110-001 = size of global var > 1 byte to follow
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,12 +331,12 @@ class EV3Motor {
|
||||||
byteCommand = byteCommand.concat([
|
byteCommand = byteCommand.concat([
|
||||||
Ev3Args.LAYER,
|
Ev3Args.LAYER,
|
||||||
port,
|
port,
|
||||||
Ev3ParamEncoding.ONE_BYTE,
|
Ev3Encoding.LOCAL_CONSTANT_ONE_BYTE,
|
||||||
dir & 0xff,
|
dir & 0xff,
|
||||||
Ev3ParamEncoding.ONE_BYTE,
|
Ev3Encoding.LOCAL_CONSTANT_ONE_BYTE,
|
||||||
rampup
|
rampup
|
||||||
]).concat(runcmd.concat([
|
]).concat(runcmd.concat([
|
||||||
Ev3ParamEncoding.ONE_BYTE,
|
Ev3Encoding.LOCAL_CONSTANT_ONE_BYTE,
|
||||||
rampdown,
|
rampdown,
|
||||||
Ev3Args.BRAKE
|
Ev3Args.BRAKE
|
||||||
]));
|
]));
|
||||||
|
@ -401,7 +400,7 @@ class EV3Motor {
|
||||||
// If run duration is less than max 16-bit integer
|
// If run duration is less than max 16-bit integer
|
||||||
if (run < 0x7fff) {
|
if (run < 0x7fff) {
|
||||||
return [
|
return [
|
||||||
Ev3ParamEncoding.TWO_BYTES,
|
Ev3Encoding.LOCAL_CONSTANT_TWO_BYTES,
|
||||||
run & 0xff,
|
run & 0xff,
|
||||||
(run >> 8) & 0xff
|
(run >> 8) & 0xff
|
||||||
];
|
];
|
||||||
|
@ -409,7 +408,7 @@ class EV3Motor {
|
||||||
|
|
||||||
// Run forever
|
// Run forever
|
||||||
return [
|
return [
|
||||||
Ev3ParamEncoding.FOUR_BYTES,
|
Ev3Encoding.LOCAL_CONSTANT_FOUR_BYTES,
|
||||||
run & 0xff,
|
run & 0xff,
|
||||||
(run >> 8) & 0xff,
|
(run >> 8) & 0xff,
|
||||||
(run >> 16) & 0xff,
|
(run >> 16) & 0xff,
|
||||||
|
@ -553,12 +552,12 @@ class EV3 {
|
||||||
[
|
[
|
||||||
Ev3Opcode.OPSOUND,
|
Ev3Opcode.OPSOUND,
|
||||||
Ev3Opcode.OPSOUND_CMD_TONE,
|
Ev3Opcode.OPSOUND_CMD_TONE,
|
||||||
Ev3ParamEncoding.ONE_BYTE,
|
Ev3Encoding.LOCAL_CONSTANT_ONE_BYTE,
|
||||||
2,
|
2,
|
||||||
Ev3ParamEncoding.TWO_BYTES,
|
Ev3Encoding.LOCAL_CONSTANT_TWO_BYTES,
|
||||||
freq,
|
freq,
|
||||||
freq >> 8,
|
freq >> 8,
|
||||||
Ev3ParamEncoding.TWO_BYTES,
|
Ev3Encoding.LOCAL_CONSTANT_TWO_BYTES,
|
||||||
time,
|
time,
|
||||||
time >> 8
|
time >> 8
|
||||||
]
|
]
|
||||||
|
@ -738,11 +737,11 @@ class EV3 {
|
||||||
if (this._pollingCounter % 20 === 0) {
|
if (this._pollingCounter % 20 === 0) {
|
||||||
// GET DEVICE LIST
|
// GET DEVICE LIST
|
||||||
cmds[0] = Ev3Opcode.OPINPUT_DEVICE_LIST;
|
cmds[0] = Ev3Opcode.OPINPUT_DEVICE_LIST;
|
||||||
cmds[1] = Ev3ParamEncoding.ONE_BYTE;
|
cmds[1] = Ev3Encoding.LOCAL_CONSTANT_ONE_BYTE;
|
||||||
cmds[2] = Ev3Args.MAX_DEVICES;
|
cmds[2] = Ev3Args.MAX_DEVICES;
|
||||||
cmds[3] = Ev3ParamEncoding.GLOBAL_VARIABLE_INDEX_0;
|
cmds[3] = Ev3Encoding.GLOBAL_VARIABLE_INDEX_0;
|
||||||
cmds[4] = Ev3ParamEncoding.GLOBAL_ONE_BYTE;
|
cmds[4] = Ev3Encoding.GLOBAL_VARIABLE_ONE_BYTE;
|
||||||
cmds[5] = Ev3ParamEncoding.GLOBAL_CONSTANT_INDEX_0;
|
cmds[5] = Ev3Encoding.GLOBAL_CONSTANT_INDEX_0;
|
||||||
|
|
||||||
// Command and payload lengths
|
// Command and payload lengths
|
||||||
allocation = 33;
|
allocation = 33;
|
||||||
|
@ -758,7 +757,7 @@ class EV3 {
|
||||||
cmds[index + 2] = i; // PORT
|
cmds[index + 2] = i; // PORT
|
||||||
cmds[index + 3] = Ev3Args.DO_NOT_CHANGE_TYPE;
|
cmds[index + 3] = Ev3Args.DO_NOT_CHANGE_TYPE;
|
||||||
cmds[index + 4] = Ev3Mode[this._sensorPorts[i]];
|
cmds[index + 4] = Ev3Mode[this._sensorPorts[i]];
|
||||||
cmds[index + 5] = Ev3ParamEncoding.GLOBAL_ONE_BYTE;
|
cmds[index + 5] = Ev3Encoding.GLOBAL_VARIABLE_ONE_BYTE;
|
||||||
cmds[index + 6] = sensorCount * 4; // GLOBAL INDEX
|
cmds[index + 6] = sensorCount * 4; // GLOBAL INDEX
|
||||||
index += 7;
|
index += 7;
|
||||||
}
|
}
|
||||||
|
@ -770,7 +769,7 @@ class EV3 {
|
||||||
cmds[index + 0] = Ev3Opcode.OPOUTPUT_GET_COUNT;
|
cmds[index + 0] = Ev3Opcode.OPOUTPUT_GET_COUNT;
|
||||||
cmds[index + 1] = Ev3Args.LAYER;
|
cmds[index + 1] = Ev3Args.LAYER;
|
||||||
cmds[index + 2] = i; // PORT (incorrectly specified as 'Output bit field' in LEGO docs)
|
cmds[index + 2] = i; // PORT (incorrectly specified as 'Output bit field' in LEGO docs)
|
||||||
cmds[index + 3] = Ev3ParamEncoding.GLOBAL_ONE_BYTE;
|
cmds[index + 3] = Ev3Encoding.GLOBAL_VARIABLE_ONE_BYTE;
|
||||||
cmds[index + 4] = sensorCount * 4; // GLOBAL INDEX
|
cmds[index + 4] = sensorCount * 4; // GLOBAL INDEX
|
||||||
index += 5;
|
index += 5;
|
||||||
sensorCount++;
|
sensorCount++;
|
||||||
|
|
Loading…
Reference in a new issue