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
c19569e8
Commit
c19569e8
authored
Jul 12, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix stepper block (was using depreciated interpolateMsg).
parent
71573290
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
34 deletions
+50
-34
ardublockly/ardublockly_toolbox.xml
ardublockly/ardublockly_toolbox.xml
+0
-5
blockly/blocks/arduino/stepper.js
blockly/blocks/arduino/stepper.js
+48
-25
blockly/generators/arduino/stepper.js
blockly/generators/arduino/stepper.js
+2
-4
No files found.
ardublockly/ardublockly_toolbox.xml
View file @
c19569e8
...
@@ -174,11 +174,6 @@
...
@@ -174,11 +174,6 @@
<field
name=
"NUM"
>
10
</field>
<field
name=
"NUM"
>
10
</field>
</block>
</block>
</value>
</value>
<value
name=
"STEPPER_NAME"
>
<block
type=
"text"
>
<field
name=
"TEXT"
>
MyStepper
</field>
</block>
</value>
</block>
</block>
<block
type=
"stepper_step"
>
<block
type=
"stepper_step"
>
<value
name=
"STEPPER_STEPS"
>
<value
name=
"STEPPER_STEPS"
>
...
...
blockly/blocks/arduino/stepper.js
View file @
c19569e8
...
@@ -96,23 +96,23 @@ Blockly.Blocks['stepper_config'] = {
...
@@ -96,23 +96,23 @@ Blockly.Blocks['stepper_config'] = {
this
.
setHelpUrl
(
'
http://arduino.cc/en/Reference/StepperConstructor
'
);
this
.
setHelpUrl
(
'
http://arduino.cc/en/Reference/StepperConstructor
'
);
this
.
setColour
(
Blockly
.
Blocks
.
Arduino
.
stepper
.
HUE
);
this
.
setColour
(
Blockly
.
Blocks
.
Arduino
.
stepper
.
HUE
);
this
.
appendDummyInput
()
this
.
appendDummyInput
()
.
appendField
(
'
Configure STEPPER:
'
);
.
appendField
(
"
setup stepper
"
)
.
appendField
(
new
Blockly
.
FieldTextInput
(
"
MyStepper
"
),
'
STEPPER_NAME
'
);
this
.
appendDummyInput
()
this
.
appendDummyInput
()
.
appendField
(
'
PIN
1#
'
)
.
appendField
(
'
pin
1#
'
)
.
appendField
(
new
Blockly
.
FieldDropdown
(
profile
.
default
.
digital
),
.
appendField
(
new
Blockly
.
FieldDropdown
(
profile
.
default
.
digital
),
'
STEPPER_PIN1
'
)
'
STEPPER_PIN1
'
)
.
appendField
(
'
PIN
2#
'
)
.
appendField
(
'
pin
2#
'
)
.
appendField
(
new
Blockly
.
FieldDropdown
(
profile
.
default
.
digital
),
.
appendField
(
new
Blockly
.
FieldDropdown
(
profile
.
default
.
digital
),
'
STEPPER_PIN2
'
);
'
STEPPER_PIN2
'
);
this
.
appendValueInput
(
'
STEPPER_STEPS
'
)
this
.
appendValueInput
(
'
STEPPER_STEPS
'
)
.
setCheck
(
Blockly
.
StaticTyping
.
blocklyType
.
NUMBER
)
.
setCheck
(
Blockly
.
StaticTyping
.
blocklyType
.
NUMBER
)
.
appendField
(
'
Steps in one revolution
'
);
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
.
appendField
(
'
steps in one revolution
'
);
this
.
appendValueInput
(
'
STEPPER_SPEED
'
)
this
.
appendValueInput
(
'
STEPPER_SPEED
'
)
.
setCheck
(
Blockly
.
StaticTyping
.
blocklyType
.
NUMBER
)
.
setCheck
(
Blockly
.
StaticTyping
.
blocklyType
.
NUMBER
)
.
appendField
(
'
Set speed to
'
);
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
this
.
appendValueInput
(
'
STEPPER_NAME
'
)
.
appendField
(
'
set speed to
'
);
.
setCheck
(
Blockly
.
StaticTyping
.
blocklyType
.
TEXT
)
.
appendField
(
'
Set name to
'
);
this
.
setTooltip
(
'
Configures a stepper motor pinout and other settings
'
);
this
.
setTooltip
(
'
Configures a stepper motor pinout and other settings
'
);
},
},
/**
/**
...
@@ -122,14 +122,12 @@ Blockly.Blocks['stepper_config'] = {
...
@@ -122,14 +122,12 @@ Blockly.Blocks['stepper_config'] = {
* @this Blockly.Block
* @this Blockly.Block
*/
*/
getStepperInstance
:
function
()
{
getStepperInstance
:
function
()
{
var
InstanceName
=
null
;
var
InstanceName
=
this
.
getFieldValue
(
'
STEPPER_NAME
'
);
var
instanceNameBlock
=
this
.
getInputTargetBlock
(
'
STEPPER_NAME
'
);
if
(
!
InstanceName
)
{
if
(
!
instanceNameBlock
)
{
InstanceName
=
Blockly
.
Blocks
.
Arduino
.
stepper
.
noName
;
InstanceName
=
Blockly
.
Blocks
.
Arduino
.
stepper
.
noName
;
}
else
{
InstanceName
=
instanceNameBlock
.
getFieldValue
(
'
TEXT
'
);
}
}
return
InstanceName
;
// Replace all spaces with underscores
return
InstanceName
.
replace
(
/ /g
,
'
_
'
);;
}
}
};
};
...
@@ -141,18 +139,43 @@ Blockly.Blocks['stepper_step'] = {
...
@@ -141,18 +139,43 @@ Blockly.Blocks['stepper_step'] = {
init
:
function
()
{
init
:
function
()
{
this
.
setHelpUrl
(
'
http://arduino.cc/en/Reference/StepperStep
'
);
this
.
setHelpUrl
(
'
http://arduino.cc/en/Reference/StepperStep
'
);
this
.
setColour
(
Blockly
.
Blocks
.
Arduino
.
stepper
.
HUE
);
this
.
setColour
(
Blockly
.
Blocks
.
Arduino
.
stepper
.
HUE
);
this
.
interpolateMsg
(
this
.
appendDummyInput
()
// TODO: Combine these messages instead of using concatenation.
.
appendField
(
'
stepper
'
)
'
STEPPER
'
+
'
%1
'
+
.
appendField
(
new
Blockly
.
Blocks
.
Arduino
.
stepper
.
FieldStepperInstance
(),
'
move
'
+
'
%2
'
+
'
steps
'
,
'
STEPPER_NAME
'
);
[
'
STEPPER_NAME
'
,
this
.
appendValueInput
(
'
STEPPER_STEPS
'
)
new
Blockly
.
Blocks
.
Arduino
.
stepper
.
FieldStepperInstance
()],
.
setCheck
(
Blockly
.
StaticTyping
.
blocklyType
.
NUMBER
)
[
'
STEPPER_STEPS
'
,
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
Blockly
.
StaticTyping
.
blocklyType
.
NUMBER
,
Blockly
.
ALIGN_RIGHT
],
.
appendField
(
'
move
'
);
Blockly
.
ALIGN_RIGHT
);
this
.
appendDummyInput
()
.
appendField
(
'
steps
'
);
this
.
setPreviousStatement
(
true
);
this
.
setPreviousStatement
(
true
);
this
.
setNextStatement
(
true
);
this
.
setNextStatement
(
true
);
this
.
setTooltip
(
'
Turns the stepper motor a specific number of steps.
'
);
this
.
setTooltip
(
'
Turns the stepper motor a specific number of steps.
'
);
/* For now the FieldStepperInstance is required, will need to replicate
functionality for JSON implementation.
this.jsonInit({
"message0": "stepper %1 move %2 steps",
"args0": [
{
"type": "field_dropdown",
"name": "STEPPER_NAME",
"options": Blockly.Blocks.Arduino.stepper.stepperDropdownList()
},
{
"type": "input_value",
"name": "STEPPER_STEPS",
"align": "RIGHT"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Blocks.Arduino.stepper.HUE,
"tooltip": "Turns the stepper motor a specific number of steps.",
"helpUrl": "http://arduino.cc/en/Reference/StepperStep"
});*/
},
},
/**
/**
* Called whenever anything on the workspace changes.
* Called whenever anything on the workspace changes.
...
@@ -206,8 +229,8 @@ Blockly.Blocks['stepper_step'] = {
...
@@ -206,8 +229,8 @@ Blockly.Blocks['stepper_step'] = {
this
.
setFieldValue
(
instances
[
0
][
0
],
'
STEPPER_NAME
'
);
this
.
setFieldValue
(
instances
[
0
][
0
],
'
STEPPER_NAME
'
);
this
.
setWarningText
(
null
);
this
.
setWarningText
(
null
);
}
else
{
}
else
{
// Al this point just set a waning to select a valid stepper config
// Al this point just set a wa
r
ning to select a valid stepper config
this
.
setWarningText
(
'
Selected stepper does not exist anymore,
'
+
this
.
setWarningText
(
'
Selected stepper does not exist any
more,
'
+
'
please select a new one.
'
);
'
please select a new one.
'
);
}
}
}
}
...
...
blockly/generators/arduino/stepper.js
View file @
c19569e8
...
@@ -77,11 +77,9 @@ Blockly.Arduino['stepper_config'] = function(block) {
...
@@ -77,11 +77,9 @@ Blockly.Arduino['stepper_config'] = function(block) {
* @return {array} Completed code with order of operation.
* @return {array} Completed code with order of operation.
*/
*/
Blockly
.
Arduino
[
'
stepper_step
'
]
=
function
(
block
)
{
Blockly
.
Arduino
[
'
stepper_step
'
]
=
function
(
block
)
{
var
stepperInstance
=
block
.
getFieldValue
(
'
STEPPER_NAME
'
);
var
stepperInstance
Name
=
block
.
getFieldValue
(
'
STEPPER_NAME
'
)
var
stepperSteps
=
Blockly
.
Arduino
.
valueToCode
(
block
,
'
STEPPER_STEPS
'
,
var
stepperSteps
=
Blockly
.
Arduino
.
valueToCode
(
block
,
'
STEPPER_STEPS
'
,
Blockly
.
Arduino
.
ORDER_ATOMIC
)
||
'
0
'
;
Blockly
.
Arduino
.
ORDER_ATOMIC
)
||
'
0
'
;
var
code
=
''
;
var
code
=
stepperInstanceName
+
'
.steps(
'
+
stepperSteps
+
'
);
\n
'
;
code
=
stepperInstance
+
'
.steps(
'
+
stepperSteps
+
'
);
\n
'
;
return
code
;
return
code
;
};
};
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