map.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license Licensed under the Apache License, Version 2.0 (the "License"):
  3. * http://www.apache.org/licenses/LICENSE-2.0
  4. */
  5. /**
  6. * @fileoverview Block for the Arduino map functionality.
  7. * The Arduino built in functions syntax can be found at:
  8. * http://arduino.cc/en/Reference/HomePage
  9. *
  10. * TODO: This block can be improved to set the new range properly.
  11. */
  12. 'use strict';
  13. goog.provide('Blockly.Blocks.map');
  14. goog.require('Blockly.Blocks');
  15. goog.require('Blockly.Types');
  16. /** Common HSV hue for all blocks in this category. */
  17. Blockly.Blocks.map.HUE = 220;
  18. Blockly.Blocks['base_map'] = {
  19. /**
  20. * Block for creating a the map function.
  21. * @this Blockly.Block
  22. */
  23. init: function() {
  24. this.setHelpUrl('http://arduino.cc/en/Reference/map');
  25. this.setColour(Blockly.Blocks.map.HUE);
  26. this.appendValueInput('NUM')
  27. .appendField(Blockly.Msg.ARD_MAP)
  28. .setCheck(Blockly.Types.NUMBER.checkList);
  29. this.appendValueInput('DMAX')
  30. .appendField(Blockly.Msg.ARD_MAP_VAL)
  31. .setCheck(Blockly.Types.NUMBER.checkList);
  32. this.appendDummyInput()
  33. .appendField(']');
  34. this.setInputsInline(true);
  35. this.setOutput(true);
  36. this.setTooltip(Blockly.Msg.ARD_MAP_TIP);
  37. },
  38. /** @return {string} The type of return value for the block, an integer. */
  39. getBlockType: function() {
  40. return Blockly.Types.NUMBER;
  41. }
  42. };