Commit 22f92e77 authored by Carlos Pereira Atencio's avatar Carlos Pereira Atencio Committed by carlospamg

Fix bug where Arduino variables were renamed with a new distinct name. Also...

Fix bug where Arduino variables were renamed with a new distinct name. Also slght modifications to the arduino board types and profiles.
parent 8f1892a0
...@@ -70,27 +70,30 @@ Blockly.Arduino.ORDER_NONE = 99; // (...) ...@@ -70,27 +70,30 @@ Blockly.Arduino.ORDER_NONE = 99; // (...)
*/ */
var profile = { var profile = {
arduino: { arduino: {
description: "Arduino standard-compatible board", description: "Arduino Uno standard-compatible board",
digital : [["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]], digital : [["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
analog : [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]], analog : [["A0", "A0"], ["A1", "A1"]],
serial : 9600 interrupt: [["Int_1", "1"], ["Int_2", "2"], ["Int_3", "3"], ["Int_4", "4"], ["Int_5", "5"]],
serial : [["300", "300"], ["600", "600"], ["1200", "1200"], ["2400", "2400"], ["4800", "4800"],["9600", "9600"], ["14400", "14400"], ["19200", "19200"], ["28800", "28800"], ["31250", "31250"], ["38400", "38400"],["57600", "57600"], ["115200", "115200"]],
}, },
arduino_mega:{ arduino_mega:{
description: "Arduino Mega-compatible board" description: "Arduino Mega-compatible board"
//53 digital //53 digital
//15 analog //15 analog
//6 interrupts
//same serial
}, },
//Behind the Wire Arduino profile arduino_leonardo:{
arduino_btw: { description: "Arduino Leonardo-compatible board"
description: "Arduino Behind The Wire", //18 digital
digital : [["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]], //6 analog
analog : [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]], //5 interrupts
serial : 9600 //same serial
} }
} }
//set default profile to arduino standard-compatible board //set default profile to arduino standard-compatible board
profile["default"] = profile["arduino_btw"]; profile["default"] = profile["arduino"];
//alert(profile.default.digital[0]);
/** /**
* Initialise the database of variable names. * Initialise the database of variable names.
...@@ -113,8 +116,8 @@ Blockly.Arduino.init = function() { ...@@ -113,8 +116,8 @@ Blockly.Arduino.init = function() {
var variables = Blockly.Variables.allVariables(); var variables = Blockly.Variables.allVariables();
for (var x = 0; x < variables.length; x++) { for (var x = 0; x < variables.length; x++) {
defvars[x] = 'int ' + defvars[x] = 'int ' +
Blockly.Arduino.variableDB_.getDistinctName(variables[x], Blockly.Arduino.variableDB_.getName(variables[x],
Blockly.Variables.NAME_TYPE) + ';\n'; Blockly.Variables.NAME_TYPE);
} }
Blockly.Arduino.definitions_['variables'] = defvars.join('\n'); Blockly.Arduino.definitions_['variables'] = defvars.join('\n');
} }
...@@ -133,7 +136,6 @@ Blockly.Arduino.finish = function(code) { ...@@ -133,7 +136,6 @@ Blockly.Arduino.finish = function(code) {
// Convert the definitions dictionary into a list. // Convert the definitions dictionary into a list.
var imports = []; var imports = [];
//var imports = ["#include <BehindTheWire.h>\n"];
var definitions = []; var definitions = [];
for (var name in Blockly.Arduino.definitions_) { for (var name in Blockly.Arduino.definitions_) {
var def = Blockly.Arduino.definitions_[name]; var def = Blockly.Arduino.definitions_[name];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment