diff --git a/public/media/hardware/ble-bee.png b/public/media/hardware/ble-bee.png new file mode 100644 index 0000000..d5e5070 Binary files /dev/null and b/public/media/hardware/ble-bee.png differ diff --git a/src/components/Blockly/blocks/logic.js b/src/components/Blockly/blocks/logic.js index 5d25ed9..6a84c74 100644 --- a/src/components/Blockly/blocks/logic.js +++ b/src/components/Blockly/blocks/logic.js @@ -1,648 +1,651 @@ -import Blockly from 'blockly/core'; -import { getColour } from '../helpers/colour'; -import * as Types from '../helpers/types'; -import { getCompatibleTypes } from '../helpers/types'; +import Blockly from "blockly/core"; +import { getColour } from "../helpers/colour"; +import * as Types from "../helpers/types"; +import { getCompatibleTypes } from "../helpers/types"; - - -Blockly.Blocks['controls_if'] = { - /** - * Block for if/elseif/else condition. - * @this Blockly.Block - */ - init: function () { - this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL); - this.setColour(getColour().logic); - this.appendValueInput('IF0') - .setCheck(Types.getCompatibleTypes('boolean')) - .appendField(Blockly.Msg.CONTROLS_IF_MSG_IF); - this.appendStatementInput('DO0') - .appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN); - this.setPreviousStatement(true); - this.setNextStatement(true); - this.setMutator(new Blockly.Mutator(['controls_if_elseif', - 'controls_if_else'])); - // Assign 'this' to a variable for use in the tooltip closure below. - var thisBlock = this; - this.setTooltip(function () { - if (!thisBlock.elseifCount_ && !thisBlock.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_1; - } else if (!thisBlock.elseifCount_ && thisBlock.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_2; - } else if (thisBlock.elseifCount_ && !thisBlock.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_3; - } else if (thisBlock.elseifCount_ && thisBlock.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_4; - } - return ''; - }); - this.elseifCount_ = 0; - this.elseCount_ = 0; - }, - /** - * Create XML to represent the number of else-if and else inputs. - * @return {Element} XML storage element. - * @this Blockly.Block - */ - mutationToDom: function () { - if (!this.elseifCount_ && !this.elseCount_) { - return null; - } - var container = document.createElement('mutation'); - if (this.elseifCount_) { - container.setAttribute('elseif', this.elseifCount_); - } - if (this.elseCount_) { - container.setAttribute('else', 1); - } - return container; - }, - /** - * Parse XML to restore the else-if and else inputs. - * @param {!Element} xmlElement XML storage element. - * @this Blockly.Block - */ - domToMutation: function (xmlElement) { - this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10) || 0; - this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10) || 0; - this.updateShape_(); - }, - /** - * Populate the mutator's dialog with this block's components. - * @param {!Blockly.Workspace} workspace Mutator's workspace. - * @return {!Blockly.Block} Root block in mutator. - * @this Blockly.Block - */ - decompose: function (workspace) { - var containerBlock = workspace.newBlock('controls_if_if'); - containerBlock.initSvg(); - var connection = containerBlock.nextConnection; - for (var i = 1; i <= this.elseifCount_; i++) { - var elseifBlock = workspace.newBlock('controls_if_elseif'); - elseifBlock.initSvg(); - connection.connect(elseifBlock.previousConnection); - connection = elseifBlock.nextConnection; - } - if (this.elseCount_) { - var elseBlock = workspace.newBlock('controls_if_else'); - elseBlock.initSvg(); - connection.connect(elseBlock.previousConnection); - } - return containerBlock; - }, - /** - * Reconfigure this block based on the mutator dialog's components. - * @param {!Blockly.Block} containerBlock Root block in mutator. - * @this Blockly.Block - */ - compose: function (containerBlock) { - var clauseBlock = containerBlock.nextConnection.targetBlock(); - // Count number of inputs. - this.elseifCount_ = 0; - this.elseCount_ = 0; - var valueConnections = [null]; - var statementConnections = [null]; - var elseStatementConnection = null; - while (clauseBlock) { - switch (clauseBlock.type) { - case 'controls_if_elseif': - this.elseifCount_++; - valueConnections.push(clauseBlock.valueConnection_); - statementConnections.push(clauseBlock.statementConnection_); - break; - case 'controls_if_else': - this.elseCount_++; - elseStatementConnection = clauseBlock.statementConnection_; - break; - default: - throw new Error('Unknown block type.'); - } - clauseBlock = clauseBlock.nextConnection && - clauseBlock.nextConnection.targetBlock(); - } - this.updateShape_(); - // Reconnect any child blocks. - for (var i = 1; i <= this.elseifCount_; i++) { - Blockly.Mutator.reconnect(valueConnections[i], this, 'IF' + i); - Blockly.Mutator.reconnect(statementConnections[i], this, 'DO' + i); - } - Blockly.Mutator.reconnect(elseStatementConnection, this, 'ELSE'); - }, - /** - * Store pointers to any connected child blocks. - * @param {!Blockly.Block} containerBlock Root block in mutator. - * @this Blockly.Block - */ - saveConnections: function (containerBlock) { - var clauseBlock = containerBlock.nextConnection.targetBlock(); - var i = 1; - var inputDo; - while (clauseBlock) { - switch (clauseBlock.type) { - case 'controls_if_elseif': - var inputIf = this.getInput('IF' + i); - inputDo = this.getInput('DO' + i); - clauseBlock.valueConnection_ = - inputIf && inputIf.connection.targetConnection; - clauseBlock.statementConnection_ = - inputDo && inputDo.connection.targetConnection; - i++; - break; - case 'controls_if_else': - inputDo = this.getInput('ELSE'); - clauseBlock.statementConnection_ = - inputDo && inputDo.connection.targetConnection; - break; - default: - throw new Error('Unknown block type.'); - } - clauseBlock = clauseBlock.nextConnection && - clauseBlock.nextConnection.targetBlock(); - } - }, - /** - * Modify this block to have the correct number of inputs. - * @private - * @this Blockly.Block - */ - updateShape_: function () { - // Delete everything. - if (this.getInput('ELSE')) { - this.removeInput('ELSE'); - } - var j = 1; - while (this.getInput('IF' + j)) { - this.removeInput('IF' + j); - this.removeInput('DO' + j); - j++; - } - // Rebuild block. - for (var i = 1; i <= this.elseifCount_; i++) { - this.appendValueInput('IF' + i) - .setCheck(Types.getCompatibleTypes('boolean')) - .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF); - this.appendStatementInput('DO' + i) - .appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN); - } - if (this.elseCount_) { - this.appendStatementInput('ELSE') - .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE); - } +Blockly.Blocks["controls_if"] = { + /** + * Block for if/elseif/else condition. + * @this Blockly.Block + */ + init: function () { + this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL); + this.setColour(getColour().logic); + this.appendValueInput("IF0") + .setCheck(Types.getCompatibleTypes("boolean")) + .appendField(Blockly.Msg.CONTROLS_IF_MSG_IF); + this.appendStatementInput("DO0").appendField( + Blockly.Msg.CONTROLS_IF_MSG_THEN + ); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setMutator( + new Blockly.Mutator(["controls_if_elseif", "controls_if_else"]) + ); + this.setTooltip(Blockly.Msg.CONTROLS_IF_TOOLTIP_1); + this.elseifCount_ = 0; + this.elseCount_ = 0; + }, + /** + * Create XML to represent the number of else-if and else inputs. + * @return {Element} XML storage element. + * @this Blockly.Block + */ + mutationToDom: function () { + if (!this.elseifCount_ && !this.elseCount_) { + return null; } + var container = document.createElement("mutation"); + if (this.elseifCount_) { + container.setAttribute("elseif", this.elseifCount_); + } + if (this.elseCount_) { + container.setAttribute("else", 1); + } + return container; + }, + /** + * Parse XML to restore the else-if and else inputs. + * @param {!Element} xmlElement XML storage element. + * @this Blockly.Block + */ + domToMutation: function (xmlElement) { + this.elseifCount_ = parseInt(xmlElement.getAttribute("elseif"), 10) || 0; + this.elseCount_ = parseInt(xmlElement.getAttribute("else"), 10) || 0; + this.updateShape_(); + }, + /** + * Populate the mutator's dialog with this block's components. + * @param {!Blockly.Workspace} workspace Mutator's workspace. + * @return {!Blockly.Block} Root block in mutator. + * @this Blockly.Block + */ + decompose: function (workspace) { + var containerBlock = workspace.newBlock("controls_if_if"); + containerBlock.initSvg(); + var connection = containerBlock.nextConnection; + for (var i = 1; i <= this.elseifCount_; i++) { + var elseifBlock = workspace.newBlock("controls_if_elseif"); + elseifBlock.initSvg(); + connection.connect(elseifBlock.previousConnection); + connection = elseifBlock.nextConnection; + } + if (this.elseCount_) { + var elseBlock = workspace.newBlock("controls_if_else"); + elseBlock.initSvg(); + connection.connect(elseBlock.previousConnection); + } + return containerBlock; + }, + /** + * Reconfigure this block based on the mutator dialog's components. + * @param {!Blockly.Block} containerBlock Root block in mutator. + * @this Blockly.Block + */ + compose: function (containerBlock) { + var clauseBlock = containerBlock.nextConnection.targetBlock(); + // Count number of inputs. + this.elseifCount_ = 0; + this.elseCount_ = 0; + var valueConnections = [null]; + var statementConnections = [null]; + var elseStatementConnection = null; + while (clauseBlock) { + switch (clauseBlock.type) { + case "controls_if_elseif": + this.elseifCount_++; + valueConnections.push(clauseBlock.valueConnection_); + statementConnections.push(clauseBlock.statementConnection_); + break; + case "controls_if_else": + this.elseCount_++; + elseStatementConnection = clauseBlock.statementConnection_; + break; + default: + throw new Error("Unknown block type."); + } + clauseBlock = + clauseBlock.nextConnection && clauseBlock.nextConnection.targetBlock(); + } + this.updateShape_(); + // Reconnect any child blocks. + for (var i = 1; i <= this.elseifCount_; i++) { + Blockly.Mutator.reconnect(valueConnections[i], this, "IF" + i); + Blockly.Mutator.reconnect(statementConnections[i], this, "DO" + i); + } + Blockly.Mutator.reconnect(elseStatementConnection, this, "ELSE"); + }, + /** + * Store pointers to any connected child blocks. + * @param {!Blockly.Block} containerBlock Root block in mutator. + * @this Blockly.Block + */ + saveConnections: function (containerBlock) { + var clauseBlock = containerBlock.nextConnection.targetBlock(); + var i = 1; + var inputDo; + while (clauseBlock) { + switch (clauseBlock.type) { + case "controls_if_elseif": + var inputIf = this.getInput("IF" + i); + inputDo = this.getInput("DO" + i); + clauseBlock.valueConnection_ = + inputIf && inputIf.connection.targetConnection; + clauseBlock.statementConnection_ = + inputDo && inputDo.connection.targetConnection; + i++; + break; + case "controls_if_else": + inputDo = this.getInput("ELSE"); + clauseBlock.statementConnection_ = + inputDo && inputDo.connection.targetConnection; + break; + default: + throw new Error("Unknown block type."); + } + clauseBlock = + clauseBlock.nextConnection && clauseBlock.nextConnection.targetBlock(); + } + }, + /** + * Modify this block to have the correct number of inputs. + * @private + * @this Blockly.Block + */ + updateShape_: function () { + // Delete everything. + if (this.getInput("ELSE")) { + this.removeInput("ELSE"); + } + var j = 1; + while (this.getInput("IF" + j)) { + this.removeInput("IF" + j); + this.removeInput("DO" + j); + j++; + } + // Rebuild block. + for (var i = 1; i <= this.elseifCount_; i++) { + this.appendValueInput("IF" + i) + .setCheck(Types.getCompatibleTypes("boolean")) + .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF); + this.appendStatementInput("DO" + i).appendField( + Blockly.Msg.CONTROLS_IF_MSG_THEN + ); + } + if (this.elseCount_) { + this.appendStatementInput("ELSE").appendField( + Blockly.Msg.CONTROLS_IF_MSG_ELSE + ); + } + }, }; -Blockly.Blocks['controls_if_if'] = { - /** - * Mutator block for if container. - * @this Blockly.Block - */ - init: function () { - this.setColour(getColour().logic); - this.appendDummyInput() - .appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF); - this.setNextStatement(true); - this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP); - this.contextMenu = false; - } +Blockly.Blocks["controls_if_if"] = { + /** + * Mutator block for if container. + * @this Blockly.Block + */ + init: function () { + this.setColour(getColour().logic); + this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF); + this.setNextStatement(true); + this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP); + this.contextMenu = false; + }, }; -Blockly.Blocks['controls_if_elseif'] = { - /** - * Mutator bolck for else-if condition. - * @this Blockly.Block - */ - init: function () { - this.setColour(getColour().logic); - this.appendDummyInput() - .appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF); - this.setPreviousStatement(true); - this.setNextStatement(true); - this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP); - this.contextMenu = false; - } +Blockly.Blocks["controls_if_elseif"] = { + /** + * Mutator bolck for else-if condition. + * @this Blockly.Block + */ + init: function () { + this.setColour(getColour().logic); + this.appendDummyInput().appendField( + Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF + ); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP); + this.contextMenu = false; + }, }; -Blockly.Blocks['controls_if_else'] = { - /** - * Mutator block for else condition. - * @this Blockly.Block - */ - init: function () { - this.setColour(getColour().logic); - this.appendDummyInput() - .appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE); - this.setPreviousStatement(true); - this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP); - this.contextMenu = false; - } +Blockly.Blocks["controls_if_else"] = { + /** + * Mutator block for else condition. + * @this Blockly.Block + */ + init: function () { + this.setColour(getColour().logic); + this.appendDummyInput().appendField( + Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE + ); + this.setPreviousStatement(true); + this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP); + this.contextMenu = false; + }, }; +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: Types.BOOLEAN.typeName, + style: "logic_blocks", + tooltip: "%{BKY_LOGIC_BOOLEAN_TOOLTIP}", + helpUrl: "%{BKY_LOGIC_BOOLEAN_HELPURL}", + }, + { + type: "controls_ifelse", + message0: "%{BKY_CONTROLS_IF_MSG_IF} %1", + args0: [ + { + type: "input_value", + name: "IF0", + check: Types.getCompatibleTypes("boolean"), + }, + ], + message1: "%{BKY_CONTROLS_IF_MSG_THEN} %1", + args1: [ + { + type: "input_statement", + name: "DO0", + }, + ], + 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: "logic_compare", + message0: "%1 %2 %3", + args0: [ + { + 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", + }, + ], + inputsInline: true, + output: Types.BOOLEAN.typeName, + 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_value", + name: "A", + check: Types.getCompatibleTypes("boolean"), + }, + { + type: "field_dropdown", + name: "OP", + options: [ + ["%{BKY_LOGIC_OPERATION_AND}", "AND"], + ["%{BKY_LOGIC_OPERATION_OR}", "OR"], + ], + }, + { + type: "input_value", + name: "B", + check: Types.getCompatibleTypes("boolean"), + }, + ], + inputsInline: true, + output: Types.BOOLEAN.typeName, + 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_value", + name: "BOOL", + check: Types.getCompatibleTypes("boolean"), + }, + ], + output: Types.BOOLEAN.typeName, + 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: Types.getCompatibleTypes("boolean"), + }, + ], + message1: "%{BKY_LOGIC_TERNARY_IF_TRUE} %1", + args1: [ + { + type: "input_value", + name: "THEN", + check: Types.getCompatibleTypes("boolean"), + }, + ], + message2: "%{BKY_LOGIC_TERNARY_IF_FALSE} %1", + args2: [ + { + type: "input_value", + name: "ELSE", + check: Types.getCompatibleTypes("boolean"), + }, + ], + 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([ // 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": Types.BOOLEAN.typeName, - "style": "logic_blocks", - "tooltip": "%{BKY_LOGIC_BOOLEAN_TOOLTIP}", - "helpUrl": "%{BKY_LOGIC_BOOLEAN_HELPURL}" - }, - { - "type": "controls_ifelse", - "message0": "%{BKY_CONTROLS_IF_MSG_IF} %1", - "args0": [ - { - "type": "input_value", - "name": "IF0", - "check": Types.getCompatibleTypes('boolean') - } - ], - "message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1", - "args1": [ - { - "type": "input_statement", - "name": "DO0" - } - ], - "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": "logic_compare", - "message0": "%1 %2 %3", - "args0": [ - { - "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" - } - ], - "inputsInline": true, - "output": Types.BOOLEAN.typeName, - "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_value", - "name": "A", - "check": Types.getCompatibleTypes('boolean') - }, - { - "type": "field_dropdown", - "name": "OP", - "options": [ - ["%{BKY_LOGIC_OPERATION_AND}", "AND"], - ["%{BKY_LOGIC_OPERATION_OR}", "OR"] - ] - }, - { - "type": "input_value", - "name": "B", - "check": Types.getCompatibleTypes('boolean') - } - ], - "inputsInline": true, - "output": Types.BOOLEAN.typeName, - "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_value", - "name": "BOOL", - "check": Types.getCompatibleTypes('boolean'), - } - ], - "output": Types.BOOLEAN.typeName, - "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": Types.getCompatibleTypes('boolean'), - } - ], - "message1": "%{BKY_LOGIC_TERNARY_IF_TRUE} %1", - "args1": [ - { - "type": "input_value", - "name": "THEN", - "check": Types.getCompatibleTypes('boolean'), - } - ], - "message2": "%{BKY_LOGIC_TERNARY_IF_FALSE} %1", - "args2": [ - { - "type": "input_value", - "name": "ELSE", - "check": Types.getCompatibleTypes('boolean'), - } - ], - "output": null, - "style": "logic_blocks", - "tooltip": "%{BKY_LOGIC_TERNARY_TOOLTIP}", - "helpUrl": "%{BKY_LOGIC_TERNARY_HELPURL}", - "extensions": ["logic_ternary"] +Blockly.Blocks["logic_compare"] = { + /** + * Block for comparison operator. + * @this Blockly.Block + */ + init: function () { + var OPERATORS = this.RTL + ? [ + ["=", "EQ"], + ["\u2260", "NEQ"], + [">", "LT"], + ["\u2265", "LTE"], + ["<", "GT"], + ["\u2264", "GTE"], + ] + : [ + ["=", "EQ"], + ["\u2260", "NEQ"], + ["<", "LT"], + ["\u2264", "LTE"], + [">", "GT"], + ["\u2265", "GTE"], + ]; + this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL); + this.setColour(getColour().logic); + this.setOutput(true, Types.BOOLEAN.typeName); + this.appendValueInput("A"); + this.appendValueInput("B").appendField( + new Blockly.FieldDropdown(OPERATORS), + "OP" + ); + this.setInputsInline(true); + // Assign 'this' to a variable for use in the tooltip closure below. + var thisBlock = this; + this.setTooltip(function () { + var op = thisBlock.getFieldValue("OP"); + var TOOLTIPS = { + EQ: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ, + NEQ: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ, + LT: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT, + LTE: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE, + GT: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT, + GTE: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE, + }; + return TOOLTIPS[op]; + }); + }, + /** + * Called whenever anything on the workspace changes. + * Prevent mismatched types from being compared. + * @param {!Blockly.Events.Abstract} e Change event. + * @this Blockly.Block + */ + onchange: function (e) { + var blockA = this.getInputTargetBlock("A"); + var blockB = this.getInputTargetBlock("B"); + if (blockA === null && blockB === null) { + this.getInput("A").setCheck(null); + this.getInput("B").setCheck(null); } -]); // END JSON EXTRACT (Do not delete this comment.) - - -Blockly.Blocks['logic_compare'] = { - /** - * Block for comparison operator. - * @this Blockly.Block - */ - init: function () { - var OPERATORS = this.RTL ? [ - ['=', 'EQ'], - ['\u2260', 'NEQ'], - ['>', 'LT'], - ['\u2265', 'LTE'], - ['<', 'GT'], - ['\u2264', 'GTE'] - ] : [ - ['=', 'EQ'], - ['\u2260', 'NEQ'], - ['<', 'LT'], - ['\u2264', 'LTE'], - ['>', 'GT'], - ['\u2265', 'GTE'] - ]; - this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL); - this.setColour(getColour().logic); - this.setOutput(true, Types.BOOLEAN.typeName); - this.appendValueInput('A'); - this.appendValueInput('B') - .appendField(new Blockly.FieldDropdown(OPERATORS), 'OP'); - this.setInputsInline(true); - // Assign 'this' to a variable for use in the tooltip closure below. - var thisBlock = this; - this.setTooltip(function () { - var op = thisBlock.getFieldValue('OP'); - var TOOLTIPS = { - 'EQ': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ, - 'NEQ': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ, - 'LT': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT, - 'LTE': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE, - 'GT': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT, - 'GTE': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE - }; - return TOOLTIPS[op]; - }); - }, - /** - * Called whenever anything on the workspace changes. - * Prevent mismatched types from being compared. - * @param {!Blockly.Events.Abstract} e Change event. - * @this Blockly.Block - */ - onchange: function (e) { - var blockA = this.getInputTargetBlock('A'); - var blockB = this.getInputTargetBlock('B'); - if (blockA === null && blockB === null) { - this.getInput('A').setCheck(null); - this.getInput('B').setCheck(null); - } - if (blockA !== null && blockB === null) { - this.getInput('A').setCheck(getCompatibleTypes(blockA.outputConnection.check_[0])); - this.getInput('B').setCheck(getCompatibleTypes(blockA.outputConnection.check_[0])); - } - if (blockB !== null && blockA === null) { - this.getInput('B').setCheck(getCompatibleTypes(blockB.outputConnection.check_[0])); - this.getInput('A').setCheck(getCompatibleTypes(blockB.outputConnection.check_[0])); - } + if (blockA !== null && blockB === null) { + this.getInput("A").setCheck( + getCompatibleTypes(blockA.outputConnection.check_[0]) + ); + this.getInput("B").setCheck( + getCompatibleTypes(blockA.outputConnection.check_[0]) + ); } + if (blockB !== null && blockA === null) { + this.getInput("B").setCheck( + getCompatibleTypes(blockB.outputConnection.check_[0]) + ); + this.getInput("A").setCheck( + getCompatibleTypes(blockB.outputConnection.check_[0]) + ); + } + }, }; +Blockly.Blocks["switch_case"] = { + init: function () { + this.setColour(getColour().logic); + this.setPreviousStatement(true); + this.setTooltip(Blockly.Msg.cases_tooltip); + this.setNextStatement(true); + this.appendValueInput("CONDITION").appendField(Blockly.Msg.cases_switch); + this.appendValueInput("CASECONDITION0").appendField( + Blockly.Msg.cases_condition + ); + this.appendStatementInput("CASE0").appendField(Blockly.Msg.cases_do); + this.setMutator(new Blockly.Mutator(["case_incaseof", "case_default"])); + this.caseCount_ = 0; + this.defaultCount_ = 0; + }, -Blockly.Blocks['switch_case'] = { - init: function () { - this.setColour(getColour().logic); - this.setPreviousStatement(true); - this.setTooltip(Blockly.Msg.cases_tooltip); - this.setNextStatement(true); - this.appendValueInput('CONDITION') - .appendField(Blockly.Msg.cases_switch); - this.appendValueInput('CASECONDITION0') - .appendField(Blockly.Msg.cases_condition); - this.appendStatementInput('CASE0') - .appendField(Blockly.Msg.cases_do); - this.setMutator(new Blockly.Mutator(['case_incaseof', 'case_default'])); - this.caseCount_ = 0; - this.defaultCount_ = 0; - }, - - mutationToDom: function () { - if (!this.caseCount_ && !this.defaultCount_) { - return null; - } - var container = document.createElement('mutation'); - if (this.caseCount_) { - container.setAttribute('case', this.caseCount_); - } - if (this.defaultCount_) { - container.setAttribute('default', 1); - } - return container; - }, - - domToMutation: function (xmlElement) { - this.caseCount_ = parseInt(xmlElement.getAttribute('case'), 10); - this.defaultCount_ = parseInt(xmlElement.getAttribute('default'), 10); - for (var x = 0; x <= this.caseCount_; x++) { - this.appendValueInput('CASECONDITION' + x) - .appendField(Blockly.Msg.cases_condition); - this.appendStatementInput('CASE' + x) - .appendField(Blockly.Msg.cases_do); - } - if (this.defaultCount_) { - this.appendStatementInput('ONDEFAULT') - .appendField('default'); - } - }, - - decompose: function (workspace) { - var containerBlock = workspace.newBlock('control_case'); - containerBlock.initSvg(); - var connection = containerBlock.getInput('STACK').connection; - for (var x = 1; x <= this.caseCount_; x++) { - var caseBlock = workspace.newBlock('case_incaseof'); - caseBlock.initSvg(); - connection.connect(caseBlock.previousConnection); - connection = caseBlock.nextConnection; - } - if (this.defaultCount_) { - var defaultBlock = Blockly.Block.obtain(workspace, 'case_default'); - defaultBlock.initSvg(); - connection.connect(defaultBlock.previousConnection); - } - return containerBlock; - }, - - compose: function (containerBlock) { - //Disconnect all input blocks and remove all inputs. - if (this.defaultCount_) { - this.removeInput('ONDEFAULT'); - } - this.defaultCount_ = 0; - for (var x = this.caseCount_; x > 0; x--) { - this.removeInput('CASECONDITION' + x); - this.removeInput('CASE' + x); - } - this.caseCount_ = 0; - var caseBlock = containerBlock.getInputTargetBlock('STACK'); - while (caseBlock) { - switch (caseBlock.type) { - case 'case_incaseof': - this.caseCount_++; - var caseconditionInput = this.appendValueInput('CASECONDITION' + this.caseCount_) - .appendField(Blockly.Msg.cases_condition); - var caseInput = this.appendStatementInput('CASE' + this.caseCount_) - .appendField(Blockly.Msg.cases_do); - if (caseBlock.valueConnection_) { - caseconditionInput.connection.connect(caseBlock.valueConnection_); - } - if (caseBlock.statementConnection_) { - caseInput.connection.connect(caseBlock.statementConnection_); - } - break; - case 'case_default': - this.defaultCount_++; - var defaultInput = this.appendStatementInput('ONDEFAULT') - .appendField('default'); - if (caseBlock.statementConnection_) { - defaultInput.connection.connect(caseBlock.statementConnection_); - } - break; - default: - throw new Error('Unknown block type.'); - } - caseBlock = caseBlock.nextConnection && - caseBlock.nextConnection.targetBlock(); - } - }, - - saveConnections: function (containerBlock) { - var caseBlock = containerBlock.getInputTargetBlock('STACK'); - var x = 1; - while (caseBlock) { - switch (caseBlock.type) { - case 'case_incaseof': - var caseconditionInput = this.getInput('CASECONDITION' + x); - var caseInput = this.getInput('CASE' + x); - caseBlock.valueConnection_ = caseconditionInput && caseconditionInput.connection.targetConnection; - caseBlock.statementConnection_ = caseInput && caseInput.connection.targetConnection; - x++; - break; - case 'case_default': - var defaultInput = this.getInput('ONDEFAULT'); - caseBlock.satementConnection_ = defaultInput && defaultInput.connection.targetConnection; - break; - default: - throw new Error('Unknown block type'); - } - caseBlock = caseBlock.nextConnection && - caseBlock.nextConnection.targetBlock(); - } + mutationToDom: function () { + if (!this.caseCount_ && !this.defaultCount_) { + return null; } + var container = document.createElement("mutation"); + if (this.caseCount_) { + container.setAttribute("case", this.caseCount_); + } + if (this.defaultCount_) { + container.setAttribute("default", 1); + } + return container; + }, + + domToMutation: function (xmlElement) { + this.caseCount_ = parseInt(xmlElement.getAttribute("case"), 10); + this.defaultCount_ = parseInt(xmlElement.getAttribute("default"), 10); + for (var x = 0; x <= this.caseCount_; x++) { + this.appendValueInput("CASECONDITION" + x).appendField( + Blockly.Msg.cases_condition + ); + this.appendStatementInput("CASE" + x).appendField(Blockly.Msg.cases_do); + } + if (this.defaultCount_) { + this.appendStatementInput("ONDEFAULT").appendField("default"); + } + }, + + decompose: function (workspace) { + var containerBlock = workspace.newBlock("control_case"); + containerBlock.initSvg(); + var connection = containerBlock.getInput("STACK").connection; + for (var x = 1; x <= this.caseCount_; x++) { + var caseBlock = workspace.newBlock("case_incaseof"); + caseBlock.initSvg(); + connection.connect(caseBlock.previousConnection); + connection = caseBlock.nextConnection; + } + if (this.defaultCount_) { + var defaultBlock = Blockly.Block.obtain(workspace, "case_default"); + defaultBlock.initSvg(); + connection.connect(defaultBlock.previousConnection); + } + return containerBlock; + }, + + compose: function (containerBlock) { + //Disconnect all input blocks and remove all inputs. + if (this.defaultCount_) { + this.removeInput("ONDEFAULT"); + } + this.defaultCount_ = 0; + for (var x = this.caseCount_; x > 0; x--) { + this.removeInput("CASECONDITION" + x); + this.removeInput("CASE" + x); + } + this.caseCount_ = 0; + var caseBlock = containerBlock.getInputTargetBlock("STACK"); + while (caseBlock) { + switch (caseBlock.type) { + case "case_incaseof": + this.caseCount_++; + var caseconditionInput = this.appendValueInput( + "CASECONDITION" + this.caseCount_ + ).appendField(Blockly.Msg.cases_condition); + var caseInput = this.appendStatementInput( + "CASE" + this.caseCount_ + ).appendField(Blockly.Msg.cases_do); + if (caseBlock.valueConnection_) { + caseconditionInput.connection.connect(caseBlock.valueConnection_); + } + if (caseBlock.statementConnection_) { + caseInput.connection.connect(caseBlock.statementConnection_); + } + break; + case "case_default": + this.defaultCount_++; + var defaultInput = + this.appendStatementInput("ONDEFAULT").appendField("default"); + if (caseBlock.statementConnection_) { + defaultInput.connection.connect(caseBlock.statementConnection_); + } + break; + default: + throw new Error("Unknown block type."); + } + caseBlock = + caseBlock.nextConnection && caseBlock.nextConnection.targetBlock(); + } + }, + + saveConnections: function (containerBlock) { + var caseBlock = containerBlock.getInputTargetBlock("STACK"); + var x = 1; + while (caseBlock) { + switch (caseBlock.type) { + case "case_incaseof": + var caseconditionInput = this.getInput("CASECONDITION" + x); + var caseInput = this.getInput("CASE" + x); + caseBlock.valueConnection_ = + caseconditionInput && + caseconditionInput.connection.targetConnection; + caseBlock.statementConnection_ = + caseInput && caseInput.connection.targetConnection; + x++; + break; + case "case_default": + var defaultInput = this.getInput("ONDEFAULT"); + caseBlock.satementConnection_ = + defaultInput && defaultInput.connection.targetConnection; + break; + default: + throw new Error("Unknown block type"); + } + caseBlock = + caseBlock.nextConnection && caseBlock.nextConnection.targetBlock(); + } + }, }; -Blockly.Blocks['control_case'] = { - init: function () { - this.setColour(getColour().logic); - this.appendDummyInput() - .appendField(Blockly.Msg.cases_switch); - this.appendStatementInput('STACK'); - this.setTooltip('--Placeholder--'); - this.contextMenu = false; - } +Blockly.Blocks["control_case"] = { + init: function () { + this.setColour(getColour().logic); + this.appendDummyInput().appendField(Blockly.Msg.cases_switch); + this.appendStatementInput("STACK"); + this.setTooltip("--Placeholder--"); + this.contextMenu = false; + }, }; -Blockly.Blocks['case_incaseof'] = { - init: function () { - this.setColour(getColour().logic); - this.appendDummyInput() - .appendField(Blockly.Msg.cases_add); - this.setPreviousStatement(true); - this.setNextStatement(true); - this.setTooltip('--Placeholder--'); - this.contextMenu = false; - } +Blockly.Blocks["case_incaseof"] = { + init: function () { + this.setColour(getColour().logic); + this.appendDummyInput().appendField(Blockly.Msg.cases_add); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setTooltip("--Placeholder--"); + this.contextMenu = false; + }, }; -Blockly.Blocks['case_default'] = { - init: function () { - this.setColour(getColour().logic); - this.appendValueInput('default') - .appendField('default'); - this.setPreviousStatement(true); - this.setNextStatement(false); - this.setTooltip('This function will run if there aren\'t any matching cases.'); - this.contextMenu = false; - } +Blockly.Blocks["case_default"] = { + init: function () { + this.setColour(getColour().logic); + this.appendValueInput("default").appendField("default"); + this.setPreviousStatement(true); + this.setNextStatement(false); + this.setTooltip( + "This function will run if there aren't any matching cases." + ); + this.contextMenu = false; + }, }; diff --git a/src/components/Blockly/blocks/sensebox-display.js b/src/components/Blockly/blocks/sensebox-display.js index 23f8124..c4f0de0 100644 --- a/src/components/Blockly/blocks/sensebox-display.js +++ b/src/components/Blockly/blocks/sensebox-display.js @@ -1,304 +1,329 @@ -import * as Blockly from 'blockly/core'; -import { getColour } from '../helpers/colour'; -import * as Types from '../helpers/types' -import { FieldSlider } from '@blockly/field-slider'; +import * as Blockly from "blockly/core"; +import { getColour } from "../helpers/colour"; +import * as Types from "../helpers/types"; +import { FieldSlider } from "@blockly/field-slider"; - -Blockly.Blocks['sensebox_display_beginDisplay'] = { - init: function () { - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_beginDisplay) - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - this.setColour(getColour().sensebox); - this.setTooltip(Blockly.Msg.senseBox_display_beginDisplay_tooltip); - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); - } +Blockly.Blocks["sensebox_display_beginDisplay"] = { + init: function () { + this.appendDummyInput().appendField( + Blockly.Msg.senseBox_display_beginDisplay + ); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(getColour().sensebox); + this.setTooltip(Blockly.Msg.senseBox_display_beginDisplay_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + }, }; -Blockly.Blocks['sensebox_display_clearDisplay'] = { - init: function () { - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_clearDisplay) - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - this.setColour(getColour().sensebox); - this.setTooltip(Blockly.Msg.senseBox_display_clearDisplay_tooltip); - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); - } +Blockly.Blocks["sensebox_display_clearDisplay"] = { + init: function () { + this.appendDummyInput().appendField( + Blockly.Msg.senseBox_display_clearDisplay + ); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(getColour().sensebox); + this.setTooltip(Blockly.Msg.senseBox_display_clearDisplay_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + }, }; -Blockly.Blocks['sensebox_display_printDisplay'] = { - init: function (block) { - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_printDisplay); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_color) - .appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_display_white, "WHITE,BLACK"], [Blockly.Msg.senseBox_display_black, "BLACK,WHITE"]]), "COLOR"); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_setSize) - .appendField(new FieldSlider(1, 1, 4), "SIZE"); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_printDisplay_x) - .appendField(new FieldSlider(0, 0, 64), "X"); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_printDisplay_y) - .appendField(new FieldSlider(0, 0, 128), "Y"); - this.appendValueInput('printDisplay') - .appendField(Blockly.Msg.senseBox_display_printDisplay_value) - .setCheck(null); - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tooltip); - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); - }, - /** - * 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_display_show'], -}; - -Blockly.Blocks['sensebox_display_fastPrint'] = { - init: function (block) { - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_fastPrint_show); - this.appendValueInput("Title1", 'Title1') - .appendField(Blockly.Msg.senseBox_display_fastPrint_title); - this.appendValueInput("Value1", 'Value1') - .appendField(Blockly.Msg.senseBox_display_fastPrint_value); - this.appendValueInput("Dimension1", 'Dimension1') - .appendField(Blockly.Msg.senseBox_display_fastPrint_dimension); - this.appendValueInput("Title2", 'Title2') - .appendField(Blockly.Msg.senseBox_display_fastPrint_title); - this.appendValueInput("Value2", 'Value2') - .appendField(Blockly.Msg.senseBox_display_fastPrint_value); - this.appendValueInput("Dimension2", 'Dimension2') - .appendField(Blockly.Msg.senseBox_display_fastPrint_dimension); - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - this.setTooltip(Blockly.Msg.sensebox_display_fastPrint_tooltip); - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); - }, - /** +Blockly.Blocks["sensebox_display_printDisplay"] = { + init: function (block) { + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField( + Blockly.Msg.senseBox_display_printDisplay + ); + this.appendDummyInput() + .appendField(Blockly.Msg.senseBox_display_color) + .appendField( + new Blockly.FieldDropdown([ + [Blockly.Msg.senseBox_display_white, "WHITE,BLACK"], + [Blockly.Msg.senseBox_display_black, "BLACK,WHITE"], + ]), + "COLOR" + ); + this.appendDummyInput() + .appendField(Blockly.Msg.senseBox_display_setSize) + .appendField(new FieldSlider(1, 1, 4), "SIZE"); + this.appendDummyInput() + .appendField(Blockly.Msg.senseBox_display_printDisplay_x) + .appendField(new FieldSlider(0, 0, 128), "X"); + this.appendDummyInput() + .appendField(Blockly.Msg.senseBox_display_printDisplay_y) + .appendField(new FieldSlider(0, 0, 64), "Y"); + this.appendValueInput("printDisplay") + .appendField(Blockly.Msg.senseBox_display_printDisplay_value) + .setCheck(null); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + }, + /** * 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_display_show'], -}; - - -Blockly.Blocks['sensebox_display_plotDisplay'] = { - init: function () { - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_display_plotDisplay) - this.appendValueInput("Title", 'Text') - .appendField(Blockly.Msg.senseBox_display_plotTitle); - this.appendValueInput("YLabel", 'Text') - .appendField(Blockly.Msg.senseBox_display_plotYLabel); - this.appendValueInput("XLabel", 'Text') - .appendField(Blockly.Msg.senseBox_display_plotXLabel); - this.appendValueInput("XRange1", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotXRange1); - this.appendValueInput("XRange2", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotXRange2) - this.appendValueInput("YRange1", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotYRange1); - this.appendValueInput("YRange2", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotYRange2); - this.setInputsInline(false); - this.appendValueInput("XTick", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotXTick); - this.appendValueInput("YTick", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotYTick); - this.appendValueInput("TimeFrame", 'Number') - .appendField(Blockly.Msg.senseBox_display_plotTimeFrame); - this.appendValueInput('plotDisplay') - .appendField(Blockly.Msg.senseBox_display_printDisplay_value) - .setCheck(null); - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tooltip); - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); - }, - /** - * 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_display_show'], -}; - -Blockly.Blocks['sensebox_display_show'] = { - init: function () { - - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.sensebox_display_show); - this.appendStatementInput('SHOW'); - this.setTooltip(Blockly.Msg.sensebox_display_show_tip); - this.setHelpUrl(''); - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); + 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_display_show"], }; -Blockly.Blocks['sensebox_display_fillCircle'] = { - init: function () { - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.sensebox_display_fillCircle); - this.appendValueInput('X') - .appendField(Blockly.Msg.senseBox_display_printDisplay_x) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendValueInput('Y') - .appendField(Blockly.Msg.senseBox_display_printDisplay_y) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendValueInput('Radius') - .appendField(Blockly.Msg.sensebox_display_fillCircle_radius) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendDummyInput('fill') - .appendField(Blockly.Msg.senseBox_display_filled) - .appendField(new Blockly.FieldCheckbox("TRUE"), "FILL"); - this.setInputsInline(false); - this.setTooltip(Blockly.Msg.senseBox_display_fillCircle_tooltip) - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl) - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - }, - /** +Blockly.Blocks["sensebox_display_fastPrint"] = { + init: function (block) { + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField( + Blockly.Msg.senseBox_display_fastPrint_show + ); + this.appendValueInput("Title1", "Title1").appendField( + Blockly.Msg.senseBox_display_fastPrint_title + ); + this.appendValueInput("Value1", "Value1").appendField( + Blockly.Msg.senseBox_display_fastPrint_value + ); + this.appendValueInput("Dimension1", "Dimension1").appendField( + Blockly.Msg.senseBox_display_fastPrint_dimension + ); + this.appendValueInput("Title2", "Title2").appendField( + Blockly.Msg.senseBox_display_fastPrint_title + ); + this.appendValueInput("Value2", "Value2").appendField( + Blockly.Msg.senseBox_display_fastPrint_value + ); + this.appendValueInput("Dimension2", "Dimension2").appendField( + Blockly.Msg.senseBox_display_fastPrint_dimension + ); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setTooltip(Blockly.Msg.sensebox_display_fastPrint_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + }, + /** * 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_display_show'], + 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_display_show"], }; -Blockly.Blocks['sensebox_display_drawRectangle'] = { - init: function () { - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.sensebox_display_drawRectangle); - this.appendValueInput('X') - .appendField(Blockly.Msg.senseBox_display_printDisplay_x) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendValueInput('Y') - .appendField(Blockly.Msg.senseBox_display_printDisplay_y) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendValueInput('width') - .appendField(Blockly.Msg.sensebox_display_drawRectangle_width) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendValueInput('height') - .appendField(Blockly.Msg.sensebox_display_drawRectangle_height) - .setCheck(Types.NUMBER.compatibleTypes); - this.appendDummyInput('fill') - .appendField(Blockly.Msg.senseBox_display_filled) - .appendField(new Blockly.FieldCheckbox("TRUE"), "FILL"); - this.setInputsInline(false); - this.setTooltip(Blockly.Msg.senseBox_display_drawRectangle_tooltip) - this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl) - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - }, - /** +Blockly.Blocks["sensebox_display_plotDisplay"] = { + init: function () { + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField( + Blockly.Msg.senseBox_display_plotDisplay + ); + this.appendValueInput("Title", "Text").appendField( + Blockly.Msg.senseBox_display_plotTitle + ); + this.appendValueInput("YLabel", "Text").appendField( + Blockly.Msg.senseBox_display_plotYLabel + ); + this.appendValueInput("XLabel", "Text").appendField( + Blockly.Msg.senseBox_display_plotXLabel + ); + this.appendValueInput("XRange1", "Number").appendField( + Blockly.Msg.senseBox_display_plotXRange1 + ); + this.appendValueInput("XRange2", "Number").appendField( + Blockly.Msg.senseBox_display_plotXRange2 + ); + this.appendValueInput("YRange1", "Number").appendField( + Blockly.Msg.senseBox_display_plotYRange1 + ); + this.appendValueInput("YRange2", "Number").appendField( + Blockly.Msg.senseBox_display_plotYRange2 + ); + this.setInputsInline(false); + this.appendValueInput("XTick", "Number").appendField( + Blockly.Msg.senseBox_display_plotXTick + ); + this.appendValueInput("YTick", "Number").appendField( + Blockly.Msg.senseBox_display_plotYTick + ); + this.appendValueInput("TimeFrame", "Number").appendField( + Blockly.Msg.senseBox_display_plotTimeFrame + ); + this.appendValueInput("plotDisplay") + .appendField(Blockly.Msg.senseBox_display_printDisplay_value) + .setCheck(null); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + }, + /** * 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_display_show'], + 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_display_show"], +}; + +Blockly.Blocks["sensebox_display_show"] = { + init: function () { + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField(Blockly.Msg.sensebox_display_show); + this.appendStatementInput("SHOW"); + this.setTooltip(Blockly.Msg.sensebox_display_show_tip); + this.setHelpUrl(""); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + }, +}; + +Blockly.Blocks["sensebox_display_fillCircle"] = { + init: function () { + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField( + Blockly.Msg.sensebox_display_fillCircle + ); + this.appendValueInput("X") + .appendField(Blockly.Msg.senseBox_display_printDisplay_x) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendValueInput("Y") + .appendField(Blockly.Msg.senseBox_display_printDisplay_y) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendValueInput("Radius") + .appendField(Blockly.Msg.sensebox_display_fillCircle_radius) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendDummyInput("fill") + .appendField(Blockly.Msg.senseBox_display_filled) + .appendField(new Blockly.FieldCheckbox("TRUE"), "FILL"); + this.setInputsInline(false); + this.setTooltip(Blockly.Msg.senseBox_display_fillCircle_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + 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_display_show"], +}; + +Blockly.Blocks["sensebox_display_drawRectangle"] = { + init: function () { + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField( + Blockly.Msg.sensebox_display_drawRectangle + ); + this.appendValueInput("X") + .appendField(Blockly.Msg.senseBox_display_printDisplay_x) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendValueInput("Y") + .appendField(Blockly.Msg.senseBox_display_printDisplay_y) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendValueInput("width") + .appendField(Blockly.Msg.sensebox_display_drawRectangle_width) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendValueInput("height") + .appendField(Blockly.Msg.sensebox_display_drawRectangle_height) + .setCheck(Types.NUMBER.compatibleTypes); + this.appendDummyInput("fill") + .appendField(Blockly.Msg.senseBox_display_filled) + .appendField(new Blockly.FieldCheckbox("TRUE"), "FILL"); + this.setInputsInline(false); + this.setTooltip(Blockly.Msg.senseBox_display_drawRectangle_tooltip); + this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl); + 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_display_show"], }; diff --git a/src/components/Blockly/helpers/board.js b/src/components/Blockly/helpers/board.js index e380ce7..16e0165 100644 --- a/src/components/Blockly/helpers/board.js +++ b/src/components/Blockly/helpers/board.js @@ -3,42 +3,129 @@ * */ const sensebox_mcu = { - description: 'senseBox Microcontroller Unit based on Microchip SAMD21G18A', - compilerFlag: 'arduino:samd', - digitalPins: [['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']], - digitalPinsLED: [['BUILTIN_1', '7'], ['BUILTIN_2', '8'], ['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']], - digitalPinsButton: [['on Board', '0'], ['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']], - pwmPins: [['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']], - serial: [['serial', 'SerialUSB'], ['serial_1', 'Serial1'], ['serial_2', 'Serial2']], - serialPins: { - SerialUSB: [['RX', ''], ['TX', '']], - Serial1: [['RX', '11'], ['TX', '10']], - Serial2: [['RX', '13'], ['TX', '12']] - }, - serialSpeed: [['300', '300'], ['600', '600'], ['1200', '1200'], - ['2400', '2400'], ['4800', '4800'], ['9600', '9600'], - ['14400', '14400'], ['19200', '19200'], ['28800', '28800'], - ['31250', '31250'], ['38400', '38400'], ['57600', '57600'], - ['115200', '115200']], - spi: [['SPI', 'SPI']], - spiPins: { SPI: [['MOSI', '19'], ['MISO', '21'], ['SCK', '20']] }, - spiClockDivide: [['2 (8MHz)', 'SPI_CLOCK_DIV2'], - ['4 (4MHz)', 'SPI_CLOCK_DIV4'], - ['8 (2MHz)', 'SPI_CLOCK_DIV8'], - ['16 (1MHz)', 'SPI_CLOCK_DIV16'], - ['32 (500KHz)', 'SPI_CLOCK_DIV32'], - ['64 (250KHz)', 'SPI_CLOCK_DIV64'], - ['128 (125KHz)', 'SPI_CLOCK_DIV128']], - i2c: [['I2C', 'Wire']], - i2cPins: { Wire: [['SDA', '17'], ['SCL', '16']] }, - i2cSpeed: [['100kHz', '100000L'], ['400kHz', '400000L']], - builtinLed: [['BUILTIN_1', '7'], ['BUILTIN_2', '8']], - interrupt: [['interrupt1', '1'], ['interrupt2', '2'], ['interrupt3', '3'], ['interrupt4', '4'], ['interrupt5', '5'], ['interrupt6', '6']], - analogPins: [['A1', 'A1'], ['A2', 'A2'], ['A3', 'A3'], ['A4', 'A4'], ['A5', 'A5'], ['A6', 'A6']], - serial_baud_rate: 9600, - parseKey: '_*_' + description: "senseBox Microcontroller Unit based on Microchip SAMD21G18A", + compilerFlag: "arduino:samd", + digitalPins: [ + ["A1", "1"], + ["A2", "2"], + ["B3", "3"], + ["B4", "4"], + ["C5", "5"], + ["C6", "6"], + ], + digitalPinsLED: [ + ["BUILTIN_1", "7"], + ["BUILTIN_2", "8"], + ["A1", "1"], + ["A2", "2"], + ["B3", "3"], + ["B4", "4"], + ["C5", "5"], + ["C6", "6"], + ], + digitalPinsButton: [ + ["on Board", "0"], + ["A1", "1"], + ["A2", "2"], + ["B3", "3"], + ["B4", "4"], + ["C5", "5"], + ["C6", "6"], + ], + pwmPins: [ + ["A1", "1"], + ["A2", "2"], + ["B3", "3"], + ["B4", "4"], + ["C5", "5"], + ["C6", "6"], + ], + serial: [ + ["serial", "SerialUSB"], + ["serial_1", "Serial1"], + ["serial_2", "Serial2"], + ], + serialPins: { + SerialUSB: [ + ["RX", ""], + ["TX", ""], + ], + Serial1: [ + ["RX", "11"], + ["TX", "10"], + ], + Serial2: [ + ["RX", "13"], + ["TX", "12"], + ], + }, + serialSpeed: [ + ["300", "300"], + ["600", "600"], + ["1200", "1200"], + ["2400", "2400"], + ["4800", "4800"], + ["9600", "9600"], + ["14400", "14400"], + ["19200", "19200"], + ["28800", "28800"], + ["31250", "31250"], + ["38400", "38400"], + ["57600", "57600"], + ["115200", "115200"], + ], + spi: [["SPI", "SPI"]], + spiPins: { + SPI: [ + ["MOSI", "19"], + ["MISO", "21"], + ["SCK", "20"], + ], + }, + spiClockDivide: [ + ["2 (8MHz)", "SPI_CLOCK_DIV2"], + ["4 (4MHz)", "SPI_CLOCK_DIV4"], + ["8 (2MHz)", "SPI_CLOCK_DIV8"], + ["16 (1MHz)", "SPI_CLOCK_DIV16"], + ["32 (500KHz)", "SPI_CLOCK_DIV32"], + ["64 (250KHz)", "SPI_CLOCK_DIV64"], + ["128 (125KHz)", "SPI_CLOCK_DIV128"], + ], + i2c: [["I2C", "Wire"]], + i2cPins: { + Wire: [ + ["SDA", "17"], + ["SCL", "16"], + ], + }, + i2cSpeed: [ + ["100kHz", "100000L"], + ["400kHz", "400000L"], + ], + builtinLed: [ + ["BUILTIN_1", "7"], + ["BUILTIN_2", "8"], + ], + interrupt: [ + ["interrupt1", "1"], + ["interrupt2", "2"], + ["interrupt3", "3"], + ["interrupt4", "4"], + ["interrupt5", "5"], + ["interrupt6", "6"], + ], + analogPins: [ + ["A1", "A1"], + ["A2", "A2"], + ["B3", "A3"], + ["B4", "A4"], + ["C5", "A5"], + ["C6", "A6"], + ], + serial_baud_rate: 9600, + parseKey: "_*_", }; export const selectedBoard = () => { - return sensebox_mcu; + return sensebox_mcu; }; diff --git a/src/components/Blockly/msg/de/logic.js b/src/components/Blockly/msg/de/logic.js index b3ebb76..1be60c6 100644 --- a/src/components/Blockly/msg/de/logic.js +++ b/src/components/Blockly/msg/de/logic.js @@ -1,50 +1,64 @@ export const LOGIC = { + CONTROLS_IF_ELSEIF_TOOLTIP: "Eine weitere Bedingung hinzufügen.", + CONTROLS_IF_ELSE_TOOLTIP: + "Eine sonst-Bedingung hinzufügen, führt eine Anweisung aus, falls keine Bedingung zutrifft.", + CONTROLS_IF_HELPURL: "https://github.com/google/blockly/wiki/IfElse", // untranslated + CONTROLS_IF_IF_TOOLTIP: "Hinzufügen, entfernen oder sortieren von Sektionen", + CONTROLS_IF_MSG_ELSE: "sonst", + CONTROLS_IF_MSG_ELSEIF: "sonst wenn", + CONTROLS_IF_MSG_IF: "wenn", + CONTROLS_IF_TOOLTIP_1: + "Wenn eine Bedingung wahr (true) ist, dann führe eine Anweisung aus.", + CONTROLS_IF_TOOLTIP_2: + "Wenn eine Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Ansonsten führe die zweite Anweisung aus.", + CONTROLS_IF_TOOLTIP_3: + "Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus.", + CONTROLS_IF_TOOLTIP_4: + "Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus. Falls keine der beiden Bedingungen wahr (true) ist, dann führe die dritte Anweisung aus.", + LOGIC_BOOLEAN_HELPURL: "https://github.com/google/blockly/wiki/Logic#values", // untranslated + LOGIC_BOOLEAN_TOOLTIP: "Ist entweder wahr (true) oder falsch (false)", + LOGIC_BOOLEAN_TRUE: "wahr", + LOGIC_COMPARE_HELPURL: "https://de.wikipedia.org/wiki/Vergleich_%28Zahlen%29", + LOGIC_COMPARE_TOOLTIP_EQ: "Ist wahr (true), wenn beide Werte gleich sind.", + LOGIC_COMPARE_TOOLTIP_GT: + "Ist wahr (true), wenn der erste Wert größer als der zweite Wert ist.", + LOGIC_COMPARE_TOOLTIP_GTE: + "Ist wahr (true), wenn der erste Wert größer als oder gleich groß wie der zweite Wert ist.", + LOGIC_COMPARE_TOOLTIP_LT: + "Ist wahr (true), wenn der erste Wert kleiner als der zweite Wert ist.", + LOGIC_COMPARE_TOOLTIP_LTE: + "Ist wahr (true), wenn der erste Wert kleiner als oder gleich groß wie der zweite Wert ist.", + LOGIC_COMPARE_TOOLTIP_NEQ: + "Ist wahr (true), wenn beide Werte unterschiedlich sind.", + LOGIC_NEGATE_HELPURL: "https://github.com/google/blockly/wiki/Logic#not", // untranslated + LOGIC_NEGATE_TITLE: "nicht %1", + LOGIC_NEGATE_TOOLTIP: + "Ist wahr (true), wenn der Eingabewert falsch (false) ist. Ist falsch (false), wenn der Eingabewert wahr (true) ist.", + LOGIC_NULL: "null", + LOGIC_NULL_HELPURL: "https://de.wikipedia.org/wiki/Nullwert", + LOGIC_NULL_TOOLTIP: "Ist NULL.", + LOGIC_OPERATION_AND: "und", + LOGIC_OPERATION_HELPURL: + "https://github.com/google/blockly/wiki/Logic#logical-operations", // untranslated + LOGIC_OPERATION_OR: "oder", + LOGIC_OPERATION_TOOLTIP_AND: + "Ist wahr (true), wenn beide Werte wahr (true) sind.", + LOGIC_OPERATION_TOOLTIP_OR: + "Ist wahr (true), wenn einer der beiden Werte wahr (true) ist.", + LOGIC_TERNARY_CONDITION: "teste", + LOGIC_TERNARY_HELPURL: "https://de.wikipedia.org/wiki/%3F:#Auswahloperator", + LOGIC_TERNARY_IF_FALSE: "wenn falsch", + LOGIC_TERNARY_IF_TRUE: "wenn wahr", + LOGIC_TERNARY_TOOLTIP: + 'Überprüft eine Bedingung "teste". Wenn die Bedingung wahr ist, wird der "wenn wahr" Wert zurückgegeben, andernfalls der "wenn falsch" Wert', - CONTROLS_IF_ELSEIF_TOOLTIP: "Eine weitere Bedingung hinzufügen.", - CONTROLS_IF_ELSE_TOOLTIP: "Eine sonst-Bedingung hinzufügen, führt eine Anweisung aus, falls keine Bedingung zutrifft.", - CONTROLS_IF_HELPURL: "https://github.com/google/blockly/wiki/IfElse", // untranslated - CONTROLS_IF_IF_TOOLTIP: "Hinzufügen, entfernen oder sortieren von Sektionen", - CONTROLS_IF_MSG_ELSE: "sonst", - CONTROLS_IF_MSG_ELSEIF: "sonst wenn", - CONTROLS_IF_MSG_IF: "wenn", - CONTROLS_IF_TOOLTIP_1: "Wenn eine Bedingung wahr (true) ist, dann führe eine Anweisung aus.", - CONTROLS_IF_TOOLTIP_2: "Wenn eine Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Ansonsten führe die zweite Anweisung aus.", - CONTROLS_IF_TOOLTIP_3: "Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus.", - CONTROLS_IF_TOOLTIP_4: "Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus. Falls keine der beiden Bedingungen wahr (true) ist, dann führe die dritte Anweisung aus.", - LOGIC_BOOLEAN_HELPURL: "https://github.com/google/blockly/wiki/Logic#values", // untranslated - LOGIC_BOOLEAN_TOOLTIP: "Ist entweder wahr (true) oder falsch (false)", - LOGIC_BOOLEAN_TRUE: "wahr", - LOGIC_COMPARE_HELPURL: "https://de.wikipedia.org/wiki/Vergleich_%28Zahlen%29", - LOGIC_COMPARE_TOOLTIP_EQ: "Ist wahr (true), wenn beide Werte gleich sind.", - LOGIC_COMPARE_TOOLTIP_GT: "Ist wahr (true), wenn der erste Wert größer als der zweite Wert ist.", - LOGIC_COMPARE_TOOLTIP_GTE: "Ist wahr (true), wenn der erste Wert größer als oder gleich groß wie der zweite Wert ist.", - LOGIC_COMPARE_TOOLTIP_LT: "Ist wahr (true), wenn der erste Wert kleiner als der zweite Wert ist.", - LOGIC_COMPARE_TOOLTIP_LTE: "Ist wahr (true), wenn der erste Wert kleiner als oder gleich groß wie der zweite Wert ist.", - LOGIC_COMPARE_TOOLTIP_NEQ: "Ist wahr (true), wenn beide Werte unterschiedlich sind.", - LOGIC_NEGATE_HELPURL: "https://github.com/google/blockly/wiki/Logic#not", // untranslated - LOGIC_NEGATE_TITLE: "nicht %1", - LOGIC_NEGATE_TOOLTIP: "Ist wahr (true), wenn der Eingabewert falsch (false) ist. Ist falsch (false), wenn der Eingabewert wahr (true) ist.", - LOGIC_NULL: "null", - LOGIC_NULL_HELPURL: "https://de.wikipedia.org/wiki/Nullwert", - LOGIC_NULL_TOOLTIP: "Ist NULL.", - LOGIC_OPERATION_AND: "und", - LOGIC_OPERATION_HELPURL: "https://github.com/google/blockly/wiki/Logic#logical-operations", // untranslated - LOGIC_OPERATION_OR: "oder", - LOGIC_OPERATION_TOOLTIP_AND: "Ist wahr (true), wenn beide Werte wahr (true) sind.", - LOGIC_OPERATION_TOOLTIP_OR: "Ist wahr (true), wenn einer der beiden Werte wahr (true) ist.", - LOGIC_TERNARY_CONDITION: "teste", - LOGIC_TERNARY_HELPURL: "https://de.wikipedia.org/wiki/%3F:#Auswahloperator", - LOGIC_TERNARY_IF_FALSE: "wenn falsch", - LOGIC_TERNARY_IF_TRUE: "wenn wahr", - LOGIC_TERNARY_TOOLTIP: "Überprüft eine Bedingung \"teste\". Wenn die Bedingung wahr ist, wird der \"wenn wahr\" Wert zurückgegeben, andernfalls der \"wenn falsch\" Wert", - - - /** - * Cases - */ - cases_do: "Führe aus", - cases_condition: "Fall (Variable): ", - cases_switch: "Variable", - cases_add: "Fall", - cases_tooltip: "Führt den entsprechenden Fall aus, wenn die Überprüfung der Variable TRUE ergibt. Über das Zahnrad kannst du weitere Fälle hinzufügen. Über den 'Default' fall kannst du bestimmen, was passieren soll wenn keiner der vorher definierten Fälle eingetreten ist.", -} \ No newline at end of file + /** + * Cases + */ + cases_do: "Führe aus", + cases_condition: "Fall (Variable): ", + cases_switch: "Variable", + cases_add: "Fall", + cases_tooltip: + "Führt den entsprechenden Fall aus, wenn die Überprüfung der Variable TRUE ergibt. Über das Zahnrad kannst du weitere Fälle hinzufügen. Über den 'Default' fall kannst du bestimmen, was passieren soll wenn keiner der vorher definierten Fälle eingetreten ist.", +}; diff --git a/src/components/Blockly/msg/de/translations.js b/src/components/Blockly/msg/de/translations.js index 30d8048..de43dba 100644 --- a/src/components/Blockly/msg/de/translations.js +++ b/src/components/Blockly/msg/de/translations.js @@ -244,7 +244,7 @@ export const TRANSLATIONS = { senseBox_serial_tip: "Gibt Messwerte oder Daten auf dem Seriellen Monitor der Arduino IDE aus. Praktisch um ohne Display zu arbeiten", senseBox_output_timestamp: "Zeitstempel (RFC 3339)", - senseBox_led: "LED an digitalen", + senseBox_led: "LED an", senseBox_led_tip: "Einfache LED. Beim Anschluss sollte immer ein Vorwiderstand verwendet werden", senseBox_piezo: "Piezo an digital", diff --git a/src/components/Blockly/msg/en/sensebox-led.js b/src/components/Blockly/msg/en/sensebox-led.js index 236ea80..53eac49 100644 --- a/src/components/Blockly/msg/en/sensebox-led.js +++ b/src/components/Blockly/msg/en/sensebox-led.js @@ -1,45 +1,45 @@ export const LED = { + senseBox_led: "LED connected to", + senseBox_led_tip: "simple LED. Don't forget the resistor", + senseBox_rgb_led: "RGB-LED", + senseBox_rgb_led_tip: "RGB-LED", + /** + * WS2818 RGB LED + */ + senseBox_ws2818_rgb_led: "Set RGB-LED at", + senseBox_ws2818_rgb_led_init: "Initialise RGB LED (WS2818)", + senseBox_ws2818_rgb_led_position: "Position", + senseBox_ws2818_rgb_led_brightness: "Brightness", + senseBox_ws2818_rgb_led_tooltip: + "Change the color of your RGB LED with this block. Link a block for the color. If multiple RGB LEDs are chained together you can use the position to determine which LED is controlled.", + senseBox_ws2818_rgb_led_init_tooltip: + "Connect the RGB LED to one of the three **digital/analog ports**. If multiple RGB LEDs are daisy-chained together you can determine which LED is controlled by position.", + senseBox_ws2818_rgb_led_color: "Color", + senseBox_ws2818_rgb_led_number: "Number", - senseBox_led: "LED connected to digital", - senseBox_led_tip: "simple LED. Don't forget the resistor", + /** + * Color + */ - senseBox_rgb_led: "RGB-LED", - senseBox_rgb_led_tip: "RGB-LED", - - /** - * WS2818 RGB LED - */ - senseBox_ws2818_rgb_led: "Set RGB-LED at", - senseBox_ws2818_rgb_led_init: "Initialise RGB LED (WS2818)", - senseBox_ws2818_rgb_led_position: "Position", - senseBox_ws2818_rgb_led_brightness: "Brightness", - senseBox_ws2818_rgb_led_tooltip: "Change the color of your RGB LED with this block. Link a block for the color. If multiple RGB LEDs are chained together you can use the position to determine which LED is controlled.", - senseBox_ws2818_rgb_led_init_tooltip: "Connect the RGB LED to one of the three **digital/analog ports**. If multiple RGB LEDs are daisy-chained together you can determine which LED is controlled by position.", - senseBox_ws2818_rgb_led_color: "Color", - senseBox_ws2818_rgb_led_number: "Number", - - /** - * Color - */ - - COLOUR_BLEND_COLOUR1: "colour 1", - COLOUR_BLEND_COLOUR2: "colour 2", - COLOUR_BLEND_HELPURL: "http://meyerweb.com/eric/tools/color-blend/", - COLOUR_BLEND_RATIO: "ratio", - COLOUR_BLEND_TITLE: "blend", - COLOUR_BLEND_TOOLTIP: "Blends two colours together with a given ratio (0.0 - 1.0).", - COLOUR_PICKER_HELPURL: "https://en.wikipedia.org/wiki/Color", - COLOUR_PICKER_TOOLTIP: "Choose a colour from the palette.", - COLOUR_RANDOM_HELPURL: "http://randomcolour.com", - COLOUR_RANDOM_TITLE: "random colour", - COLOUR_RANDOM_TOOLTIP: "Choose a colour at random.", - COLOUR_RGB_BLUE: "blue", - COLOUR_RGB_GREEN: "green", - COLOUR_RGB_HELPURL: "http://www.december.com/html/spec/colorper.html", - COLOUR_RGB_RED: "red", - COLOUR_RGB_TITLE: "colour with", - COLOUR_RGB_TOOLTIP: "Create a colour with the specified amount of red, green, and blue. All values must be between 0 and 255.", - -} + COLOUR_BLEND_COLOUR1: "colour 1", + COLOUR_BLEND_COLOUR2: "colour 2", + COLOUR_BLEND_HELPURL: "http://meyerweb.com/eric/tools/color-blend/", + COLOUR_BLEND_RATIO: "ratio", + COLOUR_BLEND_TITLE: "blend", + COLOUR_BLEND_TOOLTIP: + "Blends two colours together with a given ratio (0.0 - 1.0).", + COLOUR_PICKER_HELPURL: "https://en.wikipedia.org/wiki/Color", + COLOUR_PICKER_TOOLTIP: "Choose a colour from the palette.", + COLOUR_RANDOM_HELPURL: "http://randomcolour.com", + COLOUR_RANDOM_TITLE: "random colour", + COLOUR_RANDOM_TOOLTIP: "Choose a colour at random.", + COLOUR_RGB_BLUE: "blue", + COLOUR_RGB_GREEN: "green", + COLOUR_RGB_HELPURL: "http://www.december.com/html/spec/colorper.html", + COLOUR_RGB_RED: "red", + COLOUR_RGB_TITLE: "colour with", + COLOUR_RGB_TOOLTIP: + "Create a colour with the specified amount of red, green, and blue. All values must be between 0 and 255.", +}; diff --git a/src/data/hardware.json b/src/data/hardware.json index f6f1a15..de7aefc 100644 --- a/src/data/hardware.json +++ b/src/data/hardware.json @@ -86,7 +86,7 @@ { "id": "bluetooth-bee", "name": "Bluetooth-Bee", - "src": "lora-bee.png", + "src": "ble-bee.png", "url": "https://docs.sensebox.de/hardware/bee-ble/" }, {