Skip to content

Commit

Permalink
type of rduino base blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SebCanet committed Aug 19, 2016
1 parent ac2438c commit 24819a9
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 353 deletions.
306 changes: 0 additions & 306 deletions blocks/arduino_base/arduino_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,312 +197,6 @@ Blockly.Blocks.various_constrain = {
}
};

Blockly.Blocks.inout_buildin_led = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_BUILDIN_LED_HELPURL);
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_BUILDIN_LED_INPUT)
.appendField(new Blockly.FieldDropdown(Blockly.Msg.FIELDDROPDOWN), 'STAT');
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_BUILDIN_LED_TOOLTIP);
}
};

Blockly.Blocks.inout_pulsein = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl('http://arduino.cc/en/Reference/pulseIn');
this.appendValueInput("PIN")
.setCheck("Number")
.appendField(Blockly.Msg.ARDUINO_PULSEIN);
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_STAT)
.appendField(new Blockly.FieldDropdown(Blockly.Msg.FIELDDROPDOWN), 'STAT');
this.setInputsInline(true);
this.setOutput(true, 'Number');
this.setTooltip('Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.');
}
};

Blockly.Blocks.inout_pulsein_timeout = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl('http://arduino.cc/en/Reference/pulseIn');
this.appendValueInput("PIN")
.setCheck("Number")
.appendField(Blockly.Msg.ARDUINO_PULSEIN);
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_STAT)
.appendField(new Blockly.FieldDropdown(Blockly.Msg.FIELDDROPDOWN), 'STAT');
this.appendValueInput("TIMEOUT")
.setCheck("Number")
.appendField(Blockly.Msg.ARDUINO_PULSEIN_TIMEOUT);
this.setInputsInline(true);
this.setOutput(true, 'Number');
this.setTooltip('Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.');
}
};

Blockly.Blocks.inout_digital_write_validator = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_HELPURL);
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_INPUT1)
.appendField(new Blockly.FieldTextInput('', Blockly.Arduino.pinDigitalValidator), 'PIN');
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_INPUT2)
.appendField(new Blockly.FieldDropdown(Blockly.Msg.FIELDDROPDOWN), 'STAT');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_TOOLTIP);
}
};

Blockly.Blocks.inout_digital_write = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.setCheck('Number')
.appendField(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_INPUT1);
this.setInputsInline(true);
this.appendValueInput("STAT", 'Boolean')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_INPUT2);
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_DIGITAL_WRITE_TOOLTIP);
}
};

Blockly.Blocks.inout_digital_read = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_DIGITAL_READ_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_DIGITAL_READ_INPUT);
this.setOutput(true, 'Boolean');
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_DIGITAL_READ_TOOLTIP);
}
};

Blockly.Blocks.inout_digital_read_validator = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_DIGITAL_READ_HELPURL);
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_DIGITAL_READ_INPUT)
.appendField(new Blockly.FieldTextInput('', Blockly.Arduino.pinDigitalValidator), 'PIN');
this.setInputsInline(true);
this.setOutput(true,'Boolean');
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_DIGITAL_READ_TOOLTIP);
}
};

Blockly.Blocks.inout_PWM_write_validator = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_HELPURL);
this.appendDummyInput("")
.appendField(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_INPUT1)
.appendField(new Blockly.FieldTextInput('', Blockly.Arduino.pinPWMValidator), 'PIN');
this.appendValueInput("NUM", 'Number')
.appendField(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_INPUT2)
.setCheck('Number');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_TOOLTIP);
}
};

Blockly.Blocks.inout_PWM_write = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_INPUT1);
this.appendValueInput("NUM", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_INPUT2)
.setCheck('Number');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_PWM_WRITE_TOOLTIP);
}
};

Blockly.Blocks.inout_analog_write = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_INPUT1);
this.appendValueInput("NUM", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_INPUT2)
.setCheck('Number');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_TOOLTIP);
}
};

Blockly.Blocks.inout_analog_write_validator = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_HELPURL);
this.appendDummyInput("")
.appendField(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_INPUT1)
.appendField(new Blockly.FieldTextInput('', Blockly.Arduino.pinAnalogValidator), 'PIN');
this.appendValueInput("NUM", 'Number')
.appendField(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_INPUT2)
.setCheck('Number');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_ANALOG_WRITE_TOOLTIP);
}
};

Blockly.Blocks.tone = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_TONE_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_TONE_INPUT1);
this.appendValueInput("NUM", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_TONE_INPUT2)
.setCheck('Number');
this.appendValueInput("TPS", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_TONE_INPUT3)
.setCheck('Number');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_TONE_TOOLTIP);
}
};

Blockly.Blocks.notone = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_NOTONE_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_NOTONE_INPUT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.ARDUINO_NOTONE_TOOLTIP);
}
};

Blockly.Blocks.inout_analog_read = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_ANALOG_READ_HELPURL);
this.appendValueInput("PIN", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.ARDUINO_INOUT_ANALOG_READ_INPUT);
this.setOutput(true, 'Number');
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_ANALOG_READ_TOOLTIP);
}
};

Blockly.Blocks.inout_analog_read_validator = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_ANALOG_READ_HELPURL);
this.appendDummyInput()
.appendField(Blockly.Msg.ARDUINO_INOUT_ANALOG_READ_INPUT)
.appendField(new Blockly.FieldTextInput('', Blockly.Arduino.pinAnalogValidator), 'PIN');
this.setOutput(true, 'Number');
this.setTooltip(Blockly.Msg.ARDUINO_INOUT_ANALOG_READ_TOOLTIP);
}
};

Blockly.Blocks['inout_onoff'] = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_ONOFF_HELPURL);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Blockly.Msg.FIELDDROPDOWN), 'BOOL');
this.setOutput(true,'Boolean');
this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP);
}
};

Blockly.Blocks.inout_angle = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl('https://developers.google.com/blockly/custom-blocks/defining-blocks#appendfield');
this.appendDummyInput("")
.appendField("angle")
.appendField(new Blockly.FieldAngle("90"), "ANGLE");
this.setOutput(true, "Number");
this.setTooltip('angle °');
}
};

Blockly.Blocks.inout_angle_maths = {
init: function() {
this.setColour("#5CB712");
this.setHelpUrl('https://developers.google.com/blockly/custom-blocks/defining-blocks#appendfield');
this.appendDummyInput("")
.appendField("angle")
.appendField(new Blockly.FieldAngle("90"), "ANGLE");
this.setOutput(true, "Number");
this.setTooltip('angle °');
}
};


Blockly.Blocks.inout_attachInterrupt = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl('https://www.arduino.cc/en/Reference/AttachInterrupt');
this.appendDummyInput("")
.appendField(Blockly.Msg.LKL_ATTACHINTERRUPT_PIN)
.appendField(new Blockly.FieldDropdown(profile.defaultBoard.interrupt), 'PIN');
this.appendDummyInput("")
.appendField(Blockly.Msg.LKL_MODE)
.appendField(new Blockly.FieldDropdown(Blockly.Msg.LKL_DROPDOWN), "mode");
this.appendStatementInput('DO')
.appendField(Blockly.Msg.CONTROLS_SWITCH_MSG_DO);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.LKL_TOOLTIP_INOUT_ATTACHINTERRUPT);
}
};

Blockly.Blocks.inout_detachInterrupt = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl('https://www.arduino.cc/en/Reference/DetachInterrupt');
this.appendDummyInput("")
.appendField(Blockly.Msg.LKL_DETACHINTERRUPT_PIN)
.appendField(new Blockly.FieldTextInput('', Blockly.Arduino.pinInterruptValidator), 'PIN');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.LKL_TOOLTIP_INOUT_DETACHINTERRUPT);
}
};

Blockly.Blocks['biblio_include'] = {
init: function() {
this.appendDummyInput()
Expand Down
14 changes: 4 additions & 10 deletions blocks/arduino_base/arduino_conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@
*/
'use strict';

goog.provide('Blockly.Blocks.conversion');

goog.require('Blockly.Blocks');

Blockly.Blocks.conversion.HUE = "#00979D";

Blockly.Blocks['conversion_tochar'] = {
init: function() {
this.setColour(Blockly.Blocks.conversion.HUE);
this.setColour("#00979D");
this.appendValueInput("NAME", 'Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.CONV_tochar);
Expand All @@ -44,7 +38,7 @@ Blockly.Blocks['conversion_tochar'] = {

Blockly.Blocks['conversion_tobyte'] = {
init: function() {
this.setColour(Blockly.Blocks.conversion.HUE);
this.setColour("#00979D");
this.appendValueInput("NAME", 'Number')
.appendField(Blockly.Msg.CONV_tobyte);
this.setOutput(true, 'Number');
Expand All @@ -55,7 +49,7 @@ Blockly.Blocks['conversion_tobyte'] = {

Blockly.Blocks['conversion_toint'] = {
init: function() {
this.setColour(Blockly.Blocks.conversion.HUE);
this.setColour("#00979D");
this.appendValueInput("NAME", 'Number')
.appendField(Blockly.Msg.CONV_toint);
this.setOutput(true, 'Number');
Expand All @@ -66,7 +60,7 @@ Blockly.Blocks['conversion_toint'] = {

Blockly.Blocks['conversion_tofloat'] = {
init: function() {
this.setColour(Blockly.Blocks.conversion.HUE);
this.setColour("#00979D");
this.appendValueInput("NAME", 'Number')
.appendField(Blockly.Msg.CONV_tofloat);
this.setOutput(true, 'Number');
Expand Down
15 changes: 1 addition & 14 deletions blocks/arduino_base/arduino_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Blockly.Blocks.inout_analog_read_validator = {
}
};

Blockly.Blocks['inout_onoff'] = {
Blockly.Blocks.inout_onoff = {
init: function() {
this.setColour("#00979D");
this.setHelpUrl(Blockly.Msg.ARDUINO_INOUT_ONOFF_HELPURL);
Expand All @@ -286,19 +286,6 @@ Blockly.Blocks.inout_angle = {
}
};

Blockly.Blocks.inout_angle_maths = {
init: function() {
this.setColour("#5CB712");
this.setHelpUrl('https://developers.google.com/blockly/custom-blocks/defining-blocks#appendfield');
this.appendDummyInput("")
.appendField("angle")
.appendField(new Blockly.FieldAngle("90"), "ANGLE");
this.setOutput(true, "Number");
this.setTooltip('angle °');
}
};


Blockly.Blocks.inout_attachInterrupt = {
init: function() {
this.setColour("#00979D");
Expand Down
Loading

0 comments on commit 24819a9

Please sign in to comment.