123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- 'use strict';
- goog.provide('Blockly.Blocks.serial');
- goog.require('Blockly.Blocks');
- goog.require('Blockly.Types');
- Blockly.Blocks.serial.HUE = 80;
- Blockly.Blocks['serial_setup'] = {
-
- init: function() {
- this.setHelpUrl('http://arduino.cc/en/Serial/Begin');
- this.setColour(Blockly.Blocks.serial.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.ARD_SERIAL_SETUP)
- .appendField(
- new Blockly.FieldDropdown(
- Blockly.Python.Boards.selected.serial.concat([
- ["serial1", "Serial1"]
- ])), 'SERIAL_ID')
- .appendField(Blockly.Msg.ARD_SERIAL_SPEED)
- .appendField(
- new Blockly.FieldDropdown(
- [
- ["9600", "9600"],
- ["115200", "115200"]
- ]), 'SPEED')
- .appendField(Blockly.Msg.ARD_SERIAL_BPS);
- this.setInputsInline(true);
- this.setTooltip(Blockly.Msg.ARD_SERIAL_SETUP_TIP);
- },
-
- getSerialSetupInstance: function() {
- return this.getFieldValue('SERIAL_ID');
- },
-
- updateFields: function() {
- Blockly.Python.Boards.refreshBlockFieldDropdown(
- this, 'SERIAL_ID', 'serial');
- Blockly.Python.Boards.refreshBlockFieldDropdown(
- this, 'SPEED', 'serialSpeed');
- }
- };
- Blockly.Blocks['serial_print'] = {
-
- init: function() {
- this.setHelpUrl('http://www.arduino.cc/en/Serial/Print');
- this.setColour(Blockly.Blocks.serial.HUE);
- this.appendDummyInput()
- .appendField(new Blockly.FieldDropdown(
- Blockly.Python.Boards.selected.serial), 'SERIAL_ID')
- .appendField(Blockly.Msg.ARD_SERIAL_PRINT);
- this.appendValueInput('CONTENT')
- .setCheck(null);
- this.appendDummyInput()
- .appendField(new Blockly.FieldCheckbox('TRUE'), 'NEW_LINE')
- .appendField(Blockly.Msg.ARD_SERIAL_PRINT_NEWLINE);
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setTooltip(Blockly.Msg.ARD_SERIAL_PRINT_TIP);
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- updateFields: function() {
- Blockly.Python.Boards.refreshBlockFieldDropdown(
- this, 'SERIAL_ID', 'serial');
- }
- };
- Blockly.Blocks['serial1_write'] = {
-
- init: function() {
- this.setHelpUrl('http://www.arduino.cc/en/Serial/Write');
- this.setColour(Blockly.Blocks.serial.HUE);
- this.appendDummyInput()
- .appendField(new Blockly.FieldDropdown(
- [
- ["serial1", "Serial1"]
- ]), 'SERIAL_ID')
- .appendField(Blockly.Msg.ARD_SERIAL_WRITE);
- this.appendValueInput('CONTENT')
- .setCheck(null);
-
-
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setTooltip(Blockly.Msg.ARD_SERIAL_PRINT_TIP);
- },
- }
- Blockly.Blocks['serial1_read'] = {
-
- init: function() {
- this.setHelpUrl('http://www.arduino.cc/en/Serial/Read');
- this.setColour(Blockly.Blocks.serial.HUE);
- this.appendDummyInput()
- .appendField(new Blockly.FieldDropdown(
- [
- ["serial1", "Serial1"]
- ]), 'SERIAL_ID')
- .appendField(Blockly.Msg.ARD_SERIAL_READ);
-
-
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setTooltip(Blockly.Msg.ARD_SERIAL_PRINT_TIP);
- },
- }
- Blockly.Blocks['serial1_available'] = {
-
- init: function() {
- this.setColour(Blockly.Blocks.serial.HUE);
- this.appendDummyInput()
- .appendField(new Blockly.FieldDropdown(
- [
- ["serial1", "Serial1"]
- ]), 'SERIAL_ID')
- .appendField(Blockly.Msg.ARD_SERIAL_AVAILABLE);
- this.setOutput(true);
- this.setTooltip(Blockly.Msg.ARD_SERIAL_PRINT_TIP);
- },
- }
|