add arduino code generator

This commit is contained in:
Mario
2020-07-23 12:01:42 +02:00
parent c05572a68e
commit 54903fb2e7
23 changed files with 2699 additions and 26 deletions
+4
View File
@@ -0,0 +1,4 @@
import './loops';
import './sensebox';
import './logic';
import './sensebox-sensors';
+61
View File
@@ -0,0 +1,61 @@
import { defineBlocksWithJsonArray } from 'blockly';
import Blockly from 'blockly/core';
defineBlocksWithJsonArray([
// If/else block that does not use a mutator.
{
type: 'control_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,
colour: '#b063c5',
tooltip: '%{BKYCONTROLS_IF_TOOLTIP_2}',
helpUrl: '%{BKY_CONTROLS_IF_HELPURL}',
extensions: ['controls_if_tooltip']
},
{
type: 'controls_ifelse',
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'
}
],
message2: '%{BKY_CONTROLS_IF_MSG_ELSE} %1',
args2: [
{
type: 'input_statement',
name: 'ELSE'
}
],
previousStatement: null,
nextStatement: null,
colour: '#b063c5',
tooltip: '%{BKYCONTROLS_IF_TOOLTIP_2}',
helpUrl: '%{BKY_CONTROLS_IF_HELPURL}',
extensions: ['controls_if_tooltip']
}
]);
+51
View File
@@ -0,0 +1,51 @@
import Blockly from 'blockly';
Blockly.defineBlocksWithJsonArray([
{
type: 'controls_for',
message0: 'count with %1 from %2 to %3 by adding %4',
args0: [
{
type: 'field_variable',
name: 'VAR',
variable: null,
variableTypes: ['Number'],
defaultType: 'Number',
createNewVariable: true,
showOnlyVariableAssigned: false,
},
{
type: 'input_value',
name: 'FROM',
check: 'Number',
align: 'RIGHT',
},
{
type: 'input_value',
name: 'TO',
check: 'Number',
align: 'RIGHT',
},
{
type: 'input_value',
name: 'BY',
check: 'Number',
align: 'RIGHT',
},
],
message1: '%{BKY_CONTROLS_REPEAT_INPUT_DO} %1',
args1: [
{
type: 'input_statement',
name: 'DO',
},
],
inputsInline: false,
previousStatement: null,
nextStatement: null,
helpUrl: '%{BKY_CONTROLS_FOR_HELPURL}',
extensions: ['contextMenu_newGetVariableBlock', 'controls_for_tooltip'],
},
]);
@@ -0,0 +1,20 @@
import Blockly from 'blockly';
Blockly.Blocks['sensebox_sensor_temp_hum'] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_temp_hum);
this.appendDummyInput()
.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.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;
},
};
+16
View File
@@ -0,0 +1,16 @@
import Blockly from 'blockly';
Blockly.Blocks["sensebox_telegram"] = {
init: function () {
this.setColour(120);
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_telegram_init);
this.appendDummyInput()
.setAlign(Blockly.ALIGN_LEFT)
.appendField("telegram")
.appendField(new Blockly.FieldTextInput("token"), "telegram_token");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};