add map block
This commit is contained in:
@@ -8,6 +8,7 @@ import './sensebox-web';
|
||||
import './sensebox-display';
|
||||
import './io';
|
||||
import './math';
|
||||
import './map';
|
||||
import './procedures';
|
||||
import './time';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
@@ -44,6 +45,7 @@ Blockly.defineBlocksWithJsonArray([
|
||||
inputsInline: false,
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: getColour().loops,
|
||||
helpUrl: '%{BKY_CONTROLS_FOR_HELPURL}',
|
||||
extensions: ['contextMenu_newGetVariableBlock', 'controls_for_tooltip'],
|
||||
},
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Block for the Arduino map functionality.
|
||||
* The Arduino built in functions syntax can be found at:
|
||||
* http://arduino.cc/en/Reference/HomePage
|
||||
*
|
||||
* TODO: This block can be improved to set the new range properly.
|
||||
*/
|
||||
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import * as Types from '../helpers/types'
|
||||
|
||||
Blockly.Blocks['base_map'] = {
|
||||
/**
|
||||
* Block for creating a the map function.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/map');
|
||||
this.setColour(getColour().math);
|
||||
this.appendValueInput('NUM')
|
||||
.appendField(Blockly.Msg.ARD_MAP)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput('FMIN')
|
||||
.appendField(Blockly.Msg.ARD_MAP_FROMMIN)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput('FMAX')
|
||||
.appendField(Blockly.Msg.ARD_MAP_FROMMAX)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput('DMIN')
|
||||
.appendField(Blockly.Msg.ARD_MAP_TOMIN)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput('DMAX')
|
||||
.appendField(Blockly.Msg.ARD_MAP_TOMAX)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(false);
|
||||
this.setTooltip(Blockly.Msg.ARD_MAP_TIP);
|
||||
},
|
||||
/** @return {string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeId;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user