Commit 966546b4 authored by carlosperate's avatar carlosperate

Added infinite loop block to end arduino program.

parent 47a96cc4
......@@ -144,6 +144,7 @@
</block>
<block type="time_millis"></block>
<block type="time_micros"></block>
<block type="infinite_loop"></block>
</category>
<sep></sep>
<category name="Motors">
......
......@@ -136,6 +136,7 @@
</block>
<block type="time_millis"></block>
<block type="time_micros"></block>
<block type="infinite_loop"></block>
</category>
<category name="Motors">
<block type="servo_write">
......
......@@ -100,3 +100,19 @@ Blockly.Blocks['time_micros'] = {
return 'int';
}
};
Blockly.Blocks['infinite_loop'] = {
/**
* Waits forever, end of program.
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl('');
this.setColour(Blockly.Blocks.Arduino.time.HUE);
this.appendDummyInput()
.appendField("wait forever (end program)");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setTooltip('Wait indefinitely, stopping the program.');
}
};
......@@ -60,3 +60,13 @@ goog.require('Blockly.Arduino');
var code = 'micros()';
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
/**
* Code generator for the wait forever (end of program) block
* Arduino code: loop { while(true); }
* @param {!Blockly.Block} block Block to generate the code from.
* @return {string} Completed code.
*/
Blockly.Arduino['infinite_loop'] = function(block) {
return 'while(true);';
};
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