1
0
mirror of https://github.com/s00500/SimpleExpressions synced 2024-12-04 04:21:27 +00:00

modified: simpleExpression_blocks.js

This commit is contained in:
roboticafacil 2017-12-09 11:38:55 +01:00
parent 718ab33c32
commit e1f29d04f4

View File

@ -1,8 +1,3 @@
Facilino.LANG_COLOUR_SCREEN_LEDSTRIP = '#8EAC32';
Facilino.locales.defaultLanguage["LANG_SUBCATERGORY_WS2812"]="LED Strip";
Facilino.locales.defaultLanguage["LANG_SIMPLEEXPRESSIONS_PIN"]="PIN";
Facilino.locales.defaultLanguage["LANG_SIMPLEEXPRESSIONS_SHOWMOUTH_TOOLTIP"]="Draw an expression on the WS2812 led strip (ring-7)";
Blockly.Blocks['show_mouth'] = { Blockly.Blocks['show_mouth'] = {
category: Facilino.locales.getKey('LANG_CATEGORY_SCREEN'), category: Facilino.locales.getKey('LANG_CATEGORY_SCREEN'),
subcategory: Facilino.locales.getKey('LANG_SUBCATERGORY_WS2812'), subcategory: Facilino.locales.getKey('LANG_SUBCATERGORY_WS2812'),
@ -37,24 +32,59 @@ code+= '\n';
return code; return code;
}; };
Blockly.Blocks['play_sound'] = { Blockly.Arduino.dyor_piezo_buzzer_predef_sounds = function() {
category: 'SimpleExpressions', var dropdown_pin = Blockly.Arduino.valueToCode(this, 'PIN', Blockly.Arduino.ORDER_ATOMIC) || '';
colour: '#fbb117', var code= '';
helpUrl: Facilino.getHelpUrl('play_sound'), Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include <SimpleExpressions.h>';
tags: [], Blockly.Arduino.setups_['setup_simpleexpressions_buzzer'] = 'SimpleExpressions.initBuzzer('+dropdown_pin+');\n';
examples: [], code='SimpleExpressions.playSound('+this.getFieldValue('OPTION')+');\n';
init: function() { return code;
this.appendDummyInput() };
.appendField("play Sound");
this.setColour("#fbb117"); Blockly.Blocks.dyor_piezo_buzzer_predef_sounds = {
this.setTooltip(""); category: Facilino.locales.getKey('LANG_CATEGORY_SOUND'),
} subcategory: Facilino.locales.getKey('LANG_SUBCATEGORY_BUZZER'),
}; tags: ['buzzer','sound'],
helpUrl: Facilino.getHelpUrl('dyor_piezo_buzzer_predef_sounds'),
examples: [''],
Blockly.Arduino['play_sound'] = function(block) { category_colour: Facilino.LANG_COLOUR_SOUND,
var input_color = Blockly.Arduino.valueToCode(block, 'Color', Blockly.Arduino.ORDER_ATOMIC); colour: Facilino.LANG_COLOUR_SOUND_BUZZER,
var code=''; //dyor_piezo_buzzer initialization
code+= '\n'; init: function() {
return code; this.setColour(Facilino.LANG_COLOUR_SOUND_BUZZER);
}; this.appendDummyInput('')
.appendField(Facilino.locales.getKey('LANG_PIEZO_BUZZER'))
.appendField(new Blockly.FieldImage('img/blocks/buzzer.svg', 52*options.zoom, 35*options.zoom));
this.appendValueInput('PIN')
.appendField(Facilino.locales.getKey('LANG_PIEZO_BUZZER_PIN')).appendField(new Blockly.FieldImage("img/blocks/pwm_signal.svg",24*options.zoom,24*options.zoom))
.setCheck(Number)
.setAlign(Blockly.ALIGN_RIGHT);
this.appendDummyInput('').appendField(new Blockly.FieldImage('img/blocks/speaker.svg', 24*options.zoom, 24*options.zoom))
.appendField(new Blockly.FieldDropdown([
['CONNECTION', '0'],
['DISCONNECTION', '1'],
['BUTTON PUSHED', '2'],
['MODE 1', '3'],
['MODE 2', '4'],
['MODE 3', '5'],
['SURPRISE', '6'],
['OHOOH', '7'],
['OHOOH2', '8'],
['CUDDLY', '9'],
['SLEEPING','10'],
['HAPPY','11'],
['SUPER_HAPPY','12'],
['HAPPY_SHORT','13'],
['SAD','14'],
['CONFUSED','15'],
['FART1','16'],
['FART2','17'],
['FART3','18'],
['PIRATES','19']
]), 'OPTION').setAlign(Blockly.ALIGN_RIGHT);
this.setInputsInline(false);
this.setPreviousStatement(true,'code');
this.setNextStatement(true,'code');
this.setTooltip(Facilino.locales.getKey('LANG_PIEZO_BUZZER_PREDEF_SOUNDS_TOOLTIP'));
}
};