Skip to content

Commit

Permalink
Merge pull request #185 from MatzElectronics/bp-1697-addPrefixToXbeeN…
Browse files Browse the repository at this point in the history
…amedConstPins

Add prefix to defined constants
  • Loading branch information
pjewald authored Aug 20, 2019
2 parents bebabac + 1aad4cf commit 3adc844
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions blockly/generators/propc/communicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2398,14 +2398,18 @@ Blockly.Blocks.xbee_setup = {

Blockly.propc.xbee_setup = function () {
if (!this.disabled) {
var mv = ['DI_PIN', 'DO_PIN', 'BAUD'];
var m = [];
for (var i = 0; i < 3; i++) {
m.push(this.getFieldValue(mv[i]));
if (i === 1) {
m.push('0');
}
var di_pin = this.getFieldValue('DI_PIN');
var do_pin = this.getFieldValue('DO_PIN');

if (profile.default.digital.toString().indexOf(di_pin + ',' + di_pin) === -1) {
di_pin = 'MY_' + di_pin;
}
if (profile.default.digital.toString().indexOf(do_pin + ',' + do_pin) === -1) {
do_pin = 'MY_' + do_pin;
}

var m = [di_pin, do_pin, '0', this.getFieldValue('BAUD')];

Blockly.propc.definitions_["include fdserial"] = '#include "fdserial.h"';
Blockly.propc.global_vars_["xbee"] = "fdserial *xbee;";
Blockly.propc.setups_["xbee"] = 'xbee = fdserial_open(' + m.join(',') + ');';
Expand Down

0 comments on commit 3adc844

Please sign in to comment.