add sensebox sensor blocks
This commit is contained in:
@@ -3,4 +3,10 @@ import './sensebox';
|
||||
import './logic';
|
||||
import './sensebox-sensors';
|
||||
import './sensebox-telegram';
|
||||
import './io';
|
||||
import './sensebox-osem';
|
||||
import './io';
|
||||
import './math';
|
||||
import './procedures';
|
||||
import './time';
|
||||
|
||||
import '../helpers/types'
|
||||
@@ -13,6 +13,7 @@
|
||||
import { defineBlocksWithJsonArray } from 'blockly';
|
||||
import Blockly from 'blockly/core';
|
||||
import { selectedBoard } from '../helpers/board'
|
||||
import * as Types from '../helpers/types'
|
||||
|
||||
|
||||
Blockly.Blocks['io_digitalwrite'] = {
|
||||
@@ -28,7 +29,7 @@ Blockly.Blocks['io_digitalwrite'] = {
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'PIN')
|
||||
.appendField(Blockly.Msg.ARD_WRITE_TO)
|
||||
// .setCheck(Blockly.Types.BOOLEAN.checkList);
|
||||
.setCheck(Types.BOOLEAN.checkList);
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
@@ -55,13 +56,13 @@ Blockly.Blocks['io_digitalread'] = {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_DIGITALREAD)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
Blockly.Arduino.Boards.selected.digitalPins), 'PIN');
|
||||
this.setOutput(true, Blockly.Types.BOOLEAN.output);
|
||||
selectedBoard().digitalPins), 'PIN');
|
||||
this.setOutput(true, Types.BOOLEAN);
|
||||
this.setTooltip(Blockly.Msg.ARD_DIGITALREAD_TIP);
|
||||
},
|
||||
/** @return {!string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.BOOLEAN;
|
||||
return Types.BOOLEAN;
|
||||
},
|
||||
/**
|
||||
* Updates the content of the the pin related fields.
|
||||
@@ -84,9 +85,9 @@ Blockly.Blocks['io_builtin_led'] = {
|
||||
this.appendValueInput('STATE')
|
||||
.appendField(Blockly.Msg.ARD_BUILTIN_LED)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
Blockly.Arduino.Boards.selected.builtinLed), 'BUILT_IN_LED')
|
||||
selectedBoard().builtinLed), 'BUILT_IN_LED')
|
||||
.appendField(Blockly.Msg.ARD_WRITE_TO)
|
||||
.setCheck(Blockly.Types.BOOLEAN.checkList);
|
||||
.setCheck(Types.BOOLEAN.compatibleTypes);
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
@@ -102,7 +103,7 @@ Blockly.Blocks['io_builtin_led'] = {
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.BOOLEAN;
|
||||
return Types.BOOLEAN;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -117,9 +118,9 @@ Blockly.Blocks['io_analogwrite'] = {
|
||||
this.appendValueInput('NUM')
|
||||
.appendField(Blockly.Msg.ARD_ANALOGWRITE)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
Blockly.Arduino.Boards.selected.pwmPins), 'PIN')
|
||||
selectedBoard().pwmPins), 'PIN')
|
||||
.appendField(Blockly.Msg.ARD_WRITE_TO)
|
||||
.setCheck(Blockly.Types.NUMBER.output);
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
@@ -134,7 +135,7 @@ Blockly.Blocks['io_analogwrite'] = {
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.NUMBER;
|
||||
return Types.NUMBER;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -149,13 +150,13 @@ Blockly.Blocks['io_analogread'] = {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_ANALOGREAD)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
Blockly.Arduino.Boards.selected.analogPins), 'PIN');
|
||||
this.setOutput(true, Blockly.Types.NUMBER.output);
|
||||
selectedBoard().analogPins), 'PIN');
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_ANALOGREAD_TIP);
|
||||
},
|
||||
/** @return {!string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.NUMBER;
|
||||
return Types.NUMBER.typeId;
|
||||
},
|
||||
/**
|
||||
* Updates the content of the the pin related fields.
|
||||
@@ -178,12 +179,12 @@ Blockly.Blocks['io_highlow'] = {
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([[Blockly.Msg.ARD_HIGH, 'HIGH'], [Blockly.Msg.ARD_LOW, 'LOW']]),
|
||||
'STATE');
|
||||
this.setOutput(true, Blockly.Types.BOOLEAN.output);
|
||||
this.setOutput(true, Types.BOOLEAN.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_HIGHLOW_TIP);
|
||||
},
|
||||
/** @return {!string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.BOOLEAN;
|
||||
return Types.BOOLEAN;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -199,14 +200,14 @@ Blockly.Blocks['io_pulsein'] = {
|
||||
"args0": [{
|
||||
"type": "input_value",
|
||||
"name": "PULSETYPE",
|
||||
"check": Blockly.Types.BOOLEAN.check
|
||||
"check": Types.BOOLEAN.compatibleTypes
|
||||
}, {
|
||||
"type": "field_dropdown",
|
||||
"name": "PULSEPIN",
|
||||
"options": Blockly.Arduino.Boards.selected.digitalPins
|
||||
"options": selectedBoard().digitalPins,
|
||||
}
|
||||
],
|
||||
"output": Blockly.Types.NUMBER.output,
|
||||
"output": Types.NUMBER.typeId,
|
||||
"inputsInline": true,
|
||||
"colour": 250,
|
||||
"tooltip": Blockly.Msg.ARD_PULSE_TIP,
|
||||
@@ -215,7 +216,7 @@ Blockly.Blocks['io_pulsein'] = {
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.NUMBER;
|
||||
return Types.NUMBER.typeId;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -232,18 +233,18 @@ Blockly.Blocks['io_pulsetimeout'] = {
|
||||
"args0": [{
|
||||
"type": "input_value",
|
||||
"name": "PULSETYPE",
|
||||
"check": Blockly.Types.BOOLEAN.check
|
||||
"check": Types.BOOLEAN.compatibleTypes
|
||||
}, {
|
||||
"type": "field_dropdown",
|
||||
"name": "PULSEPIN",
|
||||
"options": Blockly.Arduino.Boards.selected.digitalPins
|
||||
"options": selectedBoard().digitalPins,
|
||||
}, {
|
||||
"type": "input_value",
|
||||
"name": "TIMEOUT",
|
||||
"check": Blockly.Types.NUMBER.check
|
||||
"check": Types.NUMBER.compatibleTypes
|
||||
}
|
||||
],
|
||||
"output": Blockly.Types.NUMBER.output,
|
||||
"output": Types.NUMBER.typeId,
|
||||
"inputsInline": true,
|
||||
"colour": 250,
|
||||
"tooltip": Blockly.Msg.ARD_PULSETIMEOUT_TIP,
|
||||
@@ -252,6 +253,6 @@ Blockly.Blocks['io_pulsetimeout'] = {
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.NUMBER;
|
||||
return Types.NUMBER.typeId;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,61 +1,236 @@
|
||||
import { defineBlocksWithJsonArray } from 'blockly';
|
||||
import Blockly from 'blockly/core';
|
||||
|
||||
defineBlocksWithJsonArray([
|
||||
|
||||
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
|
||||
// Block for boolean data type: true and false.
|
||||
{
|
||||
"type": "logic_boolean",
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "BOOL",
|
||||
"options": [
|
||||
["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"],
|
||||
["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"]
|
||||
]
|
||||
}
|
||||
],
|
||||
"output": "Boolean",
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_LOGIC_BOOLEAN_TOOLTIP}",
|
||||
"helpUrl": "%{BKY_LOGIC_BOOLEAN_HELPURL}"
|
||||
},
|
||||
// Block for if/elseif/else condition.
|
||||
{
|
||||
"type": "controls_if",
|
||||
"message0": "%{BKY_CONTROLS_IF_MSG_IF} %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "IF0",
|
||||
"check": "Boolean"
|
||||
}
|
||||
],
|
||||
"message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1",
|
||||
"args1": [
|
||||
{
|
||||
"type": "input_statement",
|
||||
"name": "DO0"
|
||||
}
|
||||
],
|
||||
"previousStatement": null,
|
||||
"nextStatement": null,
|
||||
"style": "logic_blocks",
|
||||
"helpUrl": "%{BKY_CONTROLS_IF_HELPURL}",
|
||||
"mutator": "controls_if_mutator",
|
||||
"extensions": ["controls_if_tooltip"]
|
||||
},
|
||||
// If/else block that does not use a mutator.
|
||||
{
|
||||
type: 'control_if',
|
||||
message0: '%{BKY_CONTROLS_IF_MSG_IF} %1',
|
||||
args0: [
|
||||
"type": "controls_ifelse",
|
||||
"message0": "%{BKY_CONTROLS_IF_MSG_IF} %1",
|
||||
"args0": [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'IF0',
|
||||
check: 'Boolean'
|
||||
"type": "input_value",
|
||||
"name": "IF0",
|
||||
"check": "Boolean"
|
||||
}
|
||||
],
|
||||
message1: '%{BKY_CONTROLS_IF_MSG_THEN} %1',
|
||||
args1: [
|
||||
"message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1",
|
||||
"args1": [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'DO0'
|
||||
"type": "input_statement",
|
||||
"name": "DO0"
|
||||
}
|
||||
],
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: '#b063c5',
|
||||
tooltip: '%{BKYCONTROLS_IF_TOOLTIP_2}',
|
||||
helpUrl: '%{BKY_CONTROLS_IF_HELPURL}',
|
||||
extensions: ['controls_if_tooltip']
|
||||
"message2": "%{BKY_CONTROLS_IF_MSG_ELSE} %1",
|
||||
"args2": [
|
||||
{
|
||||
"type": "input_statement",
|
||||
"name": "ELSE"
|
||||
}
|
||||
],
|
||||
"previousStatement": null,
|
||||
"nextStatement": null,
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKYCONTROLS_IF_TOOLTIP_2}",
|
||||
"helpUrl": "%{BKY_CONTROLS_IF_HELPURL}",
|
||||
"extensions": ["controls_if_tooltip"]
|
||||
},
|
||||
// Block for comparison operator.
|
||||
{
|
||||
type: 'controls_ifelse',
|
||||
message0: '%{BKY_CONTROLS_IF_MSG_IF} %1',
|
||||
args0: [
|
||||
"type": "logic_compare",
|
||||
"message0": "%1 %2 %3",
|
||||
"args0": [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'IF0',
|
||||
check: 'Boolean'
|
||||
"type": "input_value",
|
||||
"name": "A"
|
||||
},
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "OP",
|
||||
"options": [
|
||||
["=", "EQ"],
|
||||
["\u2260", "NEQ"],
|
||||
["\u200F<", "LT"],
|
||||
["\u200F\u2264", "LTE"],
|
||||
["\u200F>", "GT"],
|
||||
["\u200F\u2265", "GTE"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "B"
|
||||
}
|
||||
],
|
||||
message1: '%{BKY_CONTROLS_IF_MSG_THEN} %1',
|
||||
args1: [
|
||||
"inputsInline": true,
|
||||
"output": "Boolean",
|
||||
"style": "logic_blocks",
|
||||
"helpUrl": "%{BKY_LOGIC_COMPARE_HELPURL}",
|
||||
"extensions": ["logic_compare", "logic_op_tooltip"]
|
||||
},
|
||||
// Block for logical operations: 'and', 'or'.
|
||||
{
|
||||
"type": "logic_operation",
|
||||
"message0": "%1 %2 %3",
|
||||
"args0": [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'DO0'
|
||||
"type": "input_value",
|
||||
"name": "A",
|
||||
"check": "Boolean"
|
||||
},
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "OP",
|
||||
"options": [
|
||||
["%{BKY_LOGIC_OPERATION_AND}", "AND"],
|
||||
["%{BKY_LOGIC_OPERATION_OR}", "OR"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "B",
|
||||
"check": "Boolean"
|
||||
}
|
||||
],
|
||||
message2: '%{BKY_CONTROLS_IF_MSG_ELSE} %1',
|
||||
args2: [
|
||||
"inputsInline": true,
|
||||
"output": "Boolean",
|
||||
"style": "logic_blocks",
|
||||
"helpUrl": "%{BKY_LOGIC_OPERATION_HELPURL}",
|
||||
"extensions": ["logic_op_tooltip"]
|
||||
},
|
||||
// Block for negation.
|
||||
{
|
||||
"type": "logic_negate",
|
||||
"message0": "%{BKY_LOGIC_NEGATE_TITLE}",
|
||||
"args0": [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'ELSE'
|
||||
"type": "input_value",
|
||||
"name": "BOOL",
|
||||
"check": "Boolean"
|
||||
}
|
||||
],
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: '#b063c5',
|
||||
tooltip: '%{BKYCONTROLS_IF_TOOLTIP_2}',
|
||||
helpUrl: '%{BKY_CONTROLS_IF_HELPURL}',
|
||||
extensions: ['controls_if_tooltip']
|
||||
"output": "Boolean",
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_LOGIC_NEGATE_TOOLTIP}",
|
||||
"helpUrl": "%{BKY_LOGIC_NEGATE_HELPURL}"
|
||||
},
|
||||
// Block for null data type.
|
||||
{
|
||||
"type": "logic_null",
|
||||
"message0": "%{BKY_LOGIC_NULL}",
|
||||
"output": null,
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_LOGIC_NULL_TOOLTIP}",
|
||||
"helpUrl": "%{BKY_LOGIC_NULL_HELPURL}"
|
||||
},
|
||||
// Block for ternary operator.
|
||||
{
|
||||
"type": "logic_ternary",
|
||||
"message0": "%{BKY_LOGIC_TERNARY_CONDITION} %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "IF",
|
||||
"check": "Boolean"
|
||||
}
|
||||
],
|
||||
"message1": "%{BKY_LOGIC_TERNARY_IF_TRUE} %1",
|
||||
"args1": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "THEN"
|
||||
}
|
||||
],
|
||||
"message2": "%{BKY_LOGIC_TERNARY_IF_FALSE} %1",
|
||||
"args2": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "ELSE"
|
||||
}
|
||||
],
|
||||
"output": null,
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_LOGIC_TERNARY_TOOLTIP}",
|
||||
"helpUrl": "%{BKY_LOGIC_TERNARY_HELPURL}",
|
||||
"extensions": ["logic_ternary"]
|
||||
}
|
||||
]);
|
||||
]); // END JSON EXTRACT (Do not delete this comment.)
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([ // Mutator blocks. Do not extract.
|
||||
// Block representing the if statement in the controls_if mutator.
|
||||
{
|
||||
"type": "controls_if_if",
|
||||
"message0": "%{BKY_CONTROLS_IF_IF_TITLE_IF}",
|
||||
"nextStatement": null,
|
||||
"enableContextMenu": false,
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_CONTROLS_IF_IF_TOOLTIP}"
|
||||
},
|
||||
// Block representing the else-if statement in the controls_if mutator.
|
||||
{
|
||||
"type": "controls_if_elseif",
|
||||
"message0": "%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",
|
||||
"previousStatement": null,
|
||||
"nextStatement": null,
|
||||
"enableContextMenu": false,
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"
|
||||
},
|
||||
// Block representing the else statement in the controls_if mutator.
|
||||
{
|
||||
"type": "controls_if_else",
|
||||
"message0": "%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",
|
||||
"previousStatement": null,
|
||||
"enableContextMenu": false,
|
||||
"style": "logic_blocks",
|
||||
"tooltip": "%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
import Blockly from 'blockly';
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Block for the Arduino functions.
|
||||
* The Arduino built in functions syntax can be found at:
|
||||
* https://arduino.cc/en/Reference/HomePage
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
|
||||
|
||||
Blockly.Blocks['arduino_functions'] = {
|
||||
/**
|
||||
* Block for defining the Arduino setup() and loop() functions.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_FUN_RUN_SETUP);
|
||||
this.appendStatementInput('SETUP_FUNC');
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_FUN_RUN_LOOP);
|
||||
this.appendStatementInput('LOOP_FUNC');
|
||||
this.setInputsInline(false);
|
||||
this.setColour(getColour().procedures);
|
||||
this.setTooltip(Blockly.Msg.ARD_FUN_RUN_TIP);
|
||||
this.setHelpUrl('https://arduino.cc/en/Reference/Loop');
|
||||
this.contextMenu = false;
|
||||
},
|
||||
/** @return {!boolean} True if the block instance is in the workspace. */
|
||||
getArduinoLoopsInstance: function () {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,114 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import Block from 'blockly'
|
||||
|
||||
|
||||
Blockly.Blocks['sensebox_osem_connection'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_osem_connection_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_osem_connection)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_osem_host, '"ingress.opensensemap.org"'], [Blockly.Msg.senseBox_osem_host_workshop, '"ingress.workshop.opensensemap.org"']]), "host")
|
||||
.appendField('SSL')
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "SSL");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_osem_exposure)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_osem_stationary, 'Stationary'], [Blockly.Msg.senseBox_osem_mobile, 'Mobile']]), "type");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("senseBox ID")
|
||||
.appendField(new Blockly.FieldTextInput("senseBox ID"), "BoxID");
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.senseBox_sensor)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
onchange: function (e) {
|
||||
var block = this;
|
||||
var blocks = block.getDescendants()
|
||||
//Blockly.Blocks.sensebox.getDescendants = blocks;
|
||||
|
||||
},
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
var input = this.getFieldValue('type');
|
||||
this.updateShape_(input);
|
||||
container.setAttribute('type', input);
|
||||
return container;
|
||||
},
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
var connections = xmlElement.getAttribute('connections');
|
||||
this.updateShape_(connections);
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var extraFieldExist = this.getFieldValue('gps');
|
||||
var input = this.getFieldValue('type');
|
||||
if ((input == 'Mobile') && extraFieldExist == null) {
|
||||
this.appendValueInput('lat', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lat, 'gps');
|
||||
this.appendValueInput('lng', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lng);
|
||||
this.appendValueInput('altitude', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_alt);
|
||||
this.appendValueInput('timeStamp', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_timeStamp);
|
||||
}
|
||||
|
||||
if (input == 'Stationary' && extraFieldExist != null) {
|
||||
this.removeInput('lat');
|
||||
this.removeInput('lng');
|
||||
this.removeInput('altitude');
|
||||
this.removeInput('timeStamp');
|
||||
}
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['sensebox_send_to_osem'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_send_to_osem_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_send_to_osem);
|
||||
this.appendValueInput('Value')
|
||||
.setCheck(null)
|
||||
.appendField('Sensor ID')
|
||||
.appendField(new Blockly.FieldTextInput('Sensor ID'), 'SensorID');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
* Add warning if block is not nested inside a the correct loop.
|
||||
* @param {!Blockly.Events.Abstract} e Change event.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function (e) {
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
do {
|
||||
if (this.LOOP_TYPES.indexOf(block.type) != -1) {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
block = block.getSurroundParent();
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_osem_connection'],
|
||||
};
|
||||
@@ -1,5 +1,12 @@
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour'
|
||||
import * as Types from '../helpers/types'
|
||||
import { selectedBoard } from '../helpers/board'
|
||||
|
||||
/**
|
||||
* HDC1080 Temperature and Humidity Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_temp_hum'] = {
|
||||
init: function () {
|
||||
@@ -9,12 +16,297 @@ Blockly.Blocks['sensebox_sensor_temp_hum'] = {
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_temp, "Temperature"], [Blockly.Msg.senseBox_hum, "Humidity"]]), "NAME");
|
||||
this.setOutput(true, "Number");
|
||||
this.setColour(120);
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_temp_hum_tip);
|
||||
this.setHelpUrl('https://edu.books.sensebox.de/de/projekte/diy_umweltstation/temp_und_luftfeuchte.html');
|
||||
},
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.DECIMAL;
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* VEML6070 and TSL4513
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_uv_light'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_uv_light);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_light, "Illuminance"], [Blockly.Msg.senseBox_uv, "UvIntensity"]]), "NAME");
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_uv_light_tip);
|
||||
this.setHelpUrl('https://edu.books.sensebox.de/de/projekte/diy_umweltstation/temp_und_luftfeuchte.html');
|
||||
},
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.DECIMAL;
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
BMX055 Three differen Blocks for Accelerometer, Gyroscope, Compass
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_bmx055_accelerometer'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_bmx055_accelerometer);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_bmx055_accelerometer_direction)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_bmx055_accelerometer_direction_x, "X"], [Blockly.Msg.senseBox_bmx055_accelerometer_direction_y, "Y"], [Blockly.Msg.senseBox_bmx055_accelerometer_direction_z, "Z"], [Blockly.Msg.senseBox_bmx055_accelerometer_direction_total, "Total"]]), "VALUE");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_bmx055_accelerometer_range)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_bmx055_accelerometer_range_2g, "0x3"], [Blockly.Msg.senseBox_bmx055_accelerometer_range_4g, "0x5"], [Blockly.Msg.senseBox_bmx055_accelerometer_range_8g, "0x8"], [Blockly.Msg.senseBox_bmx055_accelerometer_range_16g, "0x0C"]]), "RANGE");
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_bmx055_accelerometer_tip);
|
||||
this.setHelpUrl('https://edu.books.sensebox.de/de/projekte/diy_umweltstation/temp_und_luftfeuchte.html');
|
||||
},
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeId;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* SDS011 Fine Particular Matter Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_sds011'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sds011);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_sds011_pm25, "Pm25"], [Blockly.Msg.senseBox_sds011_pm10, "Pm10"]]), "NAME")
|
||||
.appendField(Blockly.Msg.senseBox_sds011_dimension)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_sds011_serial1, "Serial1"], [Blockly.Msg.senseBox_sds011_serial2, "Serial2"]]), "SERIAL");
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sds011_tip);
|
||||
this.setHelpUrl('https://edu.books.sensebox.de/de/projekte/diy_umweltstation/temp_und_luftfeuchte.html');
|
||||
},
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.DECIMAL;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* BMP280 Pressure Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_pressure'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_pressure, "Pressure"], [Blockly.Msg.senseBox_temp, "Temperature"], [Blockly.Msg.senseBox_gps_alt, "Altitude"]];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
||||
var input = (option == 'Pressure') || (option == 'Temperature') || (option == 'Altitude');
|
||||
this.sourceBlock_.updateShape_(input);
|
||||
});
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_pressure_sensor);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(dropdown, "NAME");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.senseBox_pressure_tip);
|
||||
this.setHelpUrl('https://edu.books.sensebox.de/de/projekte/diy_umweltstation/luftdruck.html');
|
||||
},
|
||||
/**
|
||||
* Parse XML to restore the number of pins available.
|
||||
* @param {!Element} xmlElement XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
var input = (xmlElement.getAttribute('port'));
|
||||
|
||||
},
|
||||
/**
|
||||
* Create XML to represent number of pins selection.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
var input = this.getFieldValue('NAME');
|
||||
this.updateShape_(input);
|
||||
container.setAttribute('NAME', input);
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var extraFieldExist = this.getFieldValue('referencePressure');
|
||||
var input = this.getFieldValue('NAME');
|
||||
if (input == 'Altitude' && extraFieldExist == null) {
|
||||
this.appendDummyInput('extraField')
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||
.appendField(new Blockly.FieldTextInput("1013"), "referencePressure")
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||
}
|
||||
|
||||
if ((input == 'Pressure' || input == 'Temperature') && extraFieldExist != null) {
|
||||
this.removeInput('extraField');
|
||||
}
|
||||
},
|
||||
getBlockType: function () {
|
||||
var input = this.getFieldValue('NAME');
|
||||
if (input == 'Temperature') {
|
||||
return Types.DECIMAL.typeId;
|
||||
} else {
|
||||
return Types.LARGE_NUMBER.typeId;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* BME680 Environmental Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_bme680_bsec'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_temp, "temperature"], [Blockly.Msg.senseBox_hum, "humidity"], [Blockly.Msg.senseBox_pressure, "pressure"], [Blockly.Msg.senseBox_bme_iaq, "IAQ"], [Blockly.Msg.senseBox_bme_iaq_accuracy, "IAQAccuracy"], [Blockly.Msg.senseBox_bme_co2, "CO2"], [Blockly.Msg.senseBox_bme_breatheVocEquivalent, "breathVocEquivalent"]];
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_bme680);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown")
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_bme_tip);
|
||||
},
|
||||
getBlockType: function () {
|
||||
return Types.DECIMAL.typeId;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Ultrasonic Sensor
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_ultrasonic_ranger'] = {
|
||||
init: function () {
|
||||
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
||||
var input = (option == 'A') || (option == 'B') || (option == 'C');
|
||||
this.sourceBlock_.updateShape_(input);
|
||||
});
|
||||
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic)
|
||||
.appendField(dropdown, "port");
|
||||
this.appendDummyInput('TrigEcho')
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic_trigger)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'ultrasonic_trigger')
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic_echo)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'ultrasonic_echo');
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.senseBox_ultrasonic_tip);
|
||||
this.setHelpUrl('https://sensebox.de/books');
|
||||
},
|
||||
/**
|
||||
* Parse XML to restore the number of pins available.
|
||||
* @param {!Element} xmlElement XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
domToMutation: function (xmlElement) {
|
||||
var input = (xmlElement.getAttribute('port'));
|
||||
|
||||
},
|
||||
/**
|
||||
* Create XML to represent number of pins selection.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
var input = this.getFieldValue('port');
|
||||
this.updateShape_(input);
|
||||
container.setAttribute("port", input);
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var input = this.getFieldValue('port');
|
||||
switch (input) {
|
||||
case 'A':
|
||||
this.setFieldValue('1', 'ultrasonic_trigger');
|
||||
this.setFieldValue('2', 'ultrasonic_echo');
|
||||
break;
|
||||
case 'B':
|
||||
this.setFieldValue('3', 'ultrasonic_trigger');
|
||||
this.setFieldValue('4', 'ultrasonic_echo');
|
||||
break;
|
||||
case 'C':
|
||||
this.setFieldValue('5', 'ultrasonic_trigger');
|
||||
this.setFieldValue('6', 'ultrasonic_echo');
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.NUMBER;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Microphone
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_sound'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sound)
|
||||
.appendField("Pin:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().analogPins), "PIN")
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sound_tip);
|
||||
this.setTooltip('Dieser Sensor mist den Geräuschpegel.');
|
||||
},
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeId;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour'
|
||||
|
||||
|
||||
Blockly.Blocks["sensebox_telegram"] = {
|
||||
init: function () {
|
||||
this.setColour(120);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_telegram_init);
|
||||
this.appendDummyInput()
|
||||
@@ -15,3 +17,37 @@ Blockly.Blocks["sensebox_telegram"] = {
|
||||
};
|
||||
|
||||
|
||||
Blockly.Blocks["sensebox_telegram_do"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_telegram_do);
|
||||
this.appendStatementInput("telegram_do");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_telegram_do_on_message"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_telegram_do_on_message);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_telegram_message)
|
||||
.appendField(new Blockly.FieldTextInput("/message"), 'telegram_message');
|
||||
this.appendStatementInput("telegram_do_on_message").setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_telegram_send"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_telegram_send);
|
||||
this.appendValueInput("telegram_text_to_send").setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_telegram_do_on_message"]
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blocks for Arduino Time functions.
|
||||
* The arduino built in functions syntax can be found in
|
||||
* http://arduino.cc/en/Reference/HomePage
|
||||
*/
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour'
|
||||
import * as Types from '../helpers/types'
|
||||
|
||||
|
||||
Blockly.Blocks['time_delay'] = {
|
||||
/**
|
||||
* Delay block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Delay');
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput('DELAY_TIME_MILI')
|
||||
.setCheck(Types.NUMBER.checkList)
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_MS);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_TIP);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['time_delaymicros'] = {
|
||||
/**
|
||||
* delayMicroseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/DelayMicroseconds');
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput('DELAY_TIME_MICRO')
|
||||
.setCheck(Types.NUMBER.checkList)
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY_MICROS);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_MICRO_TIP);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['time_millis'] = {
|
||||
/**
|
||||
* Elapsed time in milliseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Millis');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_MILLIS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
},
|
||||
/** @return {string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.LARGE_NUMBER;
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['time_micros'] = {
|
||||
/**
|
||||
* Elapsed time in microseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Micros');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_MICROS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MICROS_TIP);
|
||||
},
|
||||
/**
|
||||
* Should be a long (32bit), but for for now an int.
|
||||
* @return {string} The type of return value for the block, an integer.
|
||||
*/
|
||||
getBlockType: function () {
|
||||
return Types.LARGE_NUMBER;
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['infinite_loop'] = {
|
||||
/**
|
||||
* Waits forever, end of program.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_INF);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_INF_TIP);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_interval_timer'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip);
|
||||
this.setInputsInline(true);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_interval_timer);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(new Blockly.FieldTextInput("10000"), "interval")
|
||||
.appendField(Blockly.Msg.senseBox_interval);
|
||||
this.appendStatementInput('DO')
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user