/** * @license Licensed under the Apache License, Version 2.0 (the "License"): * http://www.apache.org/licenses/LICENSE-2.0 */ /** * @fileoverview Ardublockly JavaScript for the Blockly resources and bindings. */ 'use strict'; goog.provide('Blockly.Blocks.motion'); goog.require('Blockly.Blocks'); Blockly.Blocks.motion.HUE = 270; /* *block for motion setup */ Blockly.Blocks['motion_setup'] = { init: function() { this.appendDummyInput() // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/main-motion.png", 50, 40, "15")); .appendField(new Blockly.FieldImage("./../blockly/media/main-motion.png", 50, 40, "15")); this.appendDummyInput() .appendField(Blockly.Msg.MOTION_SETUP); //.appendField('MOTION_SETUP'); this.setColour(Blockly.Blocks.motion.HUE); this.setTooltip(''); this.setHelpUrl(''); } }; Blockly.Blocks['motion_onshake'] = { init: function() { this.appendDummyInput() .appendField(Blockly.Msg.MOTION_ONSHAKE) this.setOutput(true, Blockly.Types.BOOLEAN.output); this.setColour(Blockly.Blocks.motion.HUE); this.setTooltip(''); this.setHelpUrl(''); }, getBlockType: function() { return Blockly.Types.BOOLEAN; } }; Blockly.Blocks['motion_onDirection'] = { init: function() { this.appendDummyInput() .appendField(Blockly.Msg.MOTION_ONDIRECTION) .appendField(new Blockly.FieldDropdown([ [Blockly.Msg.MOTION_ONDIRECTION_LEFT, "left"], [Blockly.Msg.MOTION_ONDIRECTION_RIGHT, "right"], [Blockly.Msg.MOTION_ONDIRECTION_FRONT, "front"], [Blockly.Msg.MOTION_ONDIRECTION_BACK, "back"], // [Blockly.Msg.MOTION_ONDIRECTION_CLOCKWISE, "clockwise"], // [Blockly.Msg.MOTION_ONDIRECTION_COUNTERCLOCKWISE, "counterClockwise"], ]), "DIRECTION") .appendField(Blockly.Msg.MOTION_ONDIRECTION1) this.setOutput(true, "Boolean"); this.setColour(Blockly.Blocks.motion.HUE); this.setTooltip(''); this.setHelpUrl(''); } }; Blockly.Blocks['motion_getRotation_ypr'] = { init: function() { this.appendDummyInput() .appendField(Blockly.Msg.MOTION_GETYPR) .appendField(new Blockly.FieldDropdown([ ["yaw", "0"], ["pitch", "1"], ["roll", "2"] ]), "Rotation") .appendField(Blockly.Msg.MOTION_GETYPR1) this.setOutput(true, Blockly.Types.NUMBER.output); this.setColour(Blockly.Blocks.motion.HUE); this.setTooltip(''); this.setHelpUrl(''); }, getBlockType: function() { return Blockly.Types.NUMBER; } } Blockly.Blocks['motion_getAcceleration'] = { init: function() { this.appendDummyInput() .appendField(Blockly.Msg.MOTION_GETACC) .appendField(new Blockly.FieldDropdown([ ["x", "x"], ["y", "y"], ["z", "z"] ]), "Acceleration") .appendField(Blockly.Msg.MOTION_GETACC1) this.setOutput(true, Blockly.Types.NUMBER.output); this.setColour(Blockly.Blocks.motion.HUE); this.setTooltip(''); this.setHelpUrl(''); }, getBlockType: function() { return Blockly.Types.NUMBER; } }