Commit 681fdf1b authored by carlosperate's avatar carlosperate

Lint corrections.

parent 4a1bdb5a
......@@ -15,6 +15,7 @@ goog.provide('Blockly.Blocks.Arduino.map');
goog.require('Blockly.Arduino');
/** Common HSV hue for all blocks in this category. */
Blockly.Blocks.Arduino.map.HUE = 230;
Blockly.Blocks['base_map'] = {
......@@ -37,10 +38,7 @@ Blockly.Blocks['base_map'] = {
this.setOutput(true);
this.setTooltip('Re-maps a number from [0-1024] to another range.');
},
/**
* Assigns a type to the block, the current map implementation for Arduino
* takes the inputs a longs and returns a long, so automatic cast to int.
*/
/** @return {string} The type of return value for the block, an integer. */
getType: function() {
return Blockly.StaticTyping.blocklyType.INTEGER;
}
......
......@@ -25,11 +25,11 @@ Blockly.Blocks['arduino_functions'] = {
*/
init: function() {
this.appendDummyInput()
.appendField("Arduino run once:");
this.appendStatementInput("SETUP_FUNC");
.appendField('Arduino run once:');
this.appendStatementInput('SETUP_FUNC');
this.appendDummyInput()
.appendField("Arduino loop forever:");
this.appendStatementInput("LOOP_FUNC");
.appendField('Arduino loop forever:');
this.appendStatementInput('LOOP_FUNC');
this.setInputsInline(false);
this.setColour(Blockly.Blocks.Arduino.procedures.HUE);
this.setTooltip('Defines the Arduino setup() and loop() functions.');
......@@ -40,7 +40,7 @@ Blockly.Blocks['arduino_functions'] = {
// Remove all options from the original reference (=[] won't work)
options.splice(0, options.length);
},
/** @return True if the a block instance is present in the workspace */
/** @return {!boolean} True if the block instance is in the workspace. */
getArduinoLoopsInstance: function() {
return true;
}
......
......@@ -46,9 +46,12 @@ Blockly.Blocks['serial_setup'] = {
* @this Blockly.Block
*/
getSerialSetupInstance: function() {
return this.getFieldValue('SERIAL_ID');;
return this.getFieldValue('SERIAL_ID');
},
/** Updates the content of the the serial related fields. */
/**
* Updates the content of the the serial related fields.
* @this Blockly.Block
*/
updateFields: function() {
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERIAL_ID', 'serial');
......@@ -72,8 +75,8 @@ Blockly.Blocks['serial_print'] = {
this.appendValueInput('CONTENT', Blockly.StaticTyping.blocklyType.TEXT)
.setCheck(Blockly.StaticTyping.blocklyType.TEXT);
this.appendDummyInput()
.appendField(new Blockly.FieldCheckbox("TRUE"), "NEW_LINE")
.appendField("add new line");
.appendField(new Blockly.FieldCheckbox('TRUE'), 'NEW_LINE')
.appendField('add new line');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
......@@ -107,13 +110,16 @@ Blockly.Blocks['serial_print'] = {
if (!setupInstancePresent) {
this.setWarningText(
'A setup block for '+ thisInstanceName + ' must be added to the ' +
'A setup block for ' + thisInstanceName + ' must be added to the ' +
'workspace to use this block!', 'serial_setup');
} else {
this.setWarningText(null, 'serial_setup');
}
},
/** Updates the content of the the serial related fields. */
/**
* Updates the content of the the serial related fields.
* @this Blockly.Block
*/
updateFields: function() {
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERIAL_ID', 'serial');
......
......@@ -15,7 +15,8 @@ goog.provide('Blockly.Blocks.Arduino.servo');
goog.require('Blockly.Arduino');
Blockly.Blocks.Arduino.servo.HUE = 50;
/** Common HSV hue for all blocks in this category. */
Blockly.Blocks.Arduino.servo.HUE = 60;
Blockly.Blocks['servo_write'] = {
/**
......@@ -41,7 +42,10 @@ Blockly.Blocks['servo_write'] = {
this.setNextStatement(true, null);
this.setTooltip('Set a Servo to an specified angle');
},
/** Updates the content of the the pin related fields. */
/**
* Updates the content of the the pin related fields.
* @this Blockly.Block
*/
updateFields: function() {
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERVO_PIN', 'pwmPins');
......@@ -63,13 +67,14 @@ Blockly.Blocks['servo_read'] = {
this.setOutput(true, Blockly.StaticTyping.blocklyType.NUMBER);
this.setTooltip('Read a Servo angle');
},
/**
* Retrieves the type of the block, in this case an integer.
*/
/** @return {string} The type of return value for the block, an integer. */
getType: function() {
return Blockly.StaticTyping.blocklyType.INTEGER;
},
/** Updates the content of the the pin related fields. */
/**
* Updates the content of the the pin related fields.
* @this Blockly.Block
*/
updateFields: function() {
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERVO_PIN', 'pwmPins');
......
......@@ -15,6 +15,7 @@ goog.provide('Blockly.Blocks.Arduino.variables');
goog.require('Blockly.Arduino');
/** Common HSV hue for all blocks in this category. */
Blockly.Blocks.Arduino.variables.HUE = 330;
Blockly.Blocks['variables_set_type'] = {
......@@ -37,6 +38,7 @@ Blockly.Blocks['variables_set_type'] = {
},
/**
* Assigns a type to the block based on the selected type to cast.
* @return {!string} Blockly type for this block configuration.
* @this Blockly.Block
*/
getType: function() {
......
......@@ -91,14 +91,11 @@ Blockly.Blocks['variables_get'] = {
* Finds the type of the selected variable.
* @this Blockly.Block
* @param {Array<string>} existingVars Associative array of variables already
* defined. Var names as key and type as
* value.
* @return {string} String to indicate the type if it has not been defined
* before.
* defined. Var names as key and type as value.
* @return {string} String to indicate the type if not defined before.
*/
getVarType: function(existingVars) {
var varName = this.getFieldValue('VAR');
// Check if variable has been defined already add if it has been.
var varType = Blockly.StaticTyping.findListVarType(varName, existingVars);
if (varType != null) {
......@@ -106,10 +103,9 @@ Blockly.Blocks['variables_get'] = {
this.setWarningText(null);
} else {
// This block needs the variable to be define before use, so warn user.
this.setWarningText('This variable needs to be set to something before' +
' it can be used!');
this.setWarningText(
'This variable needs to be set to something before it can be used!');
}
return varType;
},
/**
......
......@@ -122,7 +122,7 @@ Blockly.Arduino['logic_boolean'] = function(block) {
*/
Blockly.Arduino['logic_null'] = function(block) {
var code = 'NULL';
return [code ,Blockly.Arduino.ORDER_ATOMIC];
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
/**
......@@ -138,6 +138,6 @@ Blockly.Arduino['logic_ternary'] = function(block) {
Blockly.Arduino.ORDER_CONDITIONAL) || 'null';
var valueElse = Blockly.Arduino.valueToCode(block, 'ELSE',
Blockly.Arduino.ORDER_CONDITIONAL) || 'null';
var code = valueIf + ' ? ' + valueThen + ' : ' + valueElse
var code = valueIf + ' ? ' + valueThen + ' : ' + valueElse;
return [code, Blockly.Arduino.ORDER_CONDITIONAL];
};
......@@ -4,7 +4,7 @@
*
* @fileoverview Generating Arduino code for the loop blocks.
*
* TODO: For each block needs to have lists implemented.
* TODO: 'For each' block needs to have lists implemented.
*/
'use strict';
......@@ -142,7 +142,7 @@ Blockly.Arduino['controls_for'] = function(block) {
code += 'abs(' + increment + ');\n';
}
code += 'if (' + startVar + ' > ' + endVar + ') {\n';
code += Blockly.Arduino.INDENT + incVar + ' = -' + incVar +';\n';
code += Blockly.Arduino.INDENT + incVar + ' = -' + incVar + ';\n';
code += '}\n';
code += 'for (' + variable0 + ' = ' + startVar + ';\n' +
' ' + incVar + ' >= 0 ? ' +
......
......@@ -25,6 +25,6 @@ Blockly.Arduino['base_map'] = function(block) {
var valueDmax = Blockly.Arduino.valueToCode(
block, 'DMAX', Blockly.Arduino.ORDER_ATOMIC) || '0';
var code = 'map(' + valueNum +', 0, 1024, 0, ' + valueDmax + ')';
var code = 'map(' + valueNum + ', 0, 1024, 0, ' + valueDmax + ')';
return [code, Blockly.Arduino.ORDER_NONE];
};
......@@ -214,7 +214,7 @@ Blockly.Arduino['math_number_property'] = function(block) {
break;
case 'WHOLE':
Blockly.Arduino.addInclude('math', '#include <math.h>');
code = '(floor(' + number_to_check + ') == ' + number_to_check +')';
code = '(floor(' + number_to_check + ') == ' + number_to_check + ')';
break;
case 'POSITIVE':
code = number_to_check + ' > 0';
......
......@@ -68,5 +68,5 @@ goog.require('Blockly.Arduino');
* @return {string} Completed code.
*/
Blockly.Arduino['infinite_loop'] = function(block) {
return 'while(true);';
return 'while(true);\n';
};
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