From fd33225d2da3d2c261b97c903c5c84d0d28dd4ca Mon Sep 17 00:00:00 2001 From: roboticafacil Date: Tue, 12 Dec 2017 18:30:08 +0100 Subject: [PATCH 1/4] modified: lars_blocks.js --- lars_blocks.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lars_blocks.js b/lars_blocks.js index 9643e4b..fc2297b 100644 --- a/lars_blocks.js +++ b/lars_blocks.js @@ -17,6 +17,22 @@ Blockly.Blocks['LARS_init'] = { } } +Blockly.Arduino['LARS_init'] = function(block) { + var code=''; + var input_FRH = Blockly.Arduino.valueToCode(this,'FRH',Blockly.Arduino.ORDER_ATOMIC) || '26'; + var input_FLH = Blockly.Arduino.valueToCode(this,'FLH',Blockly.Arduino.ORDER_ATOMIC) || '25'; + var input_BRH = Blockly.Arduino.valueToCode(this,'BRH',Blockly.Arduino.ORDER_ATOMIC) || '17'; + var input_BLH = Blockly.Arduino.valueToCode(this,'BLH',Blockly.Arduino.ORDER_ATOMIC) || '16'; + var input_FRL = Blockly.Arduino.valueToCode(this,'FRL',Blockly.Arduino.ORDER_ATOMIC) || '27'; + var input_FLL = Blockly.Arduino.valueToCode(this,'FLL',Blockly.Arduino.ORDER_ATOMIC) || '5'; + var input_BRL = Blockly.Arduino.valueToCode(this,'BRL',Blockly.Arduino.ORDER_ATOMIC) || '23'; + var input_BLL = Blockly.Arduino.valueToCode(this,'BLL',Blockly.Arduino.ORDER_ATOMIC) || '13'; + Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include '; + Blockly.Arduino.definitions_['declare_var_define_lars']='LARS lars;\n'; + Blockly.Arduino.setups_['setup_lars_init'] = 'lars.init('+input_FRH+','+input_FLH+','+input_BRH+','+input_BLH+','+input_FRL+','+input_FLL+','+input_BRL+','+input_BLL+');\n'; + return code; + }; + Blockly.Arduino['LARS_movement'] = function() { var code=''; var movement = this.getFieldValue('MOVEMENT'); From 21db36369b1bb549475db0b82956f3e4b7e67b2f Mon Sep 17 00:00:00 2001 From: roboticafacil Date: Tue, 12 Dec 2017 19:00:58 +0100 Subject: [PATCH 2/4] modified: lars_blocks.js --- lars_blocks.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lars_blocks.js b/lars_blocks.js index fc2297b..84521b0 100644 --- a/lars_blocks.js +++ b/lars_blocks.js @@ -4,18 +4,27 @@ Facilino.LANG_COLOUR_MOVEMENT_WALK = '#8D8D25'; Blockly.Blocks['LARS_init'] = { category: Facilino.locales.getKey('LANG_CATEGORY_MOVEMENT'), subcategory: Facilino.locales.getKey('LANG_SUBCATEGORY_WALK'), - helpUrl: Facilino.getHelpUrl('LARS_init'), category_colour: Facilino.LANG_COLOUR_MOVEMENT, colour: Facilino.LANG_COLOUR_MOVEMENT_WALK, + helpUrl: Facilino.getHelpUrl('LARS_init'), tags: [], examples: [], init: function () { + this.appendDummyInput('').appendField(new Blockly.FieldImage('img/blocks/LARS.svg', 32*options.zoom, 32*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_ROBOT')); + this.appendValueInput('FRH').appendField(new Blockly.FieldImage('img/blocks/LARS_FRH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FRH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('FLH').appendField(new Blockly.FieldImage('img/blocks/LARS_FLH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FLH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BRH').appendField(new Blockly.FieldImage('img/blocks/LARS_BRH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BRH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BLH').appendField(new Blockly.FieldImage('img/blocks/LARS_BLH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BLH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('FRL').appendField(new Blockly.FieldImage('img/blocks/LARS_FRL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FRL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('FLL').appendField(new Blockly.FieldImage('img/blocks/LARS_FLL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FLL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BRL').appendField(new Blockly.FieldImage('img/blocks/LARS_BRL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BRL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BLL').appendField(new Blockly.FieldImage('img/blocks/LARS_BLL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BLL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); this.setPreviousStatement(true,'code'); this.setNextStatement(true,'code'); this.setColour(Facilino.LANG_COLOUR_MOVEMENT_WALK); this.setTooltip(Facilino.locales.getKey('LANG_LARS_INIT_TOOLTIP')); } -} +}; Blockly.Arduino['LARS_init'] = function(block) { var code=''; From 89f1d579b3f561763ce7d0fd83db39d14dcc5586 Mon Sep 17 00:00:00 2001 From: roboticafacil Date: Tue, 12 Dec 2017 19:06:22 +0100 Subject: [PATCH 3/4] modified: lars_blocks.js --- lars_blocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lars_blocks.js b/lars_blocks.js index 84521b0..bd9a666 100644 --- a/lars_blocks.js +++ b/lars_blocks.js @@ -36,7 +36,7 @@ Blockly.Arduino['LARS_init'] = function(block) { var input_FLL = Blockly.Arduino.valueToCode(this,'FLL',Blockly.Arduino.ORDER_ATOMIC) || '5'; var input_BRL = Blockly.Arduino.valueToCode(this,'BRL',Blockly.Arduino.ORDER_ATOMIC) || '23'; var input_BLL = Blockly.Arduino.valueToCode(this,'BLL',Blockly.Arduino.ORDER_ATOMIC) || '13'; - Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include '; + Blockly.Arduino.definitions_['define_lars_h'] = '#include '; Blockly.Arduino.definitions_['declare_var_define_lars']='LARS lars;\n'; Blockly.Arduino.setups_['setup_lars_init'] = 'lars.init('+input_FRH+','+input_FLH+','+input_BRH+','+input_BLH+','+input_FRL+','+input_FLL+','+input_BRL+','+input_BLL+');\n'; return code; From d6f4e775b2fca38eb015246eaaf11f504ddf7ebf Mon Sep 17 00:00:00 2001 From: roboticafacil Date: Tue, 12 Dec 2017 19:12:39 +0100 Subject: [PATCH 4/4] modified: lang/LARS.json modified: lars_blocks.js --- lang/LARS.json | 10 ++++++++++ lars_blocks.js | 46 +++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/lang/LARS.json b/lang/LARS.json index 4b76305..c643d5c 100644 --- a/lang/LARS.json +++ b/lang/LARS.json @@ -5,6 +5,16 @@ { "keys": { + "LANG_SUBCATEGORY_WALK": "Robot walk", + "LANG_MOVEMENT_LARS_ROBOT": "Define robot", + "LANG_MOVEMENT_LARS_FRH": "Hip 1", + "LANG_MOVEMENT_LARS_BRH": "Hip 2", + "LANG_MOVEMENT_LARS_BLH": "Hip 3", + "LANG_MOVEMENT_LARS_FLH": "Hip 4", + "LANG_MOVEMENT_LARS_FRL": "Leg 1", + "LANG_MOVEMENT_LARS_BRL": "Leg 2", + "LANG_MOVEMENT_LARS_BLL": "Leg 3", + "LANG_MOVEMENT_LARS_FLL": "Leg 4", "LANG_LARS_INIT_TOOLTIP": "Defines the servo pins for a quadruped robot.", "LANG_LARS_MOVEMENT": "Move robot", "LANG_LARS_MOVEMENT_MOVEMENT": "Movement", diff --git a/lars_blocks.js b/lars_blocks.js index bd9a666..5b2233a 100644 --- a/lars_blocks.js +++ b/lars_blocks.js @@ -2,29 +2,29 @@ Facilino.LANG_COLOUR_MOVEMENT = '#CECE42'; Facilino.LANG_COLOUR_MOVEMENT_WALK = '#8D8D25'; Blockly.Blocks['LARS_init'] = { - category: Facilino.locales.getKey('LANG_CATEGORY_MOVEMENT'), - subcategory: Facilino.locales.getKey('LANG_SUBCATEGORY_WALK'), - category_colour: Facilino.LANG_COLOUR_MOVEMENT, - colour: Facilino.LANG_COLOUR_MOVEMENT_WALK, - helpUrl: Facilino.getHelpUrl('LARS_init'), - tags: [], - examples: [], - init: function () { - this.appendDummyInput('').appendField(new Blockly.FieldImage('img/blocks/LARS.svg', 32*options.zoom, 32*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_ROBOT')); - this.appendValueInput('FRH').appendField(new Blockly.FieldImage('img/blocks/LARS_FRH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FRH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('FLH').appendField(new Blockly.FieldImage('img/blocks/LARS_FLH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FLH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('BRH').appendField(new Blockly.FieldImage('img/blocks/LARS_BRH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BRH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('BLH').appendField(new Blockly.FieldImage('img/blocks/LARS_BLH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BLH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('FRL').appendField(new Blockly.FieldImage('img/blocks/LARS_FRL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FRL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('FLL').appendField(new Blockly.FieldImage('img/blocks/LARS_FLL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FLL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('BRL').appendField(new Blockly.FieldImage('img/blocks/LARS_BRL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BRL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.appendValueInput('BLL').appendField(new Blockly.FieldImage('img/blocks/LARS_BLL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BLL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); - this.setPreviousStatement(true,'code'); - this.setNextStatement(true,'code'); - this.setColour(Facilino.LANG_COLOUR_MOVEMENT_WALK); - this.setTooltip(Facilino.locales.getKey('LANG_LARS_INIT_TOOLTIP')); - } -}; + category: Facilino.locales.getKey('LANG_CATEGORY_MOVEMENT'), + subcategory: Facilino.locales.getKey('LANG_SUBCATEGORY_WALK'), + category_colour: Facilino.LANG_COLOUR_MOVEMENT, + colour: Facilino.LANG_COLOUR_MOVEMENT_WALK, + helpUrl: Facilino.getHelpUrl('LARS_init'), + tags: [], + examples: [], + init: function () { + this.appendDummyInput('').appendField(new Blockly.FieldImage('img/blocks/LARS.svg', 32*options.zoom, 32*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_ROBOT')); + this.appendValueInput('FRH').appendField(new Blockly.FieldImage('img/blocks/LARS_FRH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FRH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BRH').appendField(new Blockly.FieldImage('img/blocks/LARS_BRH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BRH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BLH').appendField(new Blockly.FieldImage('img/blocks/LARS_BLH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BLH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('FLH').appendField(new Blockly.FieldImage('img/blocks/LARS_FLH.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FLH')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('FRL').appendField(new Blockly.FieldImage('img/blocks/LARS_FRL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FRL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BRL').appendField(new Blockly.FieldImage('img/blocks/LARS_BRL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BRL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('BLL').appendField(new Blockly.FieldImage('img/blocks/LARS_BLL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_BLL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.appendValueInput('FLL').appendField(new Blockly.FieldImage('img/blocks/LARS_FLL.svg', 24*options.zoom, 24*options.zoom)).appendField(Facilino.locales.getKey('LANG_MOVEMENT_LARS_FLL')).appendField(new Blockly.FieldImage('img/blocks/pwm_signal.svg', 24*options.zoom, 24*options.zoom)).setAlign(Blockly.ALIGN_RIGHT); + this.setPreviousStatement(true,'code'); + this.setNextStatement(true,'code'); + this.setColour(Facilino.LANG_COLOUR_MOVEMENT_WALK); + this.setTooltip(Facilino.locales.getKey('LANG_LARS_INIT_TOOLTIP')); + } + }; Blockly.Arduino['LARS_init'] = function(block) { var code='';