Updated Arduino app to include Arduino code generation.

parent e5899d56
......@@ -30,10 +30,9 @@
<script type="text/javascript" src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../generators/arduino.js"></script>
<script type="text/javascript" src="../../generators/arduino/base.js"></script>
<script type="text/javascript" src="../../generators/arduino/control.js"></script>
<script type="text/javascript" src="../../generators/arduino/logic.js"></script>
<!--script type="text/javascript" src="../../generators/arduino/loops.js"></script-->
<script type="text/javascript" src="../../generators/arduino/loops.js"></script>
<script type="text/javascript" src="../../generators/arduino/math.js"></script>
<script type="text/javascript" src="../../generators/arduino/text.js"></script>
<script type="text/javascript" src="../../generators/arduino/lists.js"></script>
......
......@@ -42,7 +42,7 @@ var Code = {};
* List of tab names.
* @private
*/
Code.TABS_ = ['blocks', 'javascript', 'python', 'dart', 'xml'];
Code.TABS_ = ['blocks', 'arduino', 'javascript', 'python', 'dart', 'xml'];
Code.selected = 'blocks';
......@@ -101,6 +101,14 @@ Code.renderContent = function() {
var xmlText = Blockly.Xml.domToPrettyText(xmlDom);
xmlTextarea.value = xmlText;
xmlTextarea.focus();
} else if (content.id == 'content_arduino') {
var code = Blockly.Arduino.workspaceToCode();
content.textContent = code;
if (typeof prettyPrintOne == 'function') {
code = content.innerHTML;
code = prettyPrintOne(code, 'js');
content.innerHTML = code;
}
} else if (content.id == 'content_javascript') {
var code = Blockly.JavaScript.workspaceToCode();
content.textContent = code;
......
......@@ -5,7 +5,7 @@ if (typeof apps == 'undefined') { var apps = {}; }
apps.messages = function(opt_data, opt_ignored, opt_ijData) {
return '<div style="display: none"><span id="subtitle">a visual programming environment</span><span id="blocklyMessage">Blockly</span><span id="codeTooltip">See generated JavaScript code.</span><span id="linkTooltip">Save and link to blocks.</span><span id="runTooltip">Run the program defined by the blocks in the workspace.</span><span id="runProgram">Run Program</span><span id="resetProgram">Reset</span><span id="dialogOk">OK</span><span id="dialogCancel">Cancel</span><span id="catLogic">Logic</span><span id="catLoops">Loops</span><span id="catMath">Math</span><span id="catText">Text</span><span id="catLists">Lists</span><span id="catColour">Colour</span><span id="catVariables">Variables</span><span id="catProcedures">Functions</span><span id="httpRequestError">There was a problem with the request.</span><span id="linkAlert">Share your blocks with this link:\n\n%1</span><span id="hashError">Sorry, \'%1\' doesn\'t correspond with any saved program.</span><span id="xmlError">Could not load your saved file. Perhaps it was created with a different version of Blockly?</span><span id="listVariable">list</span><span id="textVariable">text</span></div>';
return '<div style="display: none"><span id="subtitle">a visual programming environment</span><span id="blocklyMessage">Blockly</span><span id="codeTooltip">See generated JavaScript code.</span><span id="linkTooltip">Save and link to blocks.</span><span id="runTooltip">Run the program defined by the blocks in the workspace.</span><span id="runProgram">Run Program</span><span id="resetProgram">Reset</span><span id="dialogOk">OK</span><span id="dialogCancel">Cancel</span><span id="catLogic">Logic</span><span id="catLoops">Loops</span><span id="catMath">Math</span><span id="catText">Text</span><span id="catLists">Lists</span><span id="catColour">Colour</span><span id="catVariables">Variables</span><span id="catProcedures">Functions</span><span id="httpRequestError">There was a problem with the request.</span><span id="linkAlert">Share your blocks with this link:\\n\\n%1</span><span id="hashError">Sorry, \'%1\' doesn\'t correspond with any saved program.</span><span id="xmlError">Could not load your saved file. Perhaps it was created with a different version of Blockly?</span><span id="listVariable">list</span><span id="textVariable">text</span></div>';
};
......@@ -36,12 +36,12 @@ if (typeof codepage == 'undefined') { var codepage = {}; }
codepage.messages = function(opt_data, opt_ignored, opt_ijData) {
return apps.messages(null, null, opt_ijData) + '<div style="display: none"><span id="Code_badXml">Error parsing XML:\n%1\n\nSelect \'OK\' to abandon your changes or \'Cancel\' to further edit the XML.</span><span id="Code_badCode">Program error:\n%1</span><span id="Code_timeout">Maximum execution iterations exceeded.</span><span id="Code_discard">Delete all %1 blocks?</span></div>';
return apps.messages(null, null, opt_ijData) + '<div style="display: none"><span id="Code_badXml">Error parsing XML:\\n%1\\n\\nSelect \'OK\' to abandon your changes or \'Cancel\' to further edit the XML.</span><span id="Code_badCode">Program error:\\n%1</span><span id="Code_timeout">Maximum execution iterations exceeded.</span><span id="Code_discard">Delete all %1 blocks?</span></div>';
};
codepage.start = function(opt_data, opt_ignored, opt_ijData) {
return codepage.messages(null, null, opt_ijData) + '<script type="text/javascript" src="../../blockly_compressed.js"><\/script><script type="text/javascript" src="../../blocks_compressed.js"><\/script><script type="text/javascript" src="../../javascript_compressed.js"><\/script><script type="text/javascript" src="../../python_compressed.js"><\/script><script type="text/javascript" src="../../dart_compressed.js"><\/script><script type="text/javascript" src="../../' + soy.$$escapeHtml(opt_ijData.langSrc) + '"><\/script><table width="100%" height="100%"><tr><td><h1><span id="title"><a href="../index.html?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '">Blockly</a> : Code</span></h1></td><td class="farSide"><select id="languageMenu"></select></td></tr><tr><td colspan=2><table width="100%"><tr id="tabRow" height="1em"><td id="tab_blocks" class="tabon">Blocks</td><td class="tabmin">&nbsp;</td><td id="tab_javascript" class="taboff">JavaScript</td><td class="tabmin">&nbsp;</td><td id="tab_python" class="taboff">Python</td><td class="tabmin">&nbsp;</td><td id="tab_dart" class="taboff">Dart</td><td class="tabmin">&nbsp;</td><td id="tab_xml" class="taboff">XML</td><td class="tabmax"><button id="trashButton" class="notext" title="Discard all blocks."><img src=\'../../media/1x1.gif\' class="trash icon21"></button> <button id="linkButton" class="notext" title="Save and link to blocks."><img src=\'../../media/1x1.gif\' class="link icon21"></button> <button id="runButton" class="notext primary" title="Run the program defined by the blocks in the workspace."><img src=\'../../media/1x1.gif\' class="run icon21"></button></td></tr></table></td></tr><tr><td height="99%" colspan=2 id="content_area">' + codepage.toolbox(null, null, opt_ijData) + '</td></tr></table><div id="content_blocks" class="content"></div><pre id="content_javascript" class="content"></pre><pre id="content_python" class="content"></pre><pre id="content_dart" class="content"></pre><textarea id="content_xml" class="content" wrap="off"></textarea>' + apps.dialog(null, null, opt_ijData) + apps.storageDialog(null, null, opt_ijData);
return codepage.messages(null, null, opt_ijData) + '<script type="text/javascript" src="../../blockly_compressed.js"><\/script><script type="text/javascript" src="../../blocks_compressed.js"><\/script><script type="text/javascript" src="../../generators/arduino.js"><\/script><script type="text/javascript" src="../../generators/arduino/colour.js"><\/script><script type="text/javascript" src="../../generators/arduino/lists.js"><\/script><script type="text/javascript" src="../../generators/arduino/logic.js"><\/script><script type="text/javascript" src="../../generators/arduino/loops.js"><\/script><script type="text/javascript" src="../../generators/arduino/math.js"><\/script><script type="text/javascript" src="../../generators/arduino/procedures.js"><\/script><script type="text/javascript" src="../../generators/arduino/text.js"><\/script><script type="text/javascript" src="../../generators/arduino/variables.js"><\/script><script type="text/javascript" src="../../javascript_compressed.js"><\/script><script type="text/javascript" src="../../python_compressed.js"><\/script><script type="text/javascript" src="../../dart_compressed.js"><\/script><script type="text/javascript" src="../../' + soy.$$escapeHtml(opt_ijData.langSrc) + '"><\/script><table width="100%" height="100%"><tr><td><h1><span id="title"><a href="../index.html?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '">Blockly</a> : Code</span></h1></td><td class="farSide"><select id="languageMenu"></select></td></tr><tr><td colspan=2><table width="100%"><tr id="tabRow" height="1em"><td id="tab_blocks" class="tabon">Blocks</td><td class="tabmin">&nbsp;</td><td id="tab_arduino" class="taboff">Arduino</td><td class="tabmin">&nbsp;</td><td id="tab_javascript" class="taboff">JavaScript</td><td class="tabmin">&nbsp;</td><td id="tab_python" class="taboff">Python</td><td class="tabmin">&nbsp;</td><td id="tab_dart" class="taboff">Dart</td><td class="tabmin">&nbsp;</td><td id="tab_xml" class="taboff">XML</td><td class="tabmax"><button id="trashButton" class="notext" title="Discard all blocks."><img src=\'../../media/1x1.gif\' class="trash icon21"></button> <button id="linkButton" class="notext" title="Save and link to blocks."><img src=\'../../media/1x1.gif\' class="link icon21"></button> <button id="runButton" class="notext primary" title="Run the program defined by the blocks in the workspace."><img src=\'../../media/1x1.gif\' class="run icon21"></button></td></tr></table></td></tr><tr><td height="99%" colspan=2 id="content_area">' + codepage.toolbox(null, null, opt_ijData) + '</td></tr></table><div id="content_blocks" class="content"></div><pre id="content_arduino" class="content"></pre><pre id="content_javascript" class="content"></pre><pre id="content_python" class="content"></pre><pre id="content_dart" class="content"></pre><textarea id="content_xml" class="content" wrap="off"></textarea>' + apps.dialog(null, null, opt_ijData) + apps.storageDialog(null, null, opt_ijData);
};
......
......@@ -29,6 +29,15 @@
{call .messages /}
<script type="text/javascript" src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../generators/arduino.js"></script>
<script type="text/javascript" src="../../generators/arduino/colour.js"></script>
<script type="text/javascript" src="../../generators/arduino/lists.js"></script>
<script type="text/javascript" src="../../generators/arduino/logic.js"></script>
<script type="text/javascript" src="../../generators/arduino/loops.js"></script>
<script type="text/javascript" src="../../generators/arduino/math.js"></script>
<script type="text/javascript" src="../../generators/arduino/procedures.js"></script>
<script type="text/javascript" src="../../generators/arduino/text.js"></script>
<script type="text/javascript" src="../../generators/arduino/variables.js"></script>
<script type="text/javascript" src="../../javascript_compressed.js"></script>
<script type="text/javascript" src="../../python_compressed.js"></script>
<script type="text/javascript" src="../../dart_compressed.js"></script>
......@@ -56,6 +65,8 @@
<tr id="tabRow" height="1em">
<td id="tab_blocks" class="tabon">{{msg meaning="Code.blocks" desc="tab text - Displays and allows editing of the user's program as blocks.\n{lb}{lb}Identical|Blocks{rb}{rb}"}}Blocks{{/msg}}</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_arduino" class="taboff">Arduino</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_javascript" class="taboff">JavaScript</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_python" class="taboff">Python</td>
......@@ -85,6 +96,7 @@
</tr>
</table>
<div id="content_blocks" class="content"></div>
<pre id="content_arduino" class="content"></pre>
<pre id="content_javascript" class="content"></pre>
<pre id="content_python" class="content"></pre>
<pre id="content_dart" class="content"></pre>
......
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