Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
681fdf1b
Commit
681fdf1b
authored
Jul 20, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lint corrections.
parent
4a1bdb5a
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
48 additions
and
41 deletions
+48
-41
blockly/blocks/arduino/map.js
blockly/blocks/arduino/map.js
+2
-4
blockly/blocks/arduino/procedures.js
blockly/blocks/arduino/procedures.js
+5
-5
blockly/blocks/arduino/serial.js
blockly/blocks/arduino/serial.js
+13
-7
blockly/blocks/arduino/servo.js
blockly/blocks/arduino/servo.js
+11
-6
blockly/blocks/arduino/variables.js
blockly/blocks/arduino/variables.js
+3
-1
blockly/blocks/variables.js
blockly/blocks/variables.js
+4
-8
blockly/generators/arduino/logic.js
blockly/generators/arduino/logic.js
+2
-2
blockly/generators/arduino/loops.js
blockly/generators/arduino/loops.js
+4
-4
blockly/generators/arduino/map.js
blockly/generators/arduino/map.js
+1
-1
blockly/generators/arduino/math.js
blockly/generators/arduino/math.js
+1
-1
blockly/generators/arduino/text.js
blockly/generators/arduino/text.js
+1
-1
blockly/generators/arduino/time.js
blockly/generators/arduino/time.js
+1
-1
No files found.
blockly/blocks/arduino/map.js
View file @
681fdf1b
...
...
@@ -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
;
}
...
...
blockly/blocks/arduino/procedures.js
View file @
681fdf1b
...
...
@@ -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
;
}
...
...
blockly/blocks/arduino/serial.js
View file @
681fdf1b
...
...
@@ -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
'
);
...
...
blockly/blocks/arduino/servo.js
View file @
681fdf1b
...
...
@@ -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
'
);
...
...
blockly/blocks/arduino/variables.js
View file @
681fdf1b
...
...
@@ -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
()
{
...
...
blockly/blocks/variables.js
View file @
681fdf1b
...
...
@@ -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
;
},
/**
...
...
blockly/generators/arduino/logic.js
View file @
681fdf1b
...
...
@@ -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
];
};
blockly/generators/arduino/loops.js
View file @
681fdf1b
...
...
@@ -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 ?
'
+
...
...
blockly/generators/arduino/map.js
View file @
681fdf1b
...
...
@@ -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
];
};
blockly/generators/arduino/math.js
View file @
681fdf1b
...
...
@@ -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
'
;
...
...
blockly/generators/arduino/text.js
View file @
681fdf1b
blockly/generators/arduino/time.js
View file @
681fdf1b
...
...
@@ -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
'
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment