Skip to content

Commit 07ef1ad

Browse files
authored
Merge pull request #534 from parallaxinc/release-1.5.7
Release 1.5.7
2 parents 633e97d + 6302293 commit 07ef1ad

File tree

10 files changed

+630
-560
lines changed

10 files changed

+630
-560
lines changed

package-lock.json

+31-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"homepage": "https://github.com/parallaxinc/solo#readme",
2929
"dependencies": {
30-
"@sentry/browser": "^5.25.0",
30+
"@sentry/browser": "^5.29.2",
3131
"ace-builds": "^1.4.8",
3232
"blockly": "^2.20190722.1",
3333
"bootbox": "^5.4.0",

src/modules/blockly/generators/propc.js

+6
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ Blockly.propc.addReservedWords(
399399
'ws2812_set,ws2812_start,ws2812_stop,ws2812_wheel,ws2812_wheel_dim,' +
400400
'ws2812b_open,ws2812b_start');
401401

402+
/**
403+
* SD File reserved words
404+
*/
405+
Blockly.propc.addReservedWords(
406+
'fp,fclose,fopen,fread,fseek,ftell,fwrite,sd_init,sd_mount,');
407+
402408
/**
403409
* Order of operation ENUMs.
404410
*

src/modules/blockly/generators/propc/communicate.js

+41-27
Original file line numberDiff line numberDiff line change
@@ -836,23 +836,23 @@ Blockly.propc.console_print_multiple = function() {
836836
orIt = '0';
837837
}
838838

839+
// Get the resulting code from Blockly core
840+
const result = Blockly.propc.valueToCode(
841+
this, 'PRINT' + i, Blockly.propc.ORDER_NONE) || orIt;
842+
839843
if (!this.getFieldValue('TYPE' + i).includes('float point divide by')) {
840-
varList += ', ' + (Blockly.propc.valueToCode(
841-
this,
842-
'PRINT' + i,
843-
Blockly.propc.ORDER_NONE).replace(/%/g, '%%') || orIt);
844+
varList += ', ' + result;
844845
} else {
845-
varList += ', ((float) ' + (Blockly.propc.valueToCode(
846-
this,
847-
'PRINT' + i,
848-
Blockly.propc.ORDER_NONE) || orIt) +
849-
') / ' + this.getFieldValue('DIV' + i) + '.0';
846+
varList += ', ((float) ' + result + ') / ' +
847+
this.getFieldValue('DIV' + i) + '.0';
850848
}
851849
i++;
852850
}
851+
853852
if (this.getFieldValue('ck_nl') === 'TRUE') {
854853
code += '\\r';
855854
}
855+
856856
code += '"' + varList + ');\n';
857857

858858
// TODO: Replace .getAllBlocks() with getAllBlocksByType()
@@ -1527,46 +1527,60 @@ Blockly.Blocks.serial_receive_text = {
15271527
onchange: Blockly.Blocks['serial_send_text'].onchange,
15281528
};
15291529

1530+
15301531
/**
15311532
* Serial Receive Text code generator
15321533
* @return {string}
1534+
* @description Generate C source code to scan data from a serial port input.
15331535
*/
15341536
Blockly.propc.serial_receive_text = function() {
15351537
let p = '';
1538+
1539+
/* Is a serial pin defined? */
15361540
if (this.ser_pins.length > 0) {
1537-
p = this.ser_pins[0].replace(',', '_').replace(/None/g, 'N');
1541+
p = this.ser_pins[0]
1542+
.replace(',', '_') // Replace commas with underscores
1543+
.replace(/None/g, 'N'); // Replace 'None' with 'N' in all occurrences.
15381544
}
1545+
1546+
/* Get serial pins in use */
15391547
if (this.getInput('SERPIN')) {
15401548
p = this.getFieldValue('SER_PIN')
15411549
.replace(',', '_')
15421550
.replace(/None/g, 'N');
15431551
}
1544-
const allBlocks = Blockly.getMainWorkspace().getAllBlocks().toString();
1545-
if (allBlocks.indexOf('Serial initialize') === -1) {
1552+
1553+
if (! Blockly.getMainWorkspace()
1554+
.getBlocksByType('Serial initialize', false)) {
15461555
return '// ERROR: Serial is not initialized!\n';
15471556
} else {
1548-
const data = Blockly.propc.variableDB_.getName(
1549-
this.getFieldValue('VALUE'),
1550-
Blockly.VARIABLE_CATEGORY_NAME);
1557+
const data = Blockly.propc.variableDB_
1558+
.getName(this.getFieldValue('VALUE'), Blockly.VARIABLE_CATEGORY_NAME);
15511559

1552-
const type = this.getFieldValue('TYPE');
1560+
switch (this.getFieldValue('TYPE')) {
1561+
case 'BYTE':
1562+
return data + ' = fdserial_rxChar(fdser' + p + ');\n';
15531563

1554-
if (type === 'BYTE') {
1555-
return data + ' = fdserial_rxChar(fdser' + p + ');\n';
1556-
} else if (type === 'INT') {
1557-
return 'dscan(fdser' + p + ', "%d", &' + data + ');\n';
1558-
} else if (type === 'BIN') {
1559-
return 'dscan(fdser' + p + ', "%b", &' + data + ');\n';
1560-
} else if (type === 'HEX') {
1561-
return 'dscan(fdser' + p + ', "%x", &' + data + ');\n';
1562-
} else {
1563-
Blockly.propc.vartype_[data] = 'char *';
1564+
case 'INT':
1565+
return 'dscan(fdser' + p + ', "%d", &' + data + ');\n';
1566+
1567+
case 'BIN':
1568+
return 'dscan(fdser' + p + ', "%b", &' + data + ');\n';
1569+
1570+
case 'HEX':
1571+
return 'dscan(fdser' + p + ', "%x", &' + data + ');\n';
15641572

1565-
return 'dscan(fdser' + p + ', "%s", ' + data + ');\n';
1573+
case 'TEXT':
1574+
default:
1575+
Blockly.propc.vartype_[data] = 'char *';
15661576
}
1577+
1578+
// This will return a string up to the first whitespace character.
1579+
return 'dscan(fdser' + p + ', "%s", ' + data + ');\n';
15671580
}
15681581
};
15691582

1583+
15701584
/**
15711585
* Serial Status block definition
15721586
* @type {{

0 commit comments

Comments
 (0)