Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components #76

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e586dc7
a componentfieldvariable dropdown field that allows to filter
bmcage Apr 29, 2016
bb59cba
convert stepper to new componentfield
bmcage Apr 29, 2016
fc4cfee
step 2 stepper: generator
bmcage Apr 30, 2016
e258e1e
create a generic test if setup block of a component is present
bmcage Apr 30, 2016
8160857
Fix issues with menu generations: should be class method
bmcage Apr 30, 2016
64ff54a
Improvements: less code needed, better documentation
bmcage May 6, 2016
9494c22
Allow blocks to automatically set correct board.
bmcage May 5, 2016
4b68174
A warning message for blocks that set the board
bmcage May 5, 2016
30e234b
dutch translation of block
bmcage May 5, 2016
5dee899
Implementation of component block, starting with adaptation of the
bmcage May 7, 2016
deeff0d
Light components: normal LED leg and neopixel strip
bmcage May 8, 2016
61fbc59
servo as components
bmcage May 8, 2016
aa42403
component: new text strings
bmcage May 7, 2016
1910ef2
light translation strings
bmcage May 8, 2016
4d5bea2
servo component language strings
bmcage May 8, 2016
8437af2
Don't include strings of Blockly4Arduino
bmcage May 8, 2016
6fbf003
adaptation of GUI to expose the new blocks
bmcage May 8, 2016
a2da103
avoid double pinMode setting
bmcage May 9, 2016
834cbdf
Add generic analog sensor component
bmcage May 9, 2016
900eeab
reservePin must be done with numbers, not varnames
bmcage May 9, 2016
fb60ba4
component for a digital input
bmcage May 9, 2016
557b674
Add a button component, and a way to handle button presses
bmcage May 9, 2016
6bbd130
digital input translate strings
bmcage May 9, 2016
6106c34
add missing translation
bmcage May 9, 2016
b17babc
digital and pwm output components
bmcage May 9, 2016
9233d2b
bugfix: correct default pwm name
bmcage May 9, 2016
96a49d3
Update ardublockly GUI with the new components
bmcage May 9, 2016
8dbf15b
Language updates
bmcage May 9, 2016
4fea5df
bugfix: en translation
bmcage May 9, 2016
d43daf8
bugfix: correct remembering of pin blocks if mutator is changed
bmcage May 11, 2016
dabd7bf
bugfix: digitalread must be BOOLEAN
bmcage May 12, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bugfix: correct remembering of pin blocks if mutator is changed
  • Loading branch information
bmcage committed May 11, 2016
commit d43daf8faf621a27494aa5fb252aff9a16fbafd7
58 changes: 39 additions & 19 deletions blockly/blocks/arduino/components.js
Original file line number Diff line number Diff line change
@@ -79,10 +79,10 @@ Blockly.Blocks['core_hub_component'] = {

if (otherBoardPresent) {
// Set a warning to select a valid stepper config
this.setWarningText(Blockly.Msg.ARD_BOARD_WARN.replace('%1', Blockly.Msg.ARD_COMPONENT_BOARD));
this.setWarningText(Blockly.Msg.ARD_BOARD_WARN.replace('%1', Blockly.Msg.ARD_COMPONENT_BOARD), 'board');
} else {
Blockly.Arduino.Boards.changeBoard(this.workspace, this.getBoardName());
this.setWarningText(null);
this.setWarningText(null, 'board');
}
},
/**
@@ -110,7 +110,7 @@ Blockly.Blocks['core_hub_component'] = {
return container;
},
/**
* Parse XML to restore the else-if and else inputs.
* Parse XML to restore the pin inputs.
* @param {!Element} xmlElement XML storage element.
* @this Blockly.Block
*/
@@ -193,27 +193,34 @@ Blockly.Blocks['core_hub_component'] = {
*/
compose: function(containerBlock) {
// Disconnect all the digpin input blocks and remove the inputs.
var oldInputs = {}
for (var i = this.digCount_; i > 0; i--) {
oldInputs['DIG' + i] = this.getFieldValue('PIND' + i);
this.removeInput('DIG' + i);
}
this.digCount_ = 0;
// Disconnect all the anapin input blocks and remove the inputs.
for (var i = this.anaCount_; i > 0; i--) {
oldInputs['ANA' + i] = this.getFieldValue('PINA' + i);
this.removeInput('ANA' + i);
}
this.anaCount_ = 0;
// Disconnect all the pwmpin input blocks and remove the inputs.
for (var i = this.pwmCount_; i > 0; i--) {
oldInputs['PWM' + i] = this.getFieldValue('PINP' + i);
this.removeInput('PWM' + i);
}
this.pwmCount_ = 0;
// Disconnect all the double digpin input blocks and remove the inputs.
for (var i = this.digdigCount_; i > 0; i--) {
oldInputs['DIGDIG' + i] = [this.getFieldValue('PINDD1_' + i),
this.getFieldValue('PINDD2_' + i)];
this.removeInput('DIGDIG' + i);
}
this.digdigCount_ = 0;
// Rebuild the block's optional inputs.
var clauseBlock = containerBlock.nextConnection.targetBlock();
console.log('inputs', oldInputs);
while (clauseBlock) {
switch (clauseBlock.type) {
case 'core_hub_digpin':
@@ -223,8 +230,11 @@ Blockly.Blocks['core_hub_component'] = {
.appendField(Blockly.Msg.ARD_PIN_DIG)
.appendField(new Blockly.FieldDropdown(Blockly.Arduino.Boards.selected.digitalPins), "PIND" + this.digCount_)
.setAlign(Blockly.ALIGN_RIGHT);
if (clauseBlock.valueConnection_) {
digInput.connection.connect(clauseBlock.valueConnection_);
if (! (oldInputs['DIG' + this.digCount_] == undefined)) {
this.setFieldValue(oldInputs['DIG' + this.digCount_], "PIND" + this.digCount_);
}
if (clauseBlock.valueDConnection_) {
digInput.connection.connect(clauseBlock.valueDConnection_);
}
break;
case 'core_hub_anapin':
@@ -234,8 +244,11 @@ Blockly.Blocks['core_hub_component'] = {
.appendField(Blockly.Msg.ARD_PIN_AN)
.appendField(new Blockly.FieldDropdown(Blockly.Arduino.Boards.selected.analogPins), "PINA" + this.anaCount_)
.setAlign(Blockly.ALIGN_RIGHT);
if (clauseBlock.valueConnection_) {
anaInput.connection.connect(clauseBlock.valueConnection_);
if (! (oldInputs['ANA' + this.anaCount_] == undefined)) {
this.setFieldValue(oldInputs['ANA' + this.anaCount_], "PINA" + this.anaCount_);
}
if (clauseBlock.valueAConnection_) {
anaInput.connection.connect(clauseBlock.valueAConnection_);
}
break;
case 'core_hub_pwmpin':
@@ -245,21 +258,28 @@ Blockly.Blocks['core_hub_component'] = {
.appendField(Blockly.Msg.ARD_PIN_PWM)
.appendField(new Blockly.FieldDropdown(Blockly.Arduino.Boards.selected.pwmPins), "PINP" + this.pwmCount_)
.setAlign(Blockly.ALIGN_RIGHT);
if (clauseBlock.valueConnection_) {
pwmInput.connection.connect(clauseBlock.valueConnection_);
if (! (oldInputs['PWM' + this.pwmCount_] == undefined)) {
this.setFieldValue(oldInputs['PWM' + this.pwmCount_], "PINP" + this.pwmCount_);
}
if (clauseBlock.valuePConnection_) {
pwmInput.connection.connect(clauseBlock.valuePConnection_);
}
break;
case 'core_hub_digdigpin':
this.digdigCount_++;
var digInput = this.appendValueInput('DIGDIG' + this.digCount_)
var digInput = this.appendValueInput('DIGDIG' + this.digdigCount_)
.setCheck(["HUB_DIGDIG"])
.appendField(Blockly.Msg.ARD_PIN_DIGDIG1)
.appendField(new Blockly.FieldDropdown(Blockly.Arduino.Boards.selected.digitalPins), "PINDD1_" + this.digdigCount_)
.appendField(Blockly.Msg.ARD_PIN_DIGDIG2)
.appendField(new Blockly.FieldDropdown(Blockly.Arduino.Boards.selected.digitalPins), "PINDD2_" + this.digdigCount_)
.setAlign(Blockly.ALIGN_RIGHT);
if (clauseBlock.valueConnection_) {
digInput.connection.connect(clauseBlock.valueConnection_);
if (! (oldInputs['DIGDIG' + this.digdigCount_] == undefined)) {
this.setFieldValue(oldInputs['DIGDIG' + this.digdigCount_][0], "PINDD1_" + this.digdigCount_);
this.setFieldValue(oldInputs['DIGDIG' + this.digdigCount_][1], "PINDD2_" + this.digdigCount_);
}
if (clauseBlock.valueDDConnection_) {
digInput.connection.connect(clauseBlock.valueDDConnection_);
}
break;
default:
@@ -281,26 +301,26 @@ Blockly.Blocks['core_hub_component'] = {
switch (clauseBlock.type) {
case 'core_hub_digpin':
var inputDig = this.getInput('DIG' + i);
clauseBlock.valueConnection_ =
clauseBlock.valueDConnection_ =
inputDig && inputDig.connection.targetConnection;
i++;
break;
case 'core_hub_anapin':
var inputAna = this.getInput('ANA' + j);
clauseBlock.valueConnection_ =
clauseBlock.valueAConnection_ =
inputAna && inputAna.connection.targetConnection;
j++;
break;
case 'core_hub_pwmpin':
var inputPwm = this.getInput('ANA' + k);
clauseBlock.valueConnection_ =
var inputPwm = this.getInput('PWM' + k);
clauseBlock.valuePConnection_ =
inputPwm && inputPwm.connection.targetConnection;
k++;
break;
case 'core_hub_digdigpin':
var inputDig = this.getInput('DIGDIG' + ii);
clauseBlock.valueConnection_ =
inputDig && inputDig.connection.targetConnection;
var inputDigDig = this.getInput('DIGDIG' + ii);
clauseBlock.valueDDConnection_ =
inputDigDig && inputDigDig.connection.targetConnection;
ii++;
break;
default: